refactoring
Skill119 starsChanged 5 months agoMITView on GitHub
Change the shape of code without changing behavior — safely, in small steps, preserving the project's layers and public contracts.
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, dependency-management and 9 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
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
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
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
- tmcfarlane/team-avatar★ 112same name
- larchanka/skills★ 50same name
- nimadorostkar/Claude-Skills-collection★ 33same name
- dan-the-dev/xp-developer-skills★ 31same 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 repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- architecture-reviewSkill
- code-reviewSkill
- documentationSkill
- git-workflowSkill
- mcp-toolsSkill
- project-architectureSkill
- prompt-renderingSkill
- runtime-engineSkill
- senior-python-engineeringSkill
- sidecar-auth-contextSkill
- skill-authoringSkill
- testingSkill
- vercel-react-best-practicesSkill
- yaml-schemaSkill
The file
We split this skill into the rules it gives an agent
7 rules. 0 are common, 4 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 53 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Do not edit this file directly.
- Distinctive: line 39
Tests first for risky changes: If coverage is thin, add characterization tests before refactoring.
- Distinctive: line 42
Stay in scope: Do not refactor unrelated code you happen to pass by.
- Very specific: line 45
Rename concepts deliberately: Update docs/ADRs/tests when a name changes.
- Distinctive: line 54
Keep layers intact: Verify the change respects architecture invariants.
- Distinctive: line 55
Update names everywhere: If a concept is renamed, fix code, tests, and docs in the same change.
- Very specific: line 58
Final validation: Run make check; diff should be structure-only.
“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
<!--
This file is generated by tools/skills.
Do not edit this file directly.
Edit .ai/skills/refactoring.md and run `make generate-ai`.
-->Skill: Refactoring
Purpose
Change the shape of code without changing its behavior, safely and in small steps, while preserving the project's layers and public contracts.
When to Use This Skill
- Improving structure, naming, or readability of existing code.
- Extracting a function/module, splitting a large file, or removing duplication.
- Preparing code for a feature by reshaping it first.
- Reducing complexity flagged during code/architecture review.
Files to Read First
AGENTS.md(boundaries and "no large uncontrolled rewrites")..ai/skills/architecture-review.md(invariants you must preserve).- The tests covering the code you intend to change.
- Any doc/ADR describing the contracts the code implements.
Core Principles
- Preserve public behavior. A refactor changes structure, not observable behavior or contracts.
- Tests first for risky changes. If coverage is thin, add characterization tests before refactoring.
- Small steps. Many tiny, verified changes beat one big rewrite.
- Stay in scope. Do not refactor unrelated code you happen to pass by.
- Don't collapse layers for convenience, and don't introduce circular dependencies.
- Rename concepts deliberately. Update docs/ADRs/tests when a name changes.
- Prefer simple extraction over introducing complex patterns.
Process
- Define the goal and boundary. State exactly what improves and which files are in scope.
- Ensure a safety net. Confirm or add tests that pin current behavior.
- Refactor in small steps, running
make testafter each meaningful step. - Keep layers intact. Verify the change respects architecture invariants.
- Update names everywhere. If a concept is renamed, fix code, tests, and docs in the same change.
- Keep commits logically scoped (one refactor idea per commit).
- Final validation. Run
make check; diff should be structure-only.
Checklist Before Finishing
- Public behavior and contracts unchanged (tests still pass unmodified, or changes are justified).
- Tests existed/were added before risky changes.
- Change is scoped; no unrelated code touched.
- No layer collapsed; no circular dependency introduced.
- Renamed concepts updated across code, tests, and docs.
- Commits are small and logically scoped.
make checkpasses.
Common Mistakes to Avoid
- "While I'm here" edits to unrelated code (scope creep).
- Refactoring without a test safety net.
- One giant commit mixing behavior changes with restructuring.
- Renaming a concept in code but not in docs/ADRs.
- Introducing a clever pattern where a simple extraction suffices.
- Creating import cycles by moving code carelessly.
Expected Final Report
State: the goal of the refactor and its scope; the safety net used (existing or
added tests); the small steps taken; confirmation that public behavior/contracts
are unchanged and layers are intact; any renamed concepts and where they were
updated; and the make check result.
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.

