Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion han-coding/docs/skills/refactor.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ Restructured code in your working tree, not a report. Specifically:
- **A refactoring plan**, shown before the first edit: numbered items, each one named refactoring with the evidence
behind it and the files it should touch.
- **One verified step at a time.** Each step shows the runner's summary line after the change. Red steps are reverted
and either retried smaller or deferred with what was learned.
and either retried smaller or deferred with what was learned. A revert undoes only that step's own edits, so earlier
green steps and your other uncommitted work stay in place even when nothing has been committed yet.
- **A final summary**, covering:
- each refactoring applied (named, with its evidence and finding IDs where a report was the source)
- YAGNI deferrals with reopen triggers
Expand Down
13 changes: 8 additions & 5 deletions han-coding/skills/refactor/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,14 @@ Take the plan items in order. For each:
stop in the shape [collaborative-stop-rule.md](../../references/collaborative-stop-rule.md) specifies. Absent such a
request, continue as below; an ordinary invocation is unchanged.

4. **Red: revert this step.** When git is available and the tree was clean at start, `git checkout`/`git restore` the
touched files. When git is absent, or the tree was already dirty at start, undo the edits directly instead, so
reverting this step does not discard the user's other work. Do not patch forward over a red suite; a failed step
means the mechanic was unsafe or the coverage was thinner than it looked. Diagnose, then either retry with a smaller
step or defer the item with what you learned.
4. **Red: revert this step, and only this step.** Undo the edits this step made directly: reverse each edit, delete
any file the step created, and move a renamed or moved file back to its original path. Every earlier green step and
the user's other work stay in place. Never undo a step by restoring files from git: `git checkout`/`git restore`
resets a file to its last commit, which also discards any earlier green step in that file not yet committed. Never
run `git reset --hard`, `git clean`, or `git stash` to undo a step. Re-run the suite and paste the summary line to
show the revert is back to green. Do not patch forward over a red suite; a failed step means the mechanic was unsafe
or the coverage was thinner than it looked. Diagnose, then either retry with a smaller step or defer the item with
what you learned.
5. **Stop rules.** If the step needed files outside its declared blast radius, or the only way to make it work changes
observable behavior, or two consecutive plan items have been reverted: stop, report where things stand (everything
already applied is green and stands), and let the user re-scope.
Expand Down
Loading