refactoring
Skill1 starsChanged 5 days agoMITView on GitHub
Systematic code improvement via design principles, smell detection, and safe transformation patterns. Triggers: refactor this, clean this up, simplify this code, reduce complexity, extract this, this code is messy, tech debt, improve this code, code smell, rename, extract function, dead code.
58 other projects use a version of this.
Adopted by
Most recently taken up by
- ishandutta2007/Awesome-Claude-Skillstheir own version, first seen Nov 8, 2026
- larchanka/skillstheir own version, first seen Nov 8, 2026
- REPOZY/superpowers-optimizedtheir own version, first seen Nov 8, 2026
- nisarth/claude-skills-storetheir own version, first seen Nov 8, 2026
- ericwang200608-beep/LANYANT-Skillstheir own version, first seen Nov 8, 2026
- AnyOrgName/php-skillstheir own version, first seen Nov 8, 2026
Used with
Projects with it also use ci-cd, multi-agent-orchestration 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.
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 5 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
MicrosoftSkillerror-handling
统一错误处理系统。在添加 API 端点、修改错误处理、添加前端 API 调用、编写错误相关测试时使用。
Also in 7 projects that use this
klauswgSkillperformance
Optimize web performance for faster loading and better user experience. Use when asked to "speed up my site", "optimize performance", "reduce load time", "fix slow loading", "improve page speed", or "performance audit".
Also in 7 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 6 projects that use this
Other versions58 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 58
- handsontable/handsontable★ 22ksame name
- ciembor/agent-rules-books★ 2.8ksame name
- hitobito/hitobito★ 485same name
- databrickslabs/ontobricks★ 457same name
- DevelopersGlobal/ai-agent-skills★ 216same name
- REPOZY/superpowers-optimized★ 146same name
- extra-org/extra★ 119same name
- tmcfarlane/team-avatar★ 112same name
- larchanka/skills★ 50same name
- nimadorostkar/Claude-Skills-collection★ 33same name
48 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 repository68 other files it gives its agents.
- AGENTS.mdAGENTS.md
- accessibility-designSkill
- ai-evaluationSkill
- api-designSkill
- architecture-designSkill
- architecture-documentationSkill
- brainstormingSkill
- browser-verificationSkill
- bug-investigatingSkill
- build-vs-buySkill
- cicd-pipelineSkill
- code-archaeologySkill
- code-reviewingSkill
- code-slop-cleanupSkill
- compliance-privacySkill
- configuration-strategySkill
- containerizationSkill
- data-modelingSkill
- data-pipeline-designSkill
- data-qualitySkill
- dependency-impact-analysisSkill
- dependency-managementSkill
- deployment-checklistSkill
- deployment-repoSkill
- dx-auditSkill
- effort-estimationSkill
- exploratory-data-analysisSkill
- feature-planningSkill
- finops-cost-optimizationSkill
- frontend-architectureSkill
- gitops-deliverySkill
- git-workflowSkill
- incident-responseSkill
- infrastructure-as-codeSkill
- llm-app-engineeringSkill
- metrics-and-okrsSkill
- ml-experiment-trackingSkill
- ml-model-deploymentSkill
- ml-pipeline-designSkill
- mobile-architectureSkill
- mobile-releaseSkill
- notebook-to-productionSkill
- observability-designSkill
- performance-optimizationSkill
- plan-executionSkill
- prd-writingSkill
- project-documentationSkill
- project-proposalSkill
- project-reviewSkill
- release-managementSkill
- research-methodologySkill
- resilience-engineeringSkill
- retrospectiveSkill
- rollback-strategySkill
- security-auditSkill
- skill-routerSkill
- statistical-analysisSkill
- strategic-reviewSkill
- subagent-orchestrationSkill
- tdd-workflowSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. 0 are common, 15 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 53 edited versions we read keep these.
15
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 18
Before refactoring anything, verify that tests exist for the behavior you're about to restructure.
- Distinctive: line 20
Write characterization tests that document current behavior (even if the behavior has quirks)
- Distinctive: line 21
Run them and confirm they pass
- Distinctive: line 22
Only then begin refactoring
- Distinctive: line 24
If the user resists writing tests first, explain: refactoring without tests is not refactoring, it's rewriting with hope.
- Distinctive: line 28
Read the code and identify code smells.
- Distinctive: line 64
If tests break, undo immediately.
- Distinctive: line 68
After completing the planned sequence:
- Distinctive: line 71
Run the full test suite
- Distinctive: line 72
Check that no public API changed (unless that was the goal)
- Distinctive: line 73
Look for any new smells introduced by the refactoring
- Distinctive: line 78
KISS: Every transformation should make the code simpler, not more abstract
- Distinctive: line 80
YAGNI: Don't introduce abstractions for hypothetical future needs during refactoring
- Distinctive: line 82
Boy Scout Rule: Leave the code cleaner than you found it — every refactoring session should improve the surrounding code slightly, not just …
- Distinctive: line 83
Kent Beck's 4 Rules of Simple Design: After refactoring, the code should: (1) keep all tests green, (2) reveal intention clearly, (3) …
“Common” is measured: kept by at least 6 in 10 of the 53 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
Guide safe, incremental code improvements that preserve behavior while enhancing design. Refactoring is disciplined — every change is small, tested, and reversible.
Core Rule
Never change behavior and structure in the same step. Either you're adding a feature (behavior change) or you're refactoring (structure change). Mixing them creates bugs that are hard to trace.
Workflow
Step 1: Ensure Test Coverage
Before refactoring anything, verify that tests exist for the behavior you're about to restructure. If tests are missing:
- Write characterization tests that document current behavior (even if the behavior has quirks)
- Run them and confirm they pass
- Only then begin refactoring
If the user resists writing tests first, explain: refactoring without tests is not refactoring, it's rewriting with hope.
Step 2: Identify Smells
Read the code and identify code smells. Prioritize by impact — don't try to fix everything at once. The most common smells, roughly ordered by severity:
- Long function (>30 lines) → Extract method
- Duplicated logic → Extract and share
- Deep nesting (>3 levels) → Early returns, extract method
- Long parameter list (>4 params) → Introduce parameter object
- Feature envy → Move method to the class it uses most
- Primitive obsession → Introduce domain types
- Shotgun surgery → Consolidate related logic
- Divergent change → Split class by responsibility
See references/transformations.md for the complete catalog of safe transformations.
Step 3: Plan the Sequence
Order refactoring steps so that each step:
- Is small enough to verify easily
- Keeps all tests green
- Makes the next step easier
A good sequence often looks like:
- Rename for clarity (cheapest, highest readability impact)
- Extract helpers to reduce function length
- Consolidate duplicates using the extracted helpers
- Move methods to better homes
- Simplify interfaces
Step 4: Execute — One Step at a Time
For each transformation:
- Explain what you're about to do and why
- Apply the single transformation
- Run tests and confirm green
- Show the diff to the user
If tests break, undo immediately. A failing test after refactoring means the transformation changed behavior — that's a bug, not a test to fix.
Step 5: Review the Result
After completing the planned sequence:
- Compare before/after: Is the intent clearer? Is the code simpler?
- Run the full test suite
- Check that no public API changed (unless that was the goal)
- Look for any new smells introduced by the refactoring
Principles Applied
- DRY: Eliminate duplication discovered during refactoring
- KISS: Every transformation should make the code simpler, not more abstract
- SRP: Each extracted function/class should have one reason to change
- YAGNI: Don't introduce abstractions for hypothetical future needs during refactoring
- Functional Independence: Refactoring should reduce coupling, not increase it
- Boy Scout Rule: Leave the code cleaner than you found it — every refactoring session should improve the surrounding code slightly, not just the target. Small cleanups (renaming, removing dead code) near the area you're working in compound over time.
- Kent Beck's 4 Rules of Simple Design: After refactoring, the code should: (1) keep all tests green, (2) reveal intention clearly, (3) contain no duplication, (4) use the fewest classes and methods needed. Apply these as a checklist during Step 5 review.
Cross-Skill References
technical-debt-review— use to identify which areas are worth refactoring at a strategic level before startingdependency-impact-analysis— use before refactoring a shared component or public interface to understand blast radiuscode-slop-cleanup— most slop cleanup is a micro-refactor: use that skill for the pre-PR diff-scoped pass (removal-only, judged against file conventions); use this one when the cleanup turns structural (extract, move, re-abstract). They chain naturally: strip slop first, then refactor what remains
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.

