refactoring
Skill1 starsChanged 40 days agoMITView on GitHub
Disciplined refactoring — change structure without changing behavior, in tiny reversible steps under green tests. Use when restructuring code, paying down a smell, or preparing messy code for a change. Language-agnostic. Triggers: refactor, code smell, technical debt, extract function, make this testable.
69 other projects use a version of this.
Adopted by
Most recently taken up by
- juninmd/skillstheir own version, first seen Nov 29, 2026
- odjacobs/claude-skillstheir own version, first seen Nov 29, 2026
- wormeyman/wormeyman-skillstheir own version, first seen Nov 26, 2026
- fabiandistler/agentstheir own version, first seen Nov 25, 2026
- syanga/astacktheir own version, first seen Nov 24, 2026
- vojto/claude-skillstheir own version, first seen Nov 22, 2026
Used with
Projects with it also use ci-cd, logging 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.
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 5 projects that use this
diego-tobalinaSkilllogging
Logging best practices for Java (SLF4J/Logback) and Node.js (Winston/Pino). Use for structured logging, log levels, and avoiding sensitive data exposure.
Also in 4 projects that use this
AWSSkillplanning
Discovers user intent and generates a structured, step-by-step plan for model customization workflows. This skill must always be activated alongside any other skill when the user's request relates to model customization — including fine-tuning, training, building, customizing, reviewing data, or getting advice on approach, regardless of domain. Do not skip this skill even if the immediate ask is narrow (e.g., reviewing data format or a single workflow step), because planning discovers the full scope of work needed. Also activate when the user wants to resume, continue, or modify an existing plan.
Also in 8 projects that use this
dkprogSkilldependency-management
Apply when wiring dependencies, integrating external services, or designing interfaces between modules. Ensures loose coupling through dependency injection, interface segregation, and proper abstraction boundaries.
Also in 3 projects that use this
javalenciacaiSkillmulti-agent-orchestration
Design and coordinate multi-agent systems where specialized agents work together to solve complex problems. Covers agent communication, task delegation, workflow orchestration, and result aggregation. Use when building coordinated agent teams, complex workflows, or systems requiring specialized expertise across domains.
Also in 3 projects that use this
harrissohail6Skilldatabase-design
Database schema design and SQL best practices. Use when designing tables, writing queries, or optimizing database performance.
Also in 5 projects that use this
Other versions69 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 69
- handsontable/handsontable★ 22ksame name
- ciembor/agent-rules-books★ 2.8ksame name
- hitobito/hitobito★ 485same name
- databrickslabs/ontobricks★ 474same name
- DevelopersGlobal/ai-agent-skills★ 220same name
- REPOZY/superpowers-optimized★ 147same name
- extra-org/extra★ 121same name
- tmcfarlane/team-avatar★ 113same name
- larchanka/skills★ 66same name
- nimadorostkar/Claude-Skills-collection★ 41same name
59 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 repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- addressing-findingsSkill
- auditSkill
- codebase-onboardingSkill
- codex-reviewSkill
- compatibilitySkill
- debuggingSkill
- developSkill
- distributed-racesSkill
- memorySkill
- nix-dev-envSkill
- nix-flakesSkill
- nixosSkill
- nix-packagingSkill
- nix-reviewSkill
- retroSkill
- review-initSkill
- review-rulesSkill
- rust-architecture-reviewSkill
- rust-architectureSkill
- rust-cliSkill
- rust-cloud-nativeSkill
- rust-concurrencySkill
- rust-ecosystemSkill
- rust-embeddedSkill
- rust-errorsSkill
- rust-fintechSkill
- rust-idiomsSkill
- rust-macrosSkill
- rust-mlSkill
- rust-navigationSkill
- rust-ownershipSkill
- rust-performanceSkill
- rust-pluginsSkill
- rust-reviewSkill
- rust-securitySkill
- rust-testingSkill
- rust-traitsSkill
- rust-unsafeSkill
- rust-webSkill
- specsSkill
- sql-reviewSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 61 edited versions we read keep these.
1
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 30
Don't refactor on a red bar, mid-debugging, or "while I'm in here" alongside a feature — separate the commits.
- Very specific: line 74
Keep behavior identical: don't "improve" an error type or a public signature mid-refactor — that's a behavior/API change, do it separately …
“Common” is measured: kept by at least 6 in 10 of the 61 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
Refactoring
Refactoring is changing how code is structured without changing what it does. The discipline is what separates it from "rewriting and hoping": tiny reversible steps, behavior held constant, tests green the whole way.
The two rules
1. NEVER refactor and change behavior in the same step.
2. NEVER refactor without a test safety net that's currently GREEN.Mixing structure and behavior changes means a failing test can't tell you which one broke it. Refactoring without tests is just editing — you have no way to know you preserved behavior.
When to Use
- Restructuring code that works but is hard to read/change
- Paying down a specific smell
- "Making the change easy, then making the easy change" — refactor first to fit a new feature, then add the feature (two separate steps/commits)
Don't refactor on a red bar, mid-debugging, or "while I'm in here" alongside a feature — separate the commits.
The loop
1. GREEN — confirm the tests pass now. No tests? Write characterization
tests first that pin current behavior.
2. ONE STEP — apply a single, named transformation (below).
3. GREEN — run the tests again immediately. Still green → keep; red → revert this step.
4. COMMIT — small commits between steps so every step is reversible.
5. REPEAT — until the smell is gone.Small steps make mistakes cheap: when a step goes red, you revert seconds of work, not an hour's.
Characterization tests first
Refactoring legacy code with no tests? Don't trust your reading of it — pin its actual current
behavior with tests first (even ugly ones, even snapshot/insta tests of the output), then
refactor under them. The safety net is the precondition, not an afterthought (→ rust-testing).
Named transformations
Refactor by recognizable moves, not freehand edits:
- Extract function / variable — name a chunk of logic or a sub-expression.
- Inline — the reverse, when the indirection costs more than it gives.
- Rename — make the name tell the truth (the cheapest, highest-value refactor).
- Introduce type — replace a primitive/
bool/stringly-typed value with a newtype/enum (→rust-traits,rust-idioms). - Replace conditional with dispatch — a sprawling
match/ifon a tag → enum dispatch or a trait (→rust-traits). - Extract trait / module — pull a seam so the unit becomes testable (→
rust-architecture). - Slide statements / split loop — group related code; one loop per concern.
Rust-specific
- Let the compiler drive: rename/extract and lean on
rustc's errors to find every call site — the type system makes many refactors mechanically safe. cargo clippysuggests refactors (needless clones, complex matches) —--fixapplies the safe ones (→rust-idioms).- Restructuring to satisfy the borrow checker (split borrows, ownership moves) is its own kind of
refactor →
rust-ownership. - Keep behavior identical: don't "improve" an error type or a public signature mid-refactor —
that's a behavior/API change, do it separately (→
rust-errors, semver inrust-ecosystem).
Boundaries
- The test safety net (characterization, snapshot, property) →
rust-testing; specs as the behavior contract →specs. - Which smells to target / the Good→Bad catalog →
rust-idioms(anti-patterns). - Extracting seams/ports as a larger structural move →
rust-architecture.
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.

