refactoring
Refactoring Methodology
Systematic approach to auditing and improving code. Every change is evidence-based: count callers, show diffs, commit surgically.
Related Skills: See
post-implementation-reviewfor the full second-read ritual after implementation. Seerethinkwhen the refactor changes public shape, ownership, naming, or lifecycle boundaries. Seecontrol-flowfor linearizing conditionals and guard clauses. Seefactory-function-compositionfor the four-zone factory anatomy. Seemethod-shorthand-jsdocfor when to usethis.method()vs direct calls. Seecode-prosefor the naming and comment pass over whatever the refactor leaves behind.
Use asymmetric-wins when a refactor is preserving a small promise that owns a large code family: legacy aliases, fallback parsers, exact old fixtures, pixel-perfect UI reproduction, duplicate call shapes, or a rare mode with its own tests and docs. Refactors do not need to preserve every old promise. They need to preserve the product sentence and the load-bearing contracts.
The Audit: Count Callers First
Before changing anything, map every internal function with its exact call count.