Skip to content

donaldfilimon/abi / .agents/skills/refactor

refactor

Verified

Plan, execute, and validate a codebase modernization or refactor with clean-slate thinking while preserving semantics. Use when the user asks how to approach a rewrite vs incremental change or what the risk is (strategy), is ready to apply a refactor plan safely (implementation), or asks whether a refactor broke anything or is complete (validation).

references/strategy-guide.md

View on GitHub
# Refactor Strategy Guide

## Strategy Selection Matrix

| Situation                    | Recommended Strategy     | Rationale |
|-----------------------------|--------------------------|---------|
| Small isolated module, good tests | Direct clean rewrite    | Low risk, high payoff |
| Core domain with many dependents | Phased (Strangler Fig)  | Preserve behavior for consumers |
| Legacy with poor tests      | Analysis first + parallel implementation | Reduce risk |
| Performance critical path   | Measure → target design → incremental migration | Protect invariants |

## Clean Slate Questions

For any module ask:
1. What is the single responsibility in modern terms?
2. What are the ideal error and success paths?
3. Which current types/structures are historical accidents?
4. How would I test this if writing it fresh?
5. What modern language features remove the need for previous workarounds?

## Example Phased Plan Outline

1. **Discovery** (1-2 days)
   - Extract contracts
   - Identify modernization targets

2. **Parallel Modern Impl** (core module)
   - Write new version beside old
   - 100% parity test suite

3. **Strangler Introduction**
   - Route 5% traffic / calls
   - Monitor + expand

4. **Cutover + Deletion**
   - Remove old after confidence gates

See the main SKILL.md for the high-level process.
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall