feat: add pt migration command + .scratch/ convention#130
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 migrationcommand 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: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
🤖 Generated with Claude Code