refactor-safely
Skill1 starsChanged 6 months agoMITView on GitHub
Improve code structure without changing behavior, guarded by tests. Use when the user wants to clean up, restructure, simplify, or pay down tech debt.
23 other projects use a version of this.
Adopted by
Most recently taken up by
- JunnDung/cursor-agent-starter-kittheir own version, first seen Nov 29, 2026
- parvez3019/ai-coding-microservices-skillstheir own version, first seen Nov 22, 2026
- hamakyo/okf-skillstheir own version, first seen Nov 21, 2026
- Kuan-AI-com/agent-skillstheir own version, first seen Nov 15, 2026
- asymmetric-effort/convocatetheir own version, first seen Nov 15, 2026
- tirth8205/code-review-graphtheir own version, first seen Nov 11, 2026
Used with
Projects with it also use audit-test-suite, change-data-safely 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.
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
NVIDIASkilldebug-issue
Use when the user asks to debug, investigate, or fix a GitHub issue or supplies a repository bug report.
Also in 6 projects that use this
MicrosoftSkillfix-flaky-test
Reproduces and fixes flaky or quarantined tests. Tries local reproduction first (fast), then falls back to CI reproduce workflow (reproduce-flaky-tests.yml). Use this when asked to investigate, reproduce, debug, or fix a flaky test, a quarantined test, or an intermittently failing test.
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
Codagent-AISkillimplement-change
Implements an approved change in one continuous session, with tiered test runs. Use when asked to implement a change from its approved definition, or to invoke codagent:implement-change.
Also in 5 projects that use this
- +6 more from yaohuangguan
Other versions23 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 23
- tirth8205/code-review-graph★ 33ksame name
- techygarg/lattice★ 218same name
- VelimirMueller/ai-development-skills★ 7same name
- VelimirMueller/claude-skills★ 7same name
- yaohuangguan/remote-arc★ 5same name
- asymmetric-effort/convocate★ 4same name
- Arasz/ai-badger★ 3same name
- hamakyo/okf-skills★ 3same name
- imMamdouhaboammar/get-things-done★ 2same name
- contextosai/skills★ 1same name
13 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 repository3 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- fix-bugSkill
- implement-featureSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 5 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 21 edited versions we read keep these.
5
Distinctive
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 12
Ensure the code under refactor has tests that pin its current behavior.
- Distinctive: line 15
Run them — they must be green before you start.
- Distinctive: line 21
Don't mix refactoring with feature changes or bug fixes — separate commits.
- Distinctive: line 26
Run the tests after each step.
- Distinctive: line 34
Delete dead code. Don't leave commented-out blocks.
“Common” is measured: kept by at least 6 in 10 of the 21 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
Refactoring changes structure, not behavior. The safety net is tests.
1. Establish the net
- Ensure the code under refactor has tests that pin its current behavior. If coverage is thin, add characterization tests first so you can detect any behavior change.
- Run them — they must be green before you start.
2. Scope it
- Define exactly what you're improving and why (readability, duplication, coupling, performance). Keep the scope tight; resist expanding.
- Don't mix refactoring with feature changes or bug fixes — separate commits.
3. Refactor in small steps
- Make one transformation at a time (extract function, rename, inline, split module).
- Run the tests after each step. If they go red, you just learned the step changed behavior — revert and reconsider.
- Lean on automated refactorings (IDE rename, extract) where available; they're safer.
4. Improve toward the heuristics
- Apply
rules/06-architecture.md: reduce coupling, raise cohesion, remove the wrong abstraction, simplify control flow. - Delete dead code. Don't leave commented-out blocks.
5. Verify behavior is unchanged
- Full suite, lint, types all green. Diff should show structure changing, not outputs. If a test had to change, that's a behavior change — flag it explicitly.
6. Summarize
- State what improved and confirm behavior is identical. Note measurable wins (less duplication, fewer params, faster path) where relevant.
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.

