Skill · Code & Agents
Refactor Planner
A refactor plan made of small steps that each keep the system working, with the behaviour contract and the first tests to write.
When to use
- Tangled or legacy code needs restructuring and you fear regressions.
- You are about to let a coding agent loose on a module and want a safe, reviewable order.
- A change you need (a new region, a new provider) is blocked by the current structure.
When not to use
- You need a bug fixed. Find the cause first with the Root-Cause Debugger; fixing and restructuring in one go hides what changed.
- The code is a small function with good tests. Refactor it directly.
Example
User: Our 300-line calculate_invoice() in Python mixes discounts, tax and currency. I need to add a new tax region. There are no tests.
Result (excerpt):
Behaviour contract
- B1: no discount → subtotal + tax at the region's rate
- B2: percentage coupon applied before tax
- B3: unknown region raises ValueError
- B4: rounding to cents happens once, at the end
Tests to write first
| test | input | expected | covers |
| no_discount_de | 100.00, DE | 119.00 | B1 |
| coupon_before_tax | 100.00, 10% coupon, DE | 107.10 | B2 |
Steps
- Extract function: tax lookup into tax_rate(region) · ~20 lines · keeps B1–B4 · commit "extract tax_rate"
- Replace conditional with a table: regions become a dict · ~30 lines · commit "region rate table"
Stop when
- Adding the new region touches the table and one test, nothing else.
Behaviour changes to decide later
- Coupons above 100% produce a negative total (B2 path); confirm with finance before changing.
Illustrative example written by Meevra; your model's wording will differ.
What is inside
The full skill has these sections. The ones marked “in the pack” come with the download.
- When to use on this page
- When not to use on this page
- Inputs to ask for in the pack
- Workflow in the pack
- Output format in the pack
- Example on this page
- Model notes (Oct 2026) in the pack
- Troubleshooting in the pack
Get Refactor Planner
The full skill is a SKILL.md folder you install once and reuse: the workflow, the checklist and the answer format written out, with notes for each model. It comes in the Code & Agents pack (5 prompts · 15 skills · 1 free), with a QUICKSTART, setup notes in every item and 12 months of updates.
All-Access 39 € vs 7 packs × 12 € = 84 € · less than buying 4 or more packs one by one
Stuck? Email support@meevra.com — we'll help you set it up.