refactor
Skill7 starsChanged 6 months agoMITView on GitHub
Analyzes code for smells and structural issues, proposes a safe refactoring plan, and executes it with test verification. Use when code is hard to read, maintain, or extend.
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 repository45 other files it gives its agents.
- .claude/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- a11y-auditSkill
- api-designSkill
- architecture-reviewSkill
- business-blueprintSkill
- business-logic-auditSkill
- changelogSkill
- ci-pipelineSkill
- code-coverageSkill
- competitive-analysisSkill
- convert-codeSkill
- create-componentSkill
- db-migrationSkill
- debugSkill
- dependency-auditSkill
- deploy-checklistSkill
- design-flowSkill
- docker-setupSkill
- env-setupSkill
- error-monitorSkill
- estimateSkill
- explain-codeSkill
- fix-issueSkill
- generate-docsSkill
- git-cleanupSkill
- grill-meSkill
- handoffSkill
- legal-pagesSkill
- memory-importSkill
- memorySkill
- microcopySkill
- migrate-frameworkSkill
- onboardSkill
- optimizeSkill
- pr-summarySkill
- reference-appSkill
- review-prSkill
- security-scanSkill
- seo-scaffoldSkill
- tddSkill
- web-launch-checkSkill
- wireframeSkill
- write-skillSkill
- write-testsSkill
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 11 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 169 edited versions we read keep these.
11
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 19
Read the target code and identify issues from this list:
- Distinctive: line 28
Dead Code: Remove unused functions, imports, variables, and commented-out code
- Distinctive: line 45
Run them to establish a green baseline
- Distinctive: line 46
If no tests exist, flag this as a risk and recommend writing tests first
- Distinctive: line 50
After each change, verify:
- Distinctive: line 53
No new linting errors
- Distinctive: line 54
If a change breaks something, revert it immediately
- Distinctive: line 57
Run the full test suite for the affected area
- Distinctive: line 58
Verify no regressions via git diff
- Distinctive: line 59
Ensure the refactored code is actually simpler/cleaner than before
- Distinctive: line 60
If it isn't, consider reverting — refactoring should reduce complexity, not just move it
“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
Safe Code Refactoring
Context
!git status --short 2>/dev/null
!git stash list 2>/dev/null
Refactoring Process
Step 1: Analyze — Identify Code Smells
Read the target code and identify issues from this list:
- Long Method/Function (>40 lines): Extract smaller, focused functions
- Deep Nesting (>3 levels): Use early returns, guard clauses, or extract methods
- Code Duplication: Extract shared logic into reusable functions
- God Class/Module: Split into focused, single-responsibility modules
- Feature Envy: Move logic to the class/module that owns the data
- Primitive Obsession: Replace related primitives with a proper type/struct/class
- Long Parameter List (>4 params): Use an options/config object or builder pattern
- Dead Code: Remove unused functions, imports, variables, and commented-out code
- Magic Numbers/Strings: Extract into named constants
- Inconsistent Naming: Align with project conventions
- Missing Abstractions: Introduce interfaces/traits where concrete types are overused
- Tight Coupling: Introduce dependency injection or interface boundaries
Step 2: Plan — Define the Refactoring Strategy
For each identified issue:
- Name the specific refactoring technique (Extract Method, Move Function, Introduce Parameter Object, etc.)
- Describe the before and after state
- Assess the risk (High/Medium/Low) — does it touch public API? Does it cross module boundaries?
- List affected files
Present the plan to the user before executing.
Step 3: Verify — Check for Existing Tests
- Find all tests that cover the code being refactored
- Run them to establish a green baseline
- If no tests exist, flag this as a risk and recommend writing tests first
Step 4: Execute — Apply Changes
- Make one refactoring change at a time
- After each change, verify:
- The code still compiles/parses
- Existing tests still pass
- No new linting errors
- If a change breaks something, revert it immediately
Step 5: Validate — Final Checks
- Run the full test suite for the affected area
- Verify no regressions via
git diff - Ensure the refactored code is actually simpler/cleaner than before
- If it isn't, consider reverting — refactoring should reduce complexity, not just move it
Rules
- Never change behavior — refactoring is about structure, not features
- Never skip tests — if tests don't exist, say so and suggest writing them first
- Small steps — one technique per commit if possible
- Respect scope — don't refactor code outside the requested area
- Keep the diff minimal — don't reformat untouched code
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.

