Skip to content

feat: add pt migration command + .scratch/ convention#130

Merged
manager-identity[bot] merged 1 commit into
mainfrom
feat/pt-migration-command
May 11, 2026
Merged

feat: add pt migration command + .scratch/ convention#130
manager-identity[bot] merged 1 commit into
mainfrom
feat/pt-migration-command

Conversation

@manager-identity
Copy link
Copy Markdown
Contributor

Summary

Phase F of the locked-hygiene umbrella (#6118). Adds two safety valves so branch-on-first-edit doesn't block legitimate work:

  • .scratch/ convention — documented in CLAUDE.md / AGENTS.md / USAGE.md. Phase B's hook already exempts edits under .scratch/; this PR makes the convention discoverable.
  • pt migration command group — snapshot-based bulk-operation recording. `start` captures git HEAD + porcelain baseline into a state file outside the repo (`~/.project-tracker/migrations/`). `finish` diffs the tree, appends a section to `MIGRATIONS.md`, and optionally:
    • `--commit` marks the session as committed (files left in place)
    • `--revert` restores tracked files via `git restore`, trashes untracked files via `send2trash` — NEVER raw `rm`.

Migration `011_add_migrations_table.py` is additive-only (LOCAL_ONLY classification). Test `test_pt_db_migrate` updated for the new migration count.

Closes #6153.

Test plan

  • 17 new tests in `tests/test_migration_cli.py` cover happy path, validation (name regex, --force, mutual exclusion), edge cases (missing state file, baseline drift, already-missing untracked file), and lifecycle (state-file cleanup).
  • `pytest tests/test_migration_cli.py tests/test_handoff_cli.py tests/test_pt_db_migrate.py` — 52 passed.
  • Full suite: 559 passed, 1 pre-existing date-sensitive flake in `test_memory_cli` (unrelated; fixture hardcodes 2026-05-01 against `--since 7d`).
  • `pt migration --help` smoke test confirms group registration.
  • `pt db migrate` applies migration 011 cleanly.

🤖 Generated with Claude Code

Phase F of the locked-hygiene umbrella (#6118). Provides two safety
valves so branch-on-first-edit doesn't block legitimate work:

1. .scratch/ convention — documented in CLAUDE.md / AGENTS.md / USAGE.md.
   Phase B's hook already exempts edits under .scratch/; this PR makes
   the convention discoverable so agents reach for it instead of working
   around the hook.

2. pt migration command group — snapshot-based bulk-operation recording.
   `pt migration start <name>` captures git HEAD + porcelain baseline
   into a state file outside the repo (~/.project-tracker/migrations/
   or PT_MIGRATION_DIR for tests). `pt migration finish` diffs the
   tree, appends a section to MIGRATIONS.md at repo root, and optionally:
     --commit  marks the session as committed (files left in place)
     --revert  restores tracked files via `git restore`, trashes
               untracked files via send2trash — NEVER raw rm.

Migration 011_add_migrations_table.py adds the recording table
(additive only, LOCAL_ONLY classification). pt db migrate now applies
10 migrations; test_pt_db_migrate updated accordingly.

17 new tests cover happy path, validation (name regex, --force, mutual
exclusion), edge cases (missing state file, baseline drift, already-
missing untracked file), and lifecycle (state-file cleanup on finish).

Closes #6153.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@manager-identity manager-identity Bot added the feature New feature label May 11, 2026
@manager-identity manager-identity Bot merged commit cb4a264 into main May 11, 2026
2 checks passed
@manager-identity manager-identity Bot deleted the feat/pt-migration-command branch May 11, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants