verify-refactor
Skill1 starsChanged 5 months agoMITView on GitHub
Prove a refactor preserved behavior by diffing deterministic output captured before and after the change. Use before trusting any refactor of load-bearing, deterministic code (a report, transform, backtest, codegen step).
In this repository4 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- cc-task-benchSkill
- llm-evalSkill
- tune-parametersSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
If you've already edited, stash or check out the original first (git stash / git worktree), capture, then restore.
- Distinctive: line 20
If output is nondeterministic (timestamps, ordering, ids), normalize both sides the same way (sort, strip volatile fields) before diffing — …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Goal: prove the change is behavior-preserving with evidence stronger than "tests still pass" — byte-identical output.
Let $ARGUMENTS be the command that produces deterministic output (e.g. npm run report -- --fixture sample). If none was given, ask the user for it, or infer it from the project's scripts.
- Baseline (before any edits). On the pre-refactor code, run the command and capture output to a temp file:
<command> > /tmp/golden-before.txt 2>&1- If you've already edited, stash or check out the original first (
git stash/git worktree), capture, then restore.
- Refactor. Make the change. Touch only what the refactor requires (see surgical-scope rule in CLAUDE.md).
- After. Re-run the same command:
<command> > /tmp/golden-after.txt 2>&1. - Diff.
diff -u /tmp/golden-before.txt /tmp/golden-after.txt.- Empty diff → behavior preserved. Report success.
- Non-empty diff → either a bug in the refactor (fix it) or an intended change (then this wasn't a pure refactor — call that out explicitly and get the change reviewed).
If output is nondeterministic (timestamps, ordering, ids), normalize both sides the same way (sort, strip volatile fields) before diffing — and note what you normalized.
Tie-in: if production and an offline replay share the exact same implementation (don't-duplicate rule), the replay is a golden-output harness for production refactors.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

