rewrite-vs-refactor
/rewrite-vs-refactor
Decide whether to refactor code in place or rewrite it from scratch using risk math, not frustration. Use when a component feels beyond repair and someone proposes starting over.
- Author
- Amey-Thakur ↗
- Repository
- AI-SKILLS ↗
- Licence
- MIT
- Last repository change
- 05.09.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Decide whether to refactor code in place or rewrite it from scratch using risk math, not frustration. Use when a component feels beyond repair and someone proposes starting over.
Original author description
Decide whether to refactor code in place or rewrite it from scratch using risk math, not frustration. Use when a component feels beyond repair and someone proposes starting over.
How it works
- Method
- Litmus tests
- Boundaries
SKILL.md preview
--- name: rewrite-vs-refactor description: Decide whether to refactor code in place or rewrite it from scratch using risk math, not frustration. Use when a component feels beyond repair and someone proposes starting over. --- # Rewrite vs refactor The urge to rewrite is usually the code punishing you for not understanding it yet. A rewrite trades a known, working system for an unknown one, and the old system keeps shipping features while the replacement plays catch-up. Choose with numbers, not with disgust. ## Method 1. **Start from refactor and make rewrite earn the switch.** In-place refactoring keeps the system green and shippable at every step. Reach for a rewrite only when the constraint is structural: a data model that cannot represent the new requirement, a framework two majors past support, or a runtime you can no longer hire engineers for. 2. **Do the risk math on paper.** Estimate rewrite effort, then multiply by 3 for the requirements buried in the old code that nobody wrote down. Add the freeze cost: the months the old system stagnates while the team builds its replacement. Compare that against refactor effort plus the interest of living with the mess. If rewrite does not win by 2x, refactor. 3. **Inventory the hidden behavior before you commit.** Grep the old code for special cases: `if` branches on customer names, date cutoffs, retry counts, and workaround comments. Each is an undocumented requirement a rewrite must re-derive from scratch. A module dense with these is costly to refactor and lethal to rewrite blind. 4. **If rewriting, migrate with a strangler fig.** Put the new code behind the old interface, route one endpoint or one entity type through it at a time, and delete the old path only after the new one carries production traffic. Never run a big-bang rewrite in a long-lived branch: it drifts from the shipping system and the merge never lands. 5. **Dual-run to prove equivalence.** Send real traffic to both paths, compare outputs, and log every divergence (the GitHub Scientist pattern makes this cheap). Cut over only after divergences shrink to explainable rounding. 6. **Write kill criteria before the first commit.** Decide up front what result reverts the effort: "if migrating module one takes over 6 weeks, we stop and refactor instead." A rewrite with no abort condition becomes a sunk-cost march that no one can call off. ## Litmus tests - Can you name the exact structural constraint refactoring cannot fix? If not, you want a rewrite for how the code feels, and feelings are cheaper to fix. - Does the plan keep the old system shipping features the whole way through? - Is there a defined checkpoint where you would cut losses and stop? ## Boundaries This weighs one component's fate, not architecture strategy. When the question is how services split or which boundaries to draw, defer to system design. When the code is small enough that a rewrite fits in a day and a single review, skip the math and just do it.
Versions
The database has no other skills named rewrite-vs-refactor.
Database snapshot: 13.11.2026 · package version ea0032a16459 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 3 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 91nightgauge-refactor-rewrite
Refactor vs rewrite decision analysis engine. Evaluates brownfield codebases across 8 dimensions to produce data-driven recommendations with confidence levels, risk/benefit matrices, and hybrid approach suggestions. Use when deciding whether to refactor or rewrite a legacy… - 95refactor
[UDS] Guide refactoring decisions and strategy selection, including the refactor-versus-rewrite call. Use when: code has become hard to change, choosing between tactical and architectural refactoring, working safely inside legacy code. Not for: moving to a different framework or… - 95refactor
[UDS] 引導重構決策與策略選擇,包含「重構還是重寫」這個判斷。 Use when: 程式碼已經難以修改、在戰術性與架構性重構之間做選擇、要在老舊程式碼裡安全地動手。 Not for: 換到不同框架或主版本——請用 /migrate;清除除錯殘留與死碼——請用 /sweep。 Keywords: refactor, rewrite, strangler, legacy code, technical debt, code smell, 重構, 重寫, 技術債, 壞味道. - 90clean-room-rewrite
Decide whether a legacy codebase should be rewritten or refactored, and when a rewrite wins, rebuild it clean-room — distill the old system into an executable behavior spec, have a builder that never reads the old source implement it, audit parity against the old code with… - 86refactoring
Use when the user asks to refactor code. - 91refactor-rewrite
Refactor vs rewrite decision analysis engine. Evaluates brownfield codebases across 8 dimensions to produce data-driven recommendations with confidence levels, risk/benefit matrices, and hybrid approach suggestions. Use when deciding whether to refactor or rewrite a legacy…