refactor
Skill0 starsChanged 7 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.
111 other projects use a version of this.
Adopted by
Most recently taken up by
- AllThingsSmitty/proven-skillstheir own version, first seen Oct 6, 2026
- GUOJIE-HONG/skillstheir own version, first seen Oct 5, 2026
- morodomi/dev-crewtheir own version, first seen Oct 5, 2026
- gilsmt/skillstheir own version, first seen Oct 4, 2026
- Integralist/agent-skillstheir own version, first seen Oct 4, 2026
- AlvaroVFon/skillstheir own version, first seen Oct 3, 2026
Used with
Projects with it also use modern-go, to-design 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.
jidechaoSkillmodern-go
Modernize Go code by applying version-appropriate idioms and APIs (gofix-style transformations). Scans go.mod for the Go version, then transforms Go source files to use modern patterns—from Go 1.0 through 1.26+. Use when the user says "现代化","现代Go语言", "地道的", "idiomatic", "modernize", "modern-go", "update Go code", "gofix", or wants to upgrade Go idioms.
Also in 3 projects that use this
jidechaoSkillto-design
Generate a design document (design proposal) from a PRD, in the style of Go's official design proposals — Abstract / Background / Design / Rationale / Compatibility / Implementation, heavy on the 'why' and tradeoffs. Triggers on: to-design, prd-to-design, prd转设计文档, 生成设计文档, 写设计文档, design doc, design proposal, 设计提案, 技术设计文档.
Also in 3 projects that use this
chidekinaSkilltest-gen
Generate test cases from type constraints and specs. Creates boundary tests, edge cases, and fixtures automatically. Pact-lang inspired. Triggers on: generate tests, test from spec, create fixtures, boundary tests.
Also in 5 projects that use this
pvnarpSkillincident
Guides incident response and post-mortem analysis. Covers triage, mitigation, root cause analysis, and prevention. Use when responding to active incidents, writing post-mortems, or improving incident processes.
Also in 6 projects that use this
platformplatformSkilldb-query
Query the local Postgres database of the active Aspire worktree via psql.
Also in 3 projects that use this
JetBrainsSkillfix-bug
End-to-end bug fix workflow for the Exposed project. Accepts a GitHub issue (#NUMBER), YouTrack issue (EXPOSED-NUMBER), or YouTrack URL (https://youtrack.jetbrains.com/issue/EXPOSED-NUMBER). Fetches the issue, creates a failing reproducer test, commits on a new branch, implements the fix, validates, and opens a PR. Use this skill whenever the user wants to fix a bug from an issue tracker, mentions a EXPOSED issue number, or references a GitHub issue to fix.
Also in 6 projects that use this
- +2 more from jidechao
Other versions111 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 111
- github/awesome-copilot★ 40ksame name
- parcadei/Continuous-Claude-v3★ 3.9ksame name
- codeaholicguy/ai-devkit★ 1.6ksame name
- SethGammon/Citadel★ 922same name
- solatis/claude-config★ 909same name
- boshu2/agentops★ 447same name
- nwiizo/tfmcp★ 373same name
- smallnest/goal-workflow★ 287same name
- oasm-platform/open-asm★ 204same name
- sd0xdev/sd0x-harness★ 191same name
101 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 94 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 94 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.

