Skip to content

/wbRefactor — Command Hub ​

/wbRefactor is the WB-Labs structural surgeon. It analyzes code structure and executes targeted improvements — extracting functions, splitting files, removing dead code, modernizing syntax — while preserving external behavior exactly. Unlike /wbDebug which fixes broken code, /wbRefactor improves working code without changing what it does.

🎯 Strategic Position ​

/wbRefactor exists because the default failure mode of cleanup is "while I'm here" scope creep. The command enforces a strict contract: public signatures, error behavior, observable side effects, and performance characteristics are preserved; only internal structure changes. It should only run when an audit has flagged structural debt, tests exist and pass, and no debug reports are open on the target.

  • After an audit flags structural debt — the audit-refactor-test-audit bracketing sequence.
  • One file at a time — entire package refactors in one go are dangerous. Split into file-level operations.
  • In the polish phase — not during feature work, not in response to a bug.

🛠️ Operating Modes ​

ModeTriggerOutput
Refactor/wbRefactor <file-or-folder>Structural transformation with a before/after comparison report
Self-correct/wbRefactor <previous_output_file>Verifies and repairs a prior refactor report in place

✅ What a useful refactor report contains ​

  1. A before/after comparison — what structural changes were made, with file references.
  2. An explicit statement that the external API remains identical — props, emits, error behavior preserved.
  3. A list of what was preserved — public signatures, error behavior, side effects, performance.
  4. A list of what was changed — internal structure, naming, dead code, formatting.
  5. The verification command — typically /wbTest <target> to confirm tests still pass.

🚫 What it cannot do ​

Not thisUse instead
Fix broken code or investigate bugs/wbDebug
Add new featuresDescribe the feature directly
Clean dead code without behavior context/wbClean
Rename a function used across the monorepo/wbPlan — coordinate the blast radius
Convert Vuetify components to wbc-ui2/wbToWBC

📚 Reading Order ​

  1. ELI5 — the one-paragraph mental model.
  2. Practical — step-by-step on a real project.
  3. Expert — architecture, edge cases, and when NOT to use.
  4. Examples — annotated transcripts from actual sessions.
  5. Exhaustive simulation · Live demo.
  • wbRefactor.md — the command reference this hub orients you around.
  • /wbAudit — the mandatory before-and-after gate for any refactor.
  • /wbDebug — fix bugs; do not refactor buggy code.
  • /wbToWBC — specialized Vuetify-to-wbc-ui2 migration.
  • /wbTest — confirm behavior parity after refactor.
  • /wbNext — ranked next action after refactor.

Quick Reference ​

bash
/wbRefactor <file-or-folder>                # restructure, preserve behavior


← Home · Commands · Install | wb-flow on npm · flow.wbc-ui.com · wi-bg.com