Produce a refactor plan before touching code
Recipe template · not yet tested on this site
This page is a recipe template, not yet tested here. Run logs, tokens and time go in after re-testing; until then no estimated numbers are filled in.
When to use
A piece of code needs refactoring but you fear a direct edit will ripple; you want a reviewable plan first.
Preparation
- Host version
- To fill (record the exact rc version when testing)
- Model
- To fill
- Mode / permissions
- Standard mode + modify-within-workspace is enough to start
- Plugins required
- None (add name & version after testing if used)
- Input materials
- Keep in a separate workspace; back up originals first
Full instruction
For [target file / module], produce a refactor plan. Do NOT modify any code.
The plan includes:
1. Current problems: what is awkward and why it is hard to maintain (file:line).
2. Target structure: what it looks like after, with key call relationships.
3. Step-by-step: what each step does, which files it touches, how it preserves behavior.
4. Risk and rollback: which step is riskiest and how to revert.
5. Acceptance: how to prove success without regressions.
Requirements: each step must be independently committable and revertible; no big-bang rewrite.Run log
| Item | Value | Note |
|---|---|---|
| Time spent | to be tested | |
| Result | to be tested | |
| In / out tokens | to be tested | |
| Leftovers | to be tested |
Output
After a successful run, list files and screenshots here, and note whether originals changed.
Acceptance checklist
Tap to tick each item off as you verify.
- Plan changed no code
- Each step is independently committable and revertible
- The riskiest step is flagged
- Actionable acceptance criteria given
Failures & boundaries
- A plan is not approval to execute; human review needed
- Pilot large modules in small scope first
- This is a recipe template and has not been tested on this site
- Blocked on: Same as code-review: needs a real repo with real debt. A refactor plan for synthetic code always reads correctly because that code has no traps.