Skip to content

code-refactor

Efficientworkflow

Improve existing code: measure → prioritize → transform → verify. Never break working behavior.

Use when improving existing code quality, reducing technical debt, eliminating coupling, splitting oversized modules, improving performance, or hardening security of existing code.

Triggers: “refactor this”, “reduce tech debt”, “clean up”, “improve code quality”, “split this module”, “too complex”

  • qual-refactoring-priority — ranks candidates by risk, impact, debt score
  • qual-code-analysis — static analysis to identify targets
  • gr-geodesic-refactor (gated) — optimal refactoring path
  • gr-escape-velocity-calculator (gated) — effort to escape debt well
  • test-verify — verify refactored code still passes all tests
  • code-review — review the refactoring for unintended consequences
  • physics-analysis — escalate to GR-based debt analysis
ScopePattern
Single-file refactorGPT-4.1 only (Zero-Cost)
Cross-module refactorGPT-4.1 draft → Claude Sonnet 4.6 boundary review
Batch refactor3× GPT-4.1 parallel → single Claude Sonnet 4.6 diff-review

Never use a free model as final reviewer for refactors touching gov-*, qm-*, gr-*, or security primitives.

{
"request": "The UserService class is 800 lines. Refactor it into cohesive modules."
}

Output: Refactoring plan, module boundary proposal, extracted code files, and a test compatibility check.