refactor-safely
Skill1 starsChanged 15 days agoMITView on GitHub
Behavior-preserving cleanup — lock behavior with tests, refactor mechanically, re-run the same tests. Use when the user asks to refactor, clean up, simplify, or restructure without changing behavior.
19 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- rumotion/ai-agent-project-templatetheir own version, first seen Nov 1, 2026
- yaohuangguan/remote-arctheir own version, first seen Nov 1, 2026
- Remote-Arc/remote-arctheir own version, first seen Nov 1, 2026
- VelimirMueller/claude-skillstheir own version, first seen Nov 1, 2026
- rpraharaj/ai-sdlcedited, first seen Nov 1, 2026
- yaohuangguan/agent-playbooktheir own version, first seen Nov 1, 2026
Used with
Projects with it also use audit-test-suite, change-data-safely and 8 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.
yaohuangguanSkillaudit-test-suite
Find where an existing test suite is weak and decide what to test next, ranked by risk. Use this when asked to add missing tests, find gaps, raise coverage, assess test quality or see which areas are thin, even if the request only mentions a coverage percentage.
Also in 3 projects that use this
yaohuangguanSkillchange-data-safely
Change a database schema or stored data without breaking running code or losing data. Use this for any migration, new or changed column, backfill, bulk update, delete, index, or change to a stored format, including in small projects. Data mistakes are often impossible to undo.
Also in 3 projects that use this
SauravSrivastavSkilldebug-failure
Diagnose a failing test, command, or runtime behavior using evidence and produce a minimal verified fix.
Also in 3 projects that use this
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
- +6 more from yaohuangguan
Other versions19 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- rpraharaj/ai-sdlc★ 026% same
Wrote their own version · 18
- tirth8205/code-review-graph★ 33ksame name
- techygarg/lattice★ 209same name
- VelimirMueller/ai-development-skills★ 7same name
- VelimirMueller/claude-skills★ 7same name
- Remote-Arc/remote-arc★ 5same name
- yaohuangguan/remote-arc★ 5same name
- Arasz/ai-badger★ 3same name
- hamakyo/okf-skills★ 2same name
- imMamdouhaboammar/get-things-done★ 2same name
- contextosai/skills★ 1same name
8 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 repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- templates/AGENTS.mdAGENTS.md
- commitSkill
- cut-releaseSkill
- data-changeSkill
- debugSkill
- engineering-barSkill
- explain-codeSkill
- explore-codebaseSkill
- fix-ciSkill
- handoffSkill
- implement-changeSkill
- incident-triageSkill
- lean-reviewSkill
- open-prSkill
- performanceSkill
- production-passSkill
- ready-to-mergeSkill
- record-decisionSkill
- resolve-conflictsSkill
- revert-changeSkill
- review-changeSkill
- security-passSkill
- shape-workSkill
- ship-notesSkill
- start-projectSkill
- upgrade-depsSkill
- verify-uiSkill
- write-architectureSkill
- write-designSkill
- write-dev-tasksSkill
- write-docsSkill
- write-prdSkill
- write-testsSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 3 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 17 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Read AGENTS.md if present.
- Very specific: line 20
If coverage is too thin to notice a break, add characterization tests first with write-tests (assert current behavior, including odd edges).
- Very specific: line 22
Run those tests once. That green run is the baseline.
- Distinctive: line 33
No new framework, no new caching, no "while we are here" feature flags.
- Distinctive: line 46
Run Test (and Lint / Typecheck if known) from AGENTS.md.
- Very specific: line 56
Do not commit unless asked.
“Common” is measured: kept by at least 6 in 10 of the 17 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
Change structure, not behavior. If the user also wants new behavior, stop and send that part to shape-work / implement-change. Do not mix the two in one diff.
Read AGENTS.md if present.
Step 1 — Pin behavior
Name the unit (files, package, endpoint) and the behavior that must stay true. Prefer existing tests that already cover it.
If coverage is too thin to notice a break, add characterization tests first with write-tests (assert current behavior, including odd edges). Do not "improve" those assertions until after the refactor.
Run those tests once. That green run is the baseline. If they are red, this is debug, not a refactor.
Step 2 — Plan the moves
List mechanical steps. Each step should be boring. Climb Minimum path in engineering-bar: delete dead flexibility, replace hand-rolls with stdlib/native, inline a one-implementation abstraction.
- Extract a helper that already exists inlined
- Move a type to the layer that owns it
- Collapse a duplicate
- Rename inside the unit (update all callers in the same change)
No new framework, no new caching, no "while we are here" feature flags. Never delete trust-boundary checks or data-loss handling to look smaller.
Load engineering-bar (paths in that skill). The bar's structure rules apply; its correctness rule here means same results, not new acceptance checks.
Step 3 — Refactor
One cluster of moves, then re-run the same tests. Do not take the suite red across many unrelated files.
Stay inside the named unit plus its callers. Do not reformat files you did not otherwise touch.
Step 4 — Prove sameness
- Re-run the characterization / existing tests. They must pass.
- Run Test (and Lint / Typecheck if known) from
AGENTS.md. - Diff review: every change should be structural. If a conditional's meaning changed, revert that part or admit it is a behavior change and stop.
Done
- Behavior that was pinned
- Moves made (files)
- Tests run (baseline + after) and results
- Any leftover cleanup you did not do
Do not commit unless asked. If the user wants this shipped: ready-to-merge then commit.
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.

