refactor
Skill0 starsChanged 6 months agoMITView on GitHub
Use this skill when restructuring, simplifying, or improving existing code without changing behavior. Triggers: 'refactor', 'simplify', 'clean up', 'reorganize', 'extract', 'consolidate', 'reduce duplication', 'too complex', 'tech debt', '/simplify'. Provides safe refactoring patterns that preserve behavior while improving structure.
196 other projects use a version of this.
Adopted by
Most recently taken up by
- Doist/todoist-aitheir own version, first seen Nov 9, 2026
- Doist/todoist-clitheir own version, first seen Nov 8, 2026
- rvdbreemen/OTGW-firmwaretheir own version, first seen Nov 8, 2026
- paulocsb/worldcup-fifa-pooltheir own version, first seen Nov 8, 2026
- DnsQueen/orcinus-skillstheir own version, first seen Nov 8, 2026
- taixuann/development-spacetheir own version, first seen Nov 8, 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 versions196 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 196
- 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
186 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 repository55 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-developmentSkill
- agent-teamsSkill
- ai-sdkSkill
- analyzing-financial-statementsSkill
- cache-componentsSkill
- chrome-devtoolsSkill
- Codex-automation-recommenderSkill
- Codex-md-improverSkill
- code-reviewSkill
- Command DevelopmentSkill
- creating-financial-modelsSkill
- data-visualizationSkill
- debugSkill
- develop-ai-functions-exampleSkill
- evolve-ai-layerSkill
- excalidraw-diagramSkill
- find-skillsSkill
- frontend-designSkill
- Hook DevelopmentSkill
- make-skill-templateSkill
- markdown-to-htmlSkill
- mcp-builderSkill
- MCP IntegrationSkill
- pdfSkill
- playwrightSkill
- Plugin SettingsSkill
- Plugin StructureSkill
- researchSkill
- security-best-practicesSkill
- skill-creatorSkill
- Skill DevelopmentSkill
- smithery-ai-cliSkill
- source-command-commit-and-deploySkill
- source-command-commitSkill
- source-command-create-prdSkill
- source-command-create-rulesSkill
- source-command-empty-redeploySkill
- source-command-evaluateSkill
- source-command-executeSkill
- source-command-handoffSkill
- source-command-plan-featureSkill
- source-command-primeSkill
- source-command-reviewSkill
- source-command-self-healSkill
- source-command-validateSkill
- sql-queriesSkill
- statistical-analysisSkill
- vscode-ext-localizationSkill
- webapp-testingSkill
- web-artifacts-builderSkill
- web-design-guidelinesSkill
- Writing Hookify RulesSkill
- xlsxSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. 0 are common, 14 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 169 edited versions we read keep these.
14
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 12
Tests must pass before AND after refactoring: If there are no tests, write them first.
- Distinctive: line 16
Run the full test suite — confirm everything passes
- Distinctive: line 17
Commit current state — create a clean rollback point
- Distinctive: line 34
Update imports throughout the codebase
- Distinctive: line 40
Create a single source of truth (utility, hook, base class)
- Distinctive: line 55
Use your IDE's rename tool, not find-and-replace
- Distinctive: line 56
Check that all callers updated correctly
- Distinctive: line 60
If a wrapper just passes through to one function, remove the wrapper
- Distinctive: line 61
If an interface has only one implementation and no plans for more, consider inlining
- Distinctive: line 76
Small steps, frequent tests: Never make multiple structural changes between test runs.
- Distinctive: line 88
Run full test suite + validation
- Distinctive: line 89
Check that no public API changed (unless intentional)
- Distinctive: line 90
Update any documentation that references changed structure
- Distinctive: line 91
Consider updating AGENTS.md or rules if patterns changed
“Common” is measured: kept by at least 6 in 10 of the 169 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 Skill
When to Use
The agent should read this skill when restructuring code to improve quality without changing external behavior.
Golden Rule
Tests must pass before AND after refactoring. If there are no tests, write them first. Refactoring without tests is just changing code and hoping.
Pre-Refactor Checklist
- Run the full test suite — confirm everything passes
- Commit current state — create a clean rollback point
- Identify the specific problem (don't just "clean up")
- Plan the changes before making them
Common Refactoring Patterns
Extract Function
When: A block of code does one distinct thing inside a larger function.
# Before: 50-line function doing 3 things
# After: 3 focused functions, each 15-20 linesExtract Module/File
When: A file has grown past 300-400 lines or handles multiple concerns.
- Group related functions and types
- Move to a new file with a clear name
- Update imports throughout the codebase
- Verify nothing broke
Consolidate Duplication
When: Similar logic exists in 3+ places.
- Identify the shared pattern
- Create a single source of truth (utility, hook, base class)
- Replace duplicates with calls to the shared version
- Don't consolidate things that are only superficially similar — if they'll diverge, keep them separate
Simplify Conditionals
When: Nested if/else blocks are hard to follow.
- Early returns to reduce nesting
- Guard clauses at the top of functions
- Lookup objects/maps instead of long switch statements
- Named boolean variables for complex conditions
Rename for Clarity
When: Names don't communicate intent.
- Functions: verb + noun (
getUserById, notgetData) - Booleans:
isActive,hasPermission,shouldRetry - Use your IDE's rename tool, not find-and-replace
- Check that all callers updated correctly
Flatten Hierarchy
When: Too many layers of abstraction for no benefit.
- If a wrapper just passes through to one function, remove the wrapper
- If an interface has only one implementation and no plans for more, consider inlining
- Premature abstraction is worse than duplication
Refactoring Workflow
1. Identify → What specifically is the problem?
2. Test → Ensure existing tests pass (write them if missing)
3. Commit → Clean rollback point
4. Change → Make ONE refactoring move at a time
5. Test → Run tests after each move
6. Commit → Checkpoint after each successful move
7. Repeat → Next refactoring moveSmall steps, frequent tests. Never make multiple structural changes between test runs.
When NOT to Refactor
- ❌ Right before a deadline (refactor after shipping)
- ❌ Code you don't understand yet (understand first, then refactor)
- ❌ Code that has no tests and is working (add tests first)
- ❌ For aesthetic reasons alone (must improve maintainability)
- ❌ Everything at once (pick the highest-impact area)
Post-Refactor
- Run full test suite + validation
- Check that no public API changed (unless intentional)
- Update any documentation that references changed structure
- Consider updating AGENTS.md or rules if patterns changed
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.

