refactoring-strategy
Skill1 starsChanged 3 months agoMITView on GitHub
Systematic refactoring methodology with safety guarantees for polyglot codebases. TRIGGER when: user asks to refactor code, restructure a module, split a monolith, do a large rename, extract a service, apply strangler fig, or plan a safe migration of existing code. Also when tech-debt-tracker findings need execution. DO NOT TRIGGER when: user is fixing a bug (use focused-fix), doing TDD on new code (use tdd), or finding tech debt without a plan to fix it (use tech-debt-tracker).
1 other project uses a version of this.
Adopted by
Most recently taken up by
- HanKyeon/han-kyeon_claude-skillstheir own version, first seen Jul 1, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- HanKyeon/han-kyeon_claude-skills★ 2same name
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 repository61 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- adversarial-reviewerSkill
- agent-designerSkill
- architectSkill
- autoresearchSkill
- blockscoutSkill
- ci-cd-pipeline-builderSkill
- claude-apiSkill
- codebase-onboardingSkill
- code-reviewSkill
- coingeckoSkill
- database-designerSkill
- dependency-auditorSkill
- design-uxSkill
- digestSkill
- droo-stackSkill
- env-secrets-managerSkill
- ethskillsSkill
- ffmpeg-asmSkill
- focused-fixSkill
- frontend-slop-auditSkill
- git-guardrailsSkill
- git-worktree-managerSkill
- humanizerSkill
- interface-designerSkill
- llm-cost-optimizerSkill
- local-browser-inspectorSkill
- mcp-server-builderSkill
- native-codeSkill
- nixSkill
- noirSkill
- observability-designerSkill
- patchbotSkill
- performance-profilerSkill
- playwrightSkill
- polymathSkill
- prd-to-planSkill
- prepperSkill
- property-testingSkill
- qaSkill
- rag-architectSkill
- raxol-paymentsSkill
- raxolSkill
- raxol-symphonySkill
- recallSkill
- regenSkill
- releaseSkill
- security-auditorSkill
- self-improving-agentSkill
- sentinelSkill
- signozSkill
- skill-creatorSkill
- solidity-auditorSkill
- tddSkill
- tech-debt-trackerSkill
- ubiquitous-languageSkill
- watchdogSkill
- web-asset-generatorSkill
- writing-voiceSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 9 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
Characterization tests BEFORE any edit: If you cannot test it, you cannot safely change it.
- Distinctive: line 36
Never both. This makes every commit individually revertable.
- Distinctive: line 37
Run the full suite after every commit: Not just the tests you think are related.
- Distinctive: line 46
Map the blast radius: Use Explore agents to find all callers, importers, and consumers of the code you plan to change.
- Very specific: line 55
Write tests that pin the current behavior.
- Distinctive: line 74
Run the full test suite
- Distinctive: line 75
If GREEN, commit with a descriptive message
- Distinctive: line 76
If RED, diagnose: is it a test that depended on structure (update the test) or did you accidentally change behavior (revert and try a …
- Distinctive: line 81
Run the full test suite one final time
- Distinctive: line 82
Remove characterization tests that are now redundant (covered by proper tests)
- Distinctive: line 83
Update documentation, imports, and cross-references
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
You are a Principal Refactoring Engineer -- you never touch code without characterization tests, you never mix behavior changes with structural changes, and you treat every commit as independently revertable.
refactoring-strategy
Systematic refactoring with safety guarantees. From single-module cleanup to monolith decomposition.
What You Get
- Characterization test plan pinning current behavior before any changes
- Phased refactoring plan with individually revertable commits
- Impact analysis identifying downstream consumers and blast radius
- Rollback strategy for each phase
The Iron Rules
- Characterization tests BEFORE any edit. If you cannot test it, you
cannot safely change it. See
characterization-tests.md. - Never mix behavior changes with structural changes. Each commit is either a refactor (same behavior, new structure) or a feature (new behavior). Never both. This makes every commit individually revertable.
- Run the full suite after every commit. Not just the tests you think are related. Refactoring reveals hidden coupling.
Workflow
Phase 1: Scope and Impact Analysis
Before touching code:
- Map the blast radius. Use Explore agents to find all callers, importers, and consumers of the code you plan to change.
- Identify the abstraction boundary. Is the current boundary wrong (need to redraw it) or is the implementation behind the boundary messy (can refactor without changing the interface)?
- Decide: refactor or rewrite? See the decision tree below.
Phase 2: Characterization Tests
Write tests that pin the current behavior. These are NOT aspirational tests for
the new design -- they document what the code does NOW, warts and all. See
characterization-tests.md for patterns.
Phase 3: Plan the Refactoring
Choose a pattern from patterns.md (extract, inline, move, rename) or
large-scale.md (strangler fig, branch by abstraction, expand/contract).
Break the work into commits where each commit:
- Changes structure OR behavior, never both
- Leaves the test suite GREEN
- Can be reverted independently without breaking other commits
Phase 4: Execute
For each planned commit:
- Make the structural change
- Run the full test suite
- If GREEN, commit with a descriptive message
- If RED, diagnose: is it a test that depended on structure (update the test) or did you accidentally change behavior (revert and try a smaller step)?
Phase 5: Verify and Clean Up
- Run the full test suite one final time
- Remove characterization tests that are now redundant (covered by proper tests)
- Update documentation, imports, and cross-references
- Review the diff as a whole -- does the new structure match the original intent?
Refactor vs Rewrite Decision Tree
Is the public interface (API, function signatures, module boundary) correct?
|
Yes --> Refactor the internals. Keep the interface, improve the implementation.
No --> Is the interface used by fewer than 5 callers?
|
Yes --> Rewrite with a new interface. Migrate callers one by one.
No --> Use Strangler Fig pattern. Build new interface alongside old,
migrate callers incrementally, remove old when empty.Default to refactoring. Rewrites feel productive but lose encoded behavior that tests don't cover. Only rewrite when the abstraction boundary itself is wrong.
Common Pitfalls
| Mistake | Fix |
| Refactoring without characterization tests | Stop. Write tests first. Always. |
| Mixing behavior + structure in one commit | Separate into two commits. No exceptions. |
| Refactoring code you don't understand | Read it first. Trace the data flow. Map callers. |
| "While I'm here" scope creep | Finish the planned refactoring. File a follow-up for new ideas. |
| Large PRs that can't be reviewed | Break into a chain of small PRs, each independently mergeable |
| Rewriting when refactoring would work | Use the decision tree. Rewrites lose implicit behavior. |
Reading guide
| Topic | File |
| Characterization test patterns | characterization-tests.md |
| Refactoring patterns (extract, inline, move, rename) | patterns.md |
| Large-scale strategies (strangler fig, expand/contract) | large-scale.md |
See also
tech-debt-tracker-- finds what to refactor; this skill says howfocused-fix-- reactive bug fixing; this skill is proactive improvementtdd-- TDD workflow; its refactoring sub-file covers post-TDD smell cleanup within a modulearchitect-- architecture analysis; pair with this skill when the refactoring changes module boundaries
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.

