refactor-safely
Skill0 starsChanged 6 days agoMITView on GitHub
Refactor code without changing what it does (rename, extract, split files, remove duplication, simplify). Use when the user says "clean this up", "refactor", "split this file", "simplify this function", "rename X everywhere", or "remove this duplication".
21 other projects use a version of this.
Adopted by
Most recently taken up by
- asymmetric-effort/convocatetheir own version, first seen Nov 15, 2026
- 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-sdlctheir own version, first seen Nov 1, 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
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
ficaviolaodorata520Skillsecurity-pass
Review an MCP server for common security gaps: LLM-facing surfaces as injection vector (tools, resources, prompts, descriptions), scope blast radius, destructive ops without consent, upstream auth shape, input sinks (URL / path / roots / shell / sampling / schema strictness / ReDoS), tenant isolation, leakage through errors and telemetry, unbounded resources, and HTTP-mode deployment surface. Use before a release, after a batch of handler changes, or when the user asks for a security review, audit, or hardening pass. Produces grouped findings and a numbered options list.
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 versions21 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 21
- 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
- asymmetric-effort/convocate★ 4same name
- Arasz/ai-badger★ 3same name
- hamakyo/okf-skills★ 2same name
- imMamdouhaboammar/get-things-done★ 2same name
11 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 repository24 other files it gives its agents.
- api-docsSkill
- changelogSkill
- ci-failure-fixSkill
- code-reviewSkill
- commit-messageSkill
- competitor-analysisSkill
- data-analystSkill
- debug-detectiveSkill
- dependency-upgradeSkill
- dockerizeSkill
- email-replierSkill
- eval-promptSkill
- incident-postmortemSkill
- meeting-notesSkill
- migration-safetySkill
- pr-descriptionSkill
- product-specSkill
- readme-writerSkill
- research-briefSkill
- security-checkSkill
- seo-articleSkill
- sql-helperSkill
- support-replySkill
- write-testsSkill
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 9 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 19 edited versions we read keep these.
9
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
If the code you will touch has no tests, write characterization tests that pin its current output for typical and edge inputs, including …
- Distinctive: line 22
Before renaming or moving anything, search for it in all forms:
- Distinctive: line 30
After each step, run the fast checks (affected tests and the type checker).
- Distinctive: line 31
Prefer tooling for renames and moves (IDE refactor, git mv) over hand edits so history and references follow.
- Distinctive: line 32
If the user is using git, suggest a commit per meaningful step so each one can be reverted alone.
- Distinctive: line 36
Do not fix bugs you find mid-refactor.
- Distinctive: line 37
Do not reformat unrelated code or change style across files you only passed through.
- Distinctive: line 38
If the refactor grows past what was agreed (more files, a new abstraction), stop and check with the user.
- Distinctive: line 42
Run the full baseline again.
- Very specific: line 43
Read your own final diff once, looking for accidental logic changes: flipped conditions, changed defaults, reordered side effects, dropped …
“Common” is measured: kept by at least 6 in 10 of the 19 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
Safe refactoring
A refactor changes structure, not behavior. Behavior includes return values, thrown errors and their messages, side effects and their order, public names and types, and log or event output that other systems read.
1. Scope it
State in one or two sentences what will change and what will not. If the user's request implies a behavior change ("and make it faster", "and fix the edge case"), split that into a separate step after the refactor.
2. Baseline
- Find and run the checks the project has: tests, type checker (
tsc --noEmit,mypy,go vet), linter. Get the commands frompackage.json,Makefile, CI config. - Record what passes now. Pre-existing failures are not yours to fix; note them.
- If the code you will touch has no tests, write characterization tests that pin its current output for typical and edge inputs, including current odd behavior. Do not refactor untested code you cannot run.
3. Find every usage
Before renaming or moving anything, search for it in all forms:
- static references (
git grep -n, editor "find references") - dynamic ones: string keys,
getattr/reflection, dependency-injection names, route names, template and config files, serialized data, SQL column names - external consumers: exported package API, HTTP or event contracts, other repos. If it is public, keep the old name as a deprecated alias or ask first.
4. Change in small steps
- One mechanical move per step: rename, extract function, inline, move file, replace conditional with lookup.
- After each step, run the fast checks (affected tests and the type checker). If something breaks, fix or revert that step before continuing.
- Prefer tooling for renames and moves (IDE refactor,
git mv) over hand edits so history and references follow. - If the user is using git, suggest a commit per meaningful step so each one can be reverted alone.
5. Stay in scope
- Do not fix bugs you find mid-refactor; list them and fix later as separate changes (a bug fix changes behavior and the tests should show it).
- Do not reformat unrelated code or change style across files you only passed through.
- If the refactor grows past what was agreed (more files, a new abstraction), stop and check with the user.
6. Verify and report
- Run the full baseline again; results must match.
- Read your own final diff once, looking for accidental logic changes: flipped conditions, changed defaults, reordered side effects, dropped
await, changed error types. - Report: what moved where, why the new shape is simpler, the checks you ran with results, and any bugs or follow-ups you noticed but did not touch.
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.

