Skip to content

/wbClean — Exhaustive Simulation () ​

/wbClean is the janitor. Its job is surface-level mess removal: dead imports, unused vars, trailing whitespace, stray console.log, orphaned files. Compared to /wbRefactor (structural surgery) it operates one level shallower — it doesn't change shape, it removes what's clearly debris.

Read this if you want to know what counts as "clearly debris" (vs "potentially load-bearing"), why /wbClean has no flags, and where cleanup ends and refactor begins.


1. Role & target ​

AspectBehavior
RoleThe Janitor — remove debris without changing structure or behavior.
TargetA file, a comma-separated set, or a directory (which /wbRefactor refuses but /wbClean accepts at scale).
Cell scopeNone.
Side effects allowedRemoving unused imports/vars; removing console.log/debugger; trimming trailing whitespace; removing orphaned files (with confirmation).
Side effects forbiddenChanging function signatures; renaming exports; reorganizing files; touching test files (cleanup of tests is its own concern).

The "no signature changes" rule is the contract with /wbRefactor: if cleanup would change a function's signature, it's not cleanup, it's refactor. The two commands stay in their lanes; they're chained, not merged.

/wbClean differs from /wbRefactor in one key respect: it accepts directory targets because cleanup scales naturally across files (every file gets the same checks). Refactor does not, because structural changes are file-specific.


2. Argument resolution matrix ​

FormExampleWhat /wbClean does
Single fileCommand: /wbClean src/WBC.jsPass over one file. Most precise.
Comma-separatedCommand: /wbClean src/WBC.js,src/renderString.jsBoth files; report per-file.
DirectoryCommand: /wbClean core2/packages/wb-core/src/Walks the directory; reports per-file.
GlobCommand: /wbClean "core2/packages/*/src/**/*.js"Cross-package cleanup. Larger; may produce many small no-op files in the report.
Free-textCommand: /wbClean "the auth code"Refused. Cleanup is path-required.

3. Flag matrix ​

/wbClean has no flags. Every cleanup pass does the same set of checks; there's no profile to filter, no severity to pick. The flag-free design says: cleanup is simple, predictable, and safe by default.

What /wbClean checks for ​

A fixed checklist applied to every file:

CategoryWhat gets removed
Dead importsImports with no reference in the file.
Dead varsconst/let declarations with no read after declaration.
Console statementsconsole.log, console.debug, console.warn not part of intentional logging (heuristic: line has comment "intentional log" → keep).
Debugger statementsdebugger; always removed.
Trailing whitespacePer-line.
Orphan trailing newlinesMultiple blank lines collapse to single.
Orphan files.bak, .orig, .tmp, .old, .swp extensions removed (with confirmation).

What /wbClean does not touch:

  • Code in comments (might be intentional reference).
  • Type-only imports in .ts files (type checker may need them).
  • Test files (cleanup of tests is /wbWork against a test-improvement row).
  • Files inside node_modules, dist*, .git.

4. Pipelines (the agent-native scenarios) ​

📋/wbClean Exhaustive Simulation
The "after refactor" cleanup/wbClean core2/packages/wb-core/src/tierEnforcement.js
> /wbClean core2/packages/wb-core/src/tierEnforcement.js
[SYSTEM] Target: tierEnforcement.js
[SCAN] Reading file (post-refactor: 78 lines, was 87)...
[FINDINGS]
- line 4: import { legacyVerify } from './deprecated.js' — unused.
- line 31: const _debug = false — never read.
- line 47: console.log('tier check entered', tier) — no "intentional"
marker; treating as debug debris.
- 12 lines have trailing whitespace.
[CONFIRM] Apply 4 cleanups? [y/N] > y
[EDIT] tierEnforcement.js cleaned.
Removed: 1 unused import, 1 unused var, 1 console.log,
12 trailing-whitespace fixes.
[TEST] All tests pass.
[OK] Cleanup complete. File now 75 lines.
⚠️ Note: Right after `/wbRefactor` completes, the touched files often have small debris (a now-unused import, a logging statement that was useful during the refactor). `/wbClean` is the natural next step:

💠 Pipeline The "after refactor" cleanup ​

Right after /wbRefactor completes, the touched files often have small debris (a now-unused import, a logging statement that was useful during the refactor). /wbClean is the natural next step:

💠 Pipeline The directory pass ​

A weekly/monthly cleanup ritual across a package:

💠 Pipeline The "orphan file" prompt ​


5. Edge cases & refusals ​

TriggerWhat /wbClean does
No targetHalt. ❌ Provide a file, comma-separated list, or directory.
Free-text targetHalt. ❌ Cleanup is path-required.
Empty fileCleanup is a no-op; reports "nothing to clean."
File where every "cleanup" would change behaviorRefuse the change. Cleanup is behavior-preserving by definition.
Console statement with "intentional" commentKept.
Type-only import in .ts fileKept. The type checker may need it.
Tests fail post-cleanupAuto-revert. Surface which check caused the regression for next pass.
Target in dist* or node_modulesSkip silently.
Test files in targetSkip with one-line notice. Cleanup of tests is its own work.
--profile, --scope, or any flag attemptedHalt. /wbClean has no flags.

The pattern: /wbClean is debris removal — small, safe, predictable, behavior-preserving. Fixed checklist, no flags, accepts directories, refuses free-text. It pairs with /wbRefactor (cleanup before refactor for a clean diff; cleanup after refactor to remove debris). Where the boundary blurs (does this change a signature? does it touch a test?), /wbClean defers — staying narrow is the discipline that makes the command trustworthy.