/silver:refactor

Specialized structural refactoring workflow — plan the change, execute without behavior drift, verify parity, then run the full review, verify, secure, and ship gate sequence.

Overview

/silver:refactor is the Silver Bullet orchestrator for structural code changes that preserve behavior — module extraction, dependency inversion, naming cleanup, dead-code removal, and architecture realignment without new features. It maps to catalog entity WF-SILVER-REFACTOR (specialized type) in the v0.48.3 APO catalog.

Refactor skips upfront clarify/specify atoms because behavior is frozen — the risk is in blast radius of structural moves, not requirements ambiguity. After execution, it runs the same post-execution gate sequence as feature work.

Standard composition:

AF-PLAN → AF-EXECUTE → AF-VERIFY → AF-REVIEW-REQUEST → AF-REVIEW → AF-REVIEW-TRIAGE → AF-VERIFY → AF-SECURE → AF-VALIDATE → AF-QUALITY-GATE → AF-BRANCH-FINISH → AF-COMPLETION-AUDIT → AF-SHIP

The post-execution sequence is the catalog's review, verify, secure, and ship gates — expanded as atomic flows above, not a separate user-facing workflow name. See Post-Execution Sequencing.

Behavior must not change. If the request adds features, changes APIs, or alters user-visible behavior, route to /silver:feature instead. Refactor assumes existing tests are the parity contract.

When to Use

Entry trigger signals for /silver:refactor and refactor:

  • Module extraction, package reorganization, or layer boundary cleanup
  • Rename sweeps, dead-code removal, or dependency graph simplification
  • Pattern migration (callbacks → async/await, class → functional) with parity tests
  • Technical debt paydown that touches multiple files but adds no features

Catalog Composition

PhaseAtomic flowsOutcome
Pre-executionAF-PLANAF-EXECUTEAF-VERIFYRefactor plan, structural changes, parity verification
Review gatesAF-REVIEW-REQUESTAF-REVIEWAF-REVIEW-TRIAGEArtifact review, triage, and fix loop
Ship gatesAF-VERIFYAF-SECUREAF-VALIDATEAF-QUALITY-GATEAF-BRANCH-FINISHAF-COMPLETION-AUDITAF-SHIPFinal verification, security, quality gate, branch hygiene, ship

Post-Execution Gates

After AF-EXECUTE completes, the refactor workflow expands into the canonical post-execution gate chain shared with /silver:feature and /silver:bugfix:

  • Review gatesAF-REVIEW-REQUEST, AF-REVIEW, AF-REVIEW-TRIAGE for structural change review
  • Verify gateAF-VERIFY confirms full test suite and no behavior regression
  • Secure gateAF-SECURE for security-sensitive structural moves (auth paths, crypto, input handling)
  • Ship gatesAF-VALIDATE, pre-ship AF-QUALITY-GATE, AF-BRANCH-FINISH, AF-COMPLETION-AUDIT, AF-SHIP

AF-UI-QUALITY inserts only when runtime evidence shows UI deliverables in scope.

Example Invocation

/silver:refactor Extract the billing module from monolith core into packages/billing with no API changes

Silver Bullet routes to WF-SILVER-REFACTOR. Planning documents module boundaries and migration steps. Execution moves code with import updates. Initial verify confirms test parity. Review gates examine structural diff. Ship gates pass and the refactor merges.