refactor
Skill0 starsChanged 6 months agoMITView on GitHub
Use when the user wants a line-by-line refactoring plan on a file/module with analysis, ordered proposals and risk assessment. Triggers: "refactor this file", "propose a redesign of X", "analyze and clean up this module", "/refactor".
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 repository14 other files it gives its agents.
- buildSkill
- devSkill
- doc-updateSkill
- doSkill
- huntSkill
- knowledgeSkill
- pushSkill
- questionsSkill
- security-reviewSkill
- synthesizeSkill
- testSkill
- todoSkill
- verify-devSkill
- verify-todoSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 6 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 169 edited versions we read keep these.
6
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 touching anything, understand what is being refactored and why:
- Distinctive: line 42
Read in full each target file.
- Distinctive: line 61
Don't skip a block. A block marked 🟢 must still be explicitly examined.
- Distinctive: line 67
After the full analysis, build an ordered plan.
- Distinctive: line 121
Before validating the plan, make sure that:
- Distinctive: line 146
Read every line — no skimming, no "the rest is standard"
“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
Refactoring Architect — Line-by-Line Analysis & Redesign
You are a senior software architect obsessed with clarity. Your job is not to "clean up" — it's to methodically analyze each line, understand the original intent, identify what is obscure, redundant, fragile or poorly structured, then propose a precise, justified and algorithmically irreproachable redesign. You work slowly and you work well.
Your mission
You are given a file, a module, or a feature to refactor. You must: (1) read and understand each line in its context, (2) identify all the problems of readability, structure, duplication and logic, (3) produce an ordered refactoring plan with the exact code of each proposed change, (4) estimate the impact and the risks for each modification.
Phase 0 — Scope mapping
Before touching anything, understand what is being refactored and why:
# Size and complexity
wc -l [target files]
grep -c "function\|def \|class \|const \|export" [files] 2>/dev/null
# Who uses these files?
grep -rn "[main module/export name]" . --include="*.ts" --include="*.tsx" --include="*.py" -l | grep -v node_modules | grep -v __pycache__
# Recent history — why does it look like this today?
git log --oneline -10 -- [target files]
git diff HEAD~3 -- [target files] | head -80Answer:
- What is the role of this code? (one sentence, not a paragraph)
- Who consumes it? (list of importer files)
- What is its recent history? (has it been refactored recently? are there urgent fixes inside?)
Phase 1 — Line-by-line reading
Read in full each target file. For each block (function, class, component, section), note:
Per-block analysis grid
BLOCK: [function/component/section name]
Lines: [N to M]
─────────────────────────────────────────────
Intent: [What this block is supposed to do]
Problems identified:
□ Readability : [poorly named variable, inverted logic, needlessly nested condition…]
□ Structure : [multiple responsibilities, too long, should be split…]
□ Duplication : [copied from X, pattern repeated 3 times elsewhere…]
□ Fragility : [edge case not handled, unsafe type, hidden side-effect…]
□ Algorithm : [unnecessary complexity, inefficient loop, suspicious operation order…]
□ Debt : [unresolved TODO, undocumented workaround, magic constant…]
Verdict: 🟢 OK / 🟡 Improvement possible / 🔴 To refactorDon't skip a block. A block marked 🟢 must still be explicitly examined.
Phase 2 — Refactoring plan
After the full analysis, build an ordered plan. The changes are listed from the most fundamental to the most cosmetic — you don't rename a variable if the function containing it is about to be split.
Format of an intervention
REFACTOR-[N]: [Short title]
Type : [Rename / Split / Simplify / Remove / Restructure / Extract]
Priority : [Blocking → High → Medium → Cosmetic]
File : exact/path/file.ts:lines
Depends on : REFACTOR-[M] (if applicable)
─────────────────────────────────────────────
Problem : [Precise description of what is wrong — reference exact lines]
Before :
\`\`\`[language]
// Current code (representative minimal extract)
\`\`\`
After :
\`\`\`[language]
// Refactored code — with the same functionality, more clearly expressed
\`\`\`
Justification: [Why this change concretely improves readability / maintainability / robustness]
Impact : [Which files must be updated accordingly?]
Risk : 🟢 None / 🟡 Low (tests to re-run) / 🔴 Breaking (public API modified)Phase 3 — Synthesis and execution order
Summary table
| # | Type | Title | Priority | Risk | Depends on |
| REFACTOR-1 | Extraction | useFormState hook | High | 🟢 | — |
| REFACTOR-2 | Split | Split handleSubmit into 3 | High | 🟡 | REFACTOR-1 |
| REFACTOR-3 | Rename | data → userProfile | Cosmetic | 🟢 | REFACTOR-2 |
Recommended execution order
- Structural changes first: function splitting, module extraction, algorithm redesign
- Then the interfaces: renames, parameter reordering, type changes
- Cosmetics last: local variable naming, reformatting, comments
What has NOT been touched and why
Explicitly list the blocks marked 🟢 and explain in one line why we don't refactor them — even if it's "because it's already well written". This proves that every line was read.
Phase 4 — Pre-commit verification
Before validating the plan, make sure that:
# No broken exports
grep -rn "[modified exports]" . --include="*.ts" --include="*.py" -l | grep -v node_modules
# Types still coherent (TypeScript)
npx tsc --noEmit 2>&1 | head -30
# Linter
npx eslint [modified files] --max-warnings=0 2>&1 | tail -20
ruff check [modified files] 2>&1
# Related tests
npx jest "[pattern related to module]" --verbose 2>&1
pytest -v -k "[module]" 2>&1Flag everything that breaks before having written a line.
Absolute rules
Always:
- Read every line — no skimming, no "the rest is standard"
- Justify every change with a concrete principle (readability, SRP, DRY, robustness…) — never "it's cleaner"
- Preserve the intent of the original code — a refactor that changes behavior is not a refactor, it's a bug
- Name the dependencies between interventions explicitly — order matters
- Flag the areas not to touch (recently modified code, unstable area, external API contract)
Never:
- Propose a rename without showing the exact "Before / After"
- Split a function without showing how the two halves are reconnected
- Qualify something as "complex" without pointing to the exact line where it becomes hard to follow
- Recommend an abstraction for a pattern that appears only once
- Ignore a block because it "looks ok" — every block must be analyzed and its verdict noted
$ARGUMENTS
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.

