Skip to content

Commit 85a26fe

Browse files
fix(cleanup-skill): apply Step 1 proposals content-anchored, re-derive when a prior pass invalidated the snippet
1 parent 390a902 commit 85a26fe

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

.claude/commands/cleanup.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ For each pass in turn, apply all of that pass's changes, then move to the next p
4444

4545
Comments apply last, on purpose: that pass operates on whatever the earlier structural passes settled the code into, so it never edits lines a sibling pass is about to delete or rewrite.
4646

47-
Re-read each file immediately before editing it (a prior pass in this same run may have changed it). After all edits, run `bun run lint:check` on the touched files.
47+
**Treat every Step 1 proposal as snapshot-relative, not authoritative.** All passes analyzed the *original* files in parallel, so a proposal's line ranges and before/after text describe the code as it was *before* any edits — once an earlier pass has run, a later pass's snippet may no longer match. So for each change, before applying:
48+
49+
1. Re-read the file and locate the target by its **content** (the proposal's `old_string` snippet), not by its line number — line numbers from Step 1 are only a hint for where to look, since earlier edits shift them.
50+
2. If the `old_string` still matches verbatim, apply it — a content-anchored edit is safe even if its line moved.
51+
3. If it no longer matches (an earlier pass altered that region), do **not** force the stale patch. Re-derive the change from the current code by re-applying that pass's rule to the construct, or drop it if a prior pass already made it moot. Never apply a proposal against text it wasn't computed from.
52+
53+
After all edits, run `bun run lint:check` on the touched files.
4854

4955
## Step 4 — Summary
5056

0 commit comments

Comments
 (0)