Repository navigation
fix(refactor): revert only the failed step's own edits - #229
Merged
Merged
Conversation
The red-step revert restored touched files from git whenever the tree was clean at the start of the run. Commits during a run are optional, so a restore reset a shared file to its last commit and discarded earlier green steps that were not yet committed. Undo the step's own edits directly and never use checkout, restore, reset --hard, clean, or stash to undo a step. Co-Authored-By: Claude <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
The refactor skill's red-step revert could throw away finished work.
The bug. On a red suite, the skill ran
git checkout/git restoreon the touched files whenever git was available and the tree was clean at the start of the run. Commits during a run only happen if you ask for them, and even then can be grouped. Git restores a file to its last commit, so when two steps touch the same file with no commit between them, reverting the second step also discarded the first, already-green step. That contradicted the skill's own stop-rule promise that "everything already applied is green and stands."The fix. A red step now undoes only its own edits directly: reverse each edit, delete any file the step created, and move renamed or moved files back. The skill never restores files from git to undo a step, never runs
git reset --hard,git clean, orgit stashfor it, and re-runs the suite to show the revert is back to green.Changes
han-coding/skills/refactor/SKILL.md: Step 4, item 4 rewritten.han-coding/docs/skills/refactor.md: the "what you get" bullet now says a revert touches only that step's edits.Found during the Mikado Method research in #228. That research's Mikado recommendations are deliberately out of scope here.
Test plan
npm run lintpassesnpm testpasses/refactoron a target where two planned steps edit the same file, with no commits requested, and force the second step red; confirm the first step's change survives the revert.🤖 Generated with Claude Code