safe-refactor
Skill0 starsChanged 14 days agoMITView on GitHub
Refactor in small, verified steps, with behavior locked by tests before any change. Use when asked to refactor, clean up, rename, extract or restructure code without changing behavior.
26 other projects use a version of this.
Adopted by
Most recently taken up by
- sudeepgupta90/my-ai-marketplacetheir own version, first seen Nov 8, 2026
- mjlueck-hash/cavemantheir own version, first seen Nov 8, 2026
- dhruvsaxena1998/skillstheir own version, first seen Nov 8, 2026
- MMACABRE/SKILLStheir own version, first seen Nov 8, 2026
- pahlevikun/levistacktheir own version, first seen Nov 1, 2026
- Terryc21/sitreptheir own version, first seen Nov 1, 2026
Used with
Projects with it also use verify-and-stop, investigate-first and 10 more.
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.
JuliusBrusseeSkillverify-and-stop
Prove existing work meets acceptance conditions without expanding scope. Use for validation-only tasks, completion checks, focused gate runs, and last-mile proof.
Also in 8 projects that use this
JuliusBrusseeSkillinvestigate-first
Diagnose ambiguous failures before editing. Use for unknown causes, intermittent behavior, performance regressions, or investigations needing evidence-ranked hypotheses.
Also in 7 projects that use this
- +10 more from JuliusBrussee
Other versions26 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 26
- JuliusBrussee/caveman★ 118ksame name
- Terryc21/sitrep★ 50same name
- JPeetz/agent-skills★ 14same name
- yeaight7/agent-powerups★ 6same name
- dfedoryshchev/weftworks★ 5same name
- Linchi1997yeh/craftsman-suite★ 2same name
- nomdedev/agent-manager-template★ 2same name
- xingtu1996/dsh-xingtu-skills★ 2same name
- dennisrongo/claude-skills★ 1same name
- dhruvsaxena1998/skills★ 1same name
16 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.
In this repository12 other files it gives its agents.
- agents-md-auditSkill
- brag-doc-from-gitSkill
- dependency-upgradeSkill
- explain-codebaseSkill
- pr-descriptionSkill
- prove-it-ranSkill
- repro-first-debuggingSkill
- review-my-diffSkill
- security-quick-reviewSkill
- session-handoffSkill
- write-agents-mdSkill
- write-subagentSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 24 edited versions we read keep these.
2
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
Close gaps: If the code to change has no tests, write characterization tests first: run the code with realistic inputs, record what it …
- Very specific: line 19
Check the blast radius: Search for callers and dependents (rg), including tests, scripts, docs and config that mention the names you will …
- Distinctive: line 24
After every step: run the relevant tests plus type check or lint.
“Common” is measured: kept by at least 6 in 10 of the 24 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 without changing behavior
Goal: improve structure while behavior stays identical, proven after every step.
Before touching code
- State the goal and the boundary in two lines: what gets better (readability, duplication, testability) and what must not change (public API, output format, performance envelope). Confirm with the user if the boundary is unclear.
- Find the safety net. Locate the tests that cover the code. Run them and record the baseline (pass count, any pre-existing failures). Pre-existing failures are not yours to fix silently; list them.
- Close gaps. If the code to change has no tests, write characterization tests first: run the code with realistic inputs, record what it currently does (even if odd), and assert exactly that. Commit or save these before refactoring.
- Check the blast radius. Search for callers and dependents (
rg), including tests, scripts, docs and config that mention the names you will change. Public or exported symbols need a deprecation path or an explicit go-ahead.
During
- One kind of change per step: rename, or extract, or move, or inline. Never mix a refactor with a bug fix or a feature.
- After every step run the relevant tests plus type check or lint. If red, undo the step (
git restoreor revert your last edit) and try a smaller step. Do not debug forward through a broken refactor. - Keep diffs reviewable. Aim for steps a person can review in minutes. Prefer several small commits if the user wants commits.
- Do not "improve" while you are here: unrelated formatting, dependency bumps and style changes go in a separate list at the end.
- Preserve behavior including error messages, ordering, logging and edge cases, unless the user says otherwise.
Finish
Report: the steps taken, tests run and results, what you deliberately did not change, bugs or smells you noticed but left alone, and any behavior you are not sure is preserved (for example, code with no coverage that you could not exercise).
Stop and ask when
- Tests cannot be run, or the baseline is red for reasons you cannot explain.
- The change needs a public API break.
- You find a real bug in the code being moved. Report it; fix it as its own change.
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.

