refactor-safely
Skill1 starsChanged 2 days agoMITView on GitHub
Restructure, rename, split or move code without changing behaviour, and prove that nothing changed. Use this for any refactor, cleanup, file move, module split or dead code removal, including when it is only one step inside a larger task.
We split this skill into the rules it gives an agent
6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 15 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Record the baseline: Run the tests, type check and build, and save the results.
- Very specific: line 21
Check that tests protect this code: If the code has no tests, write tests that record its current behaviour first, using write-tests.
- Distinctive: line 24
Move in small mechanical steps: Use the editor or language tools to rename and move where you can.
- Distinctive: line 30
Update everything that names the old path: Search for it in imports, tests, docs, build config, CI, scripts, and strings built at runtime.
- Distinctive: line 39
Prove that behaviour is unchanged: Use the strongest check you can:
- Distinctive: line 44
Run the type checker with unused-name checks on.
“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Refactor safely
A refactor promises that behaviour stays the same, so it needs evidence. Mixing behaviour changes into a move makes that impossible to review.
When to use
The goal is better structure with the same behaviour. If behaviour must change too, do it in a separate commit.
Steps
- Record the baseline. Run the tests, type check and build, and save the results. Stop and fix the baseline first if it is failing in this area.
- Check that tests protect this code. If the code has no tests, write tests
that record its current behaviour first, using
write-tests. - Move in small mechanical steps. Use the editor or language tools to rename
and move where you can. Prefer
git mv, so that history follows the file. - Commit structure apart from behaviour. A reviewer should be able to read a move commit as a move.
- Update everything that names the old path. Search for it in imports, tests, docs, build config, CI, scripts, and strings built at runtime. Strings are easy to miss, because neither the compiler nor search-and-replace on imports finds them.
- Check that tests still test something. A test that looks through a folder or matches a path can pass with nothing to check after a move. Confirm that test counts did not fall, and that each path-based check still finds its files.
Prove that behaviour is unchanged. Use the strongest check you can:
- Compare the built output before and after, with paths normalized.
- Compare the test count and results with the baseline.
- Compare the public API or exported names.
- Run the type checker with unused-name checks on.
- Finish. Follow
verify-and-report.
Stop and ask when
- You find a bug. Mention it, and do not fix it inside the refactor.
- A clean move needs a public API change.
- The change is too large to review, and it could be split.
Common mistakes
| Tempting move | Why it fails | Do this instead |
| Fix a bug during the move | Reviewers cannot tell what changed | Use a separate commit |
| Reformat everything | Buries the real change | Keep formatting out |
| Say tests still pass | Fewer tests may be running | Compare the counts |
| Delete code that looks unused | It may be reached dynamically | Search for it, including strings |
| Add a new abstraction | That is a design change, not a refactor | Keep to the agreed goal |
Report
Structure changed: <what moved>
Behaviour changed: none
Equivalence proof: <what you compared, and the result>
Test count: <before> -> <after>
References updated: <imports, docs, CI, scripts>Other versions19 projects use a version of this.
Word for word · 2
- Remote-Arc/remote-arc★ 5100% same
- yaohuangguan/remote-arc★ 5100% same
Edited · 0
None found.
Wrote their own version · 17
- tirth8205/code-review-graph★ 32ksame name
- techygarg/lattice★ 209same name
- VelimirMueller/ai-development-skills★ 7same name
- VelimirMueller/claude-skills★ 7same name
- Arasz/ai-badger★ 3same name
- hamakyo/okf-skills★ 2same name
- imMamdouhaboammar/get-things-done★ 2same name
- contextosai/skills★ 1same name
- exactbee/claude-code-workflow★ 1same name
- rpraharaj/ai-engineer★ 1same name
7 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use debug-issue.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
NVIDIASkilldebug-issue
Use when the user asks to debug, investigate, or fix a GitHub issue or supplies a repository bug report.
Also in 5 projects that use this
In this repository14 other files it gives its agents.
- AGENTS.mdAGENTS.md
- audit-test-suiteSkill
- change-data-safelySkill
- debug-failureSkill
- fix-flaky-testSkill
- hand-off-workSkill
- implement-changeSkill
- orient-in-codebaseSkill
- review-codeSkill
- secure-changeSkill
- use-external-apiSkill
- verify-and-reportSkill
- write-pull-requestSkill
- write-testsSkill
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.

