refactor
Skill0 starsChanged yesterdayMITView on GitHub
Change code structure without changing behavior: refactor, clean up, remove duplication or dead code, rename, move, or simplify. For a change in behavior, use tdd instead.
195 other projects use a version of this.
Adopted by
Most recently taken up by
- Archont561/skillstheir own version, first seen Nov 15, 2026
- nazmirket/skillstheir own version, first seen Nov 15, 2026
- qivora-labs/agentinittheir own version, first seen Nov 15, 2026
- NomadicDaddy/aiddtheir own version, first seen Nov 15, 2026
- zircote-plugins/refactortheir own version, first seen Nov 15, 2026
- vlad-ryzhkov/ai-context-engineering-for-frontendtheir own version, first seen Nov 15, 2026
Used with
Projects with it also use ascii-diagram, debug-fix 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.
SethGammonSkillascii-diagram
Generate perfectly aligned ASCII diagrams — architecture, flow, sequence, box-and-arrow. Uses a programmatic character-grid approach so alignment is guaranteed by math, not token prediction. Includes post-render verification.
Also in 4 projects that use this
zebbernSkilldebug-fix
Find and fix a bug or issue — from any source (GitHub issue, error message, user report, or observed behavior)
Also in 4 projects that use this
parcadeiSkillagent-context-isolation
Agent Context Isolation
Also in 3 projects that use this
parcadeiSkillagentica-infrastructure
Reference guide for Agentica multi-agent infrastructure APIs
Also in 3 projects that use this
- +8 more from parcadei
Other versions195 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 195
- github/awesome-copilot★ 41ksame name
- unkeyed/unkey★ 5.5ksame name
- parcadei/Continuous-Claude★ 3.9ksame name
- parcadei/Continuous-Claude-v2★ 3.9ksame name
- parcadei/Continuous-Claude-v3★ 3.9ksame name
- adobe/S3Mock★ 1.2ksame name
- SethGammon/Citadel★ 927same name
- poshan0126/dotclaude★ 871same name
- JordanCoin/codemap★ 710same name
- membrane/api-gateway★ 658same name
185 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.
- astroSkill
- bun-standardsSkill
- postgresSkill
- react-engineeringSkill
- rust-standardsSkill
- spring-bootSkill
- tailwind-v4Skill
- typescript-standardsSkill
- vitest-testingSkill
- api-designSkill
- architecture-reviewSkill
- benchmark-readiness-reviewSkill
- cli-designSkill
- codebase-scoutingSkill
- code-review-findingsSkill
- config-projection-reviewSkill
- documentation-hygieneSkill
- domain-modelingSkill
- formal-verificationSkill
- implementation-planningSkill
- orchestration-workflowSkill
- problem-clarificationSkill
- product-copySkill
- repository-text-hygieneSkill
- researchSkill
- security-scope-reviewSkill
- setup-canastaSkill
- system-designSkill
- task-closeoutSkill
- tddSkill
- technical-writingSkill
- upstream-contributionSkill
- writing-issuesSkill
- writing-prSkill
The file
We split this skill into the rules it gives an agent
9 rules. 0 are common, 7 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 170 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 9
If behavior must change, it is not a refactor: split it out and use tdd.
- Distinctive: line 17
Never mix a behavior change into a refactor, not even a "small fix" you notice.
- Distinctive: line 21
Use the compiler, type system, IDE, or AST tools for renames and moves instead of editing text by hand when they are available.
- Distinctive: line 26
Do not add an abstraction, layer, or wrapper unless it removes demonstrated duplication, coupling, or confusion.
- Distinctive: line 35
Make sure a check would catch drift.
- Very specific: line 52
Leave mechanical rules (unused or wildcard imports, any, formatting) to the repository's linters and formatters.
- Distinctive: line 56
Do not refactor generated code, applied migrations, third-party code, or configuration files.
- Distinctive: line 61
After each transformation, run the narrowest check that could expose drift.
- Distinctive: line 71
Keep structure and behavior in separate commits (Kent Beck's *Tidy First?*): a refactor commit contains no behavior change.
“Common” is measured: kept by at least 6 in 10 of the 170 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
A refactor changes structure and keeps observable behavior exactly the same.
If behavior must change, it is not a refactor: split it out and use tdd.
Agent failure modes
Coding agents often change behavior while "refactoring" (in published studies, about one recommended refactoring in fourteen changed functionality or broke syntax). These rules override convenience:
- Never mix a behavior change into a refactor, not even a "small fix" you notice. Report it, and if asked, do it as a separate change.
- One named transformation at a time (extract function, inline, rename, move, replace conditional), each leaving the code buildable and its checks green.
- Use the compiler, type system, IDE, or AST tools for renames and moves instead of editing text by hand when they are available.
- Absence of static references does not prove code is dead: check configuration, reflection, registration, generated code, scripts, and entry points first.
- Do not add an abstraction, layer, or wrapper unless it removes demonstrated duplication, coupling, or confusion.
Before editing
- Name the behavior that must not change: public APIs, outputs, persisted or serialized data, errors, ordering, side effects, authorization decisions, and performance where it is part of the contract.
- Find every consumer of the code you will touch.
- Make sure a check would catch drift. If the existing tests are weak around the code, add characterization tests first; they record current behavior, right or wrong.
- Name the structural problem you are fixing and stay inside it. Adjacent cleanup the user did not ask for gets mentioned, not done.
What to fix
- Duplicated logic: one owner per behavior.
- Dead code, commented-out code, and compatibility paths with no remaining consumer: delete them in the same change.
- Wrappers and layers with a single caller that add nothing: inline them.
- Swallowed exceptions: fail fast or handle the error deliberately.
- Complex conditionals, unclear names, magic numbers.
- Explanations made obsolete by the move: delete them rather than keep a historical copy beside the new owner.
Leave mechanical rules (unused or wildcard imports, any, formatting) to the
repository's linters and formatters. If a rule you keep fixing has no linter,
propose one instead of fixing it by hand every time.
Do not refactor generated code, applied migrations, third-party code, or configuration files.
Verify
- After each transformation, run the narrowest check that could expose drift; then check affected dependents in proportion to their reach and risk.
- Where tests are weak or the change crosses a boundary, compare before and after directly: characterization, differential, or trace evidence.
- Review the final diff for accidental changes to defaults, constants, errors, ordering, transactions, async behavior, authorization, data shape, and resource use.
Commit and report
- Keep structure and behavior in separate commits (Kent Beck's Tidy First?): a refactor commit contains no behavior change.
- Report the behavior preserved, the transformations applied, the checks run and their results, and any residual uncertainty. If equivalence could not be established, say so and treat the work as a behavior 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.

