Skip to content

fix(refactor): revert only the failed step's own edits - #229

Merged
mxriverlynn merged 1 commit into
v6.0.0-betafrom
fix/refactor-step-undo
Oct 15, 2026
Merged

mxriverlynn merged 1 commit into
v6.0.0-betafrom
fix/refactor-step-undo

Conversation

@mxriverlynn

Copy link
Copy Markdown
Collaborator

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 restore on 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, or git stash for 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 lint passes
  • npm test passes
  • Manual: run /refactor on 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

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>
@mxriverlynn
mxriverlynn marked this pull request as ready for review October 15, 2026 20:39
@mxriverlynn
mxriverlynn merged commit f413d73 into v6.0.0-beta Oct 15, 2026
2 checks passed
@mxriverlynn
mxriverlynn deleted the fix/refactor-step-undo branch October 15, 2026 20:39
@mxriverlynn mxriverlynn mentioned this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant