implement-refactor
Installation
SKILL.md
Implement-refactor
Execute exactly one resumable unit of a Clean Architecture refactor plan. Output is real, behaviour-preserving production code plus an implementation report. The plan lives under .plans/clean/<run>/ (Feature-Driven flavour, FDD) or .plans/clean-bob/<run>/ (Uncle-Bob layer-first flavour), where <run> is the timestamped run directory minted by the audit skill. The skill leaves the working tree on a clean atomic commit per unit and never amends. This skill is self-contained — it reads the audit-plan files directly and does not invoke any other skill.
Inputs and outputs
- Source plan:
.plans/clean/<run>/<feature>/progress.md(Feature-Driven flavour) or.plans/clean-bob/<run>/<layer>/progress.md(Uncle-Bob layer-first flavour). Each unchecked- [ ]is a candidate unit.<run>is the most recent run directory under the chosen<root>(timestamped, e.g.2026-05-12T1432Z). - Code output: edits to project source — moves, extractions, dependency inversions; never new product behaviour.
- Report output:
.plans/<root>/<run>/<feature_or_layer>/implementations/<NNN>.mdwhere<root>iscleanorclean-bob,<run>is the chosen run directory, and<NNN>is a zero-padded serial picked at write time (001.md,002.md, …). - State updates:
STATE.md,progress.md, repo-levelCONTEXT.md(also read during the loop for vocabulary lookup), and.plans/<root>/<run>/adr/NNNN-*.mdwhen a load-bearing decision is reached. ADRs are run-scoped;CONTEXT.mdis repo-level.
Core rules
- Behaviour preservation is the contract. Refactors must not change observable behaviour. If existing tests don't cover the touched code, write characterization tests first (capture current behaviour, including bugs), commit them separately, then refactor.
- One resumable unit per invocation. Stop after a single unit; ask the user to re-invoke for the next one. Do not chain.
- Honour the audit's vocabulary. Use the slice / layer / port / gateway / adapter / entity terms defined in the source plan and
CONTEXT.md. Do not invent synonyms ("service," "module," "boundary"). - Honour ADRs.
.plans/<root>/<run>/adr/NNNN-*.mdis load-bearing. If a unit contradicts an existing ADR, hard-stop and surface the conflict — let the user reopen it before proceeding. - Atomic commits. One commit per unit, scoped to files that satisfy that unit (plus the state files updated in this loop). Never
git add -A. Never amend or--no-verifywithout explicit user authorization (see What NOT to do). - No new behaviour. This skill does not add features, fix bugs, or change public APIs. If a unit cannot be completed without a behaviour change, hard-stop and tell the user to handle that work through their normal feature-implementation flow — not this refactor loop.