Refactor
Execute a structural method inside an authorised implement run. This skill
inherits exact paths, non-goals and repair limits; it cannot widen scope, accept
the change, release it or turn nearby cleanup into work.
Entry evidence
Before editing, record:
- the named cost/risk to remove and the observable behaviours that must not
change;
- public API, schema, protocol, data, ordering, error and performance invariants;
- a green baseline plus characterisation, differential, replay, property or
compatibility checks selected by risk;
- the dependency cone: callers, exports, registration/configuration, generated
artifacts, persistence and mixed-version boundaries;
- canonical ownership, duplicate/parallel paths, rollback seam and a
move/deletion manifest.
Use SOLID and related principles as probes, not success metrics: improve
cohesion and single ownership; preserve substitutability and caller contracts;
segregate interfaces only where clients carry unused coupling; invert volatile
dependencies only when the new seam hides real complexity. Prefer simple,
explicit state and information hiding over speculative abstraction, pattern
count, DRY-by-text or acronym compliance.
If the desired structure or behaviour is undecided, route to scope. If a
failure's cause is unknown, use diagnose. Changed behaviour is a separate TDD
slice, never hidden in the refactor.
Method
- Establish a seam while green. Do not start by deleting the old path.
- Move one independently reviewable responsibility at a time. Preserve the
public contract or use an approved compatibility adapter with an expiry.
- Switch callers/registrations to one canonical owner and verify after each
slice. Keep focused checks fast; run affected and full required gates at the
enclosing tranche.
- Delete only when caller, runtime, build, registry, reflection/dynamic-load,
configuration and data evidence show the path is unreachable or replaced.
Unknown, user-owned and unrelated files stay untouched.
- Stop on behaviour drift, unexplained performance/resource change, scope
expansion or an invariant the evidence cannot cover. Revert only exact
run-owned hunks under authority and return to
scope/diagnose as needed.
Completion gate
Provide before/after ownership and dependency deltas, the classified
move/deletion manifest, exact verification results and residual risk. Pass only
when observable/API/schema/data contracts remain equivalent, the named
structural debt is measurably reduced, no unowned parallel path remains,
relevant performance/resource budgets hold, documentation is current and an
independent code-review finds no blocking regression. Lines deleted alone are
never proof.
1---2name: refactor3description: Use for authorised, behaviour-preserving structural simplification backed by characterisation and equivalence evidence. Not for new behaviour, read-only review, or unknown root cause; use tdd, code-review, or diagnose.4---56# Refactor78Execute a structural method inside an authorised `implement` run. This skill9inherits exact paths, non-goals and repair limits; it cannot widen scope, accept10the change, release it or turn nearby cleanup into work.1112## Entry evidence1314Before editing, record:1516- the named cost/risk to remove and the observable behaviours that must not17 change;18- public API, schema, protocol, data, ordering, error and performance invariants;19- a green baseline plus characterisation, differential, replay, property or20 compatibility checks selected by risk;21- the dependency cone: callers, exports, registration/configuration, generated22 artifacts, persistence and mixed-version boundaries;23- canonical ownership, duplicate/parallel paths, rollback seam and a24 move/deletion manifest.2526Use SOLID and related principles as probes, not success metrics: improve27cohesion and single ownership; preserve substitutability and caller contracts;28segregate interfaces only where clients carry unused coupling; invert volatile29dependencies only when the new seam hides real complexity. Prefer simple,30explicit state and information hiding over speculative abstraction, pattern31count, DRY-by-text or acronym compliance.3233If the desired structure or behaviour is undecided, route to `scope`. If a34failure's cause is unknown, use `diagnose`. Changed behaviour is a separate TDD35slice, never hidden in the refactor.3637## Method38391. Establish a seam while green. Do not start by deleting the old path.402. Move one independently reviewable responsibility at a time. Preserve the41 public contract or use an approved compatibility adapter with an expiry.423. Switch callers/registrations to one canonical owner and verify after each43 slice. Keep focused checks fast; run affected and full required gates at the44 enclosing tranche.454. Delete only when caller, runtime, build, registry, reflection/dynamic-load,46 configuration and data evidence show the path is unreachable or replaced.47 Unknown, user-owned and unrelated files stay untouched.485. Stop on behaviour drift, unexplained performance/resource change, scope49 expansion or an invariant the evidence cannot cover. Revert only exact50 run-owned hunks under authority and return to `scope`/`diagnose` as needed.5152## Completion gate5354Provide before/after ownership and dependency deltas, the classified55move/deletion manifest, exact verification results and residual risk. Pass only56when observable/API/schema/data contracts remain equivalent, the named57structural debt is measurably reduced, no unowned parallel path remains,58relevant performance/resource budgets hold, documentation is current and an59independent `code-review` finds no blocking regression. Lines deleted alone are60never proof.