Use Case: Refactoring

Refactoring changes structure, never behavior. The running example here is the option parsing duplicated across the CLI commands — surfaced by an architecture review, consolidated under a plan, and verified to have changed nothing but the structure.

  1. 1

    Structure

    Review the Architecture

    The code base is reviewed for package cohesion and inter-package coupling, which reports the duplication as a persisted PROBLEM finding with an id, next to an architecture diagram.

    Claude Code
    /ase-arch-analyze --prefix cli src/
  2. 2

    Plan

    Choose the Refactoring Approach

    Refactoring follows its own tenets — behavior preservation, Boy Scout Rule, DRY, SRP — so alternative approaches with pros and cons are proposed, you pick one, and a persisted task plan is composed for it.

    Claude Code
    /ase-code-refactor getopt: consolidate the option parsing of all CLI commands into src/ase-getopt.ts (finding cli-P1)
  3. 3

    Realization

    Preflight, Then Implement

    The dry run shows every call site the consolidation touches; only then does the implementation run, isolated in its own Git worktree.

    Claude Code
    /ase-task-preflight getopt
    /ase-task-implement --worktree getopt
  4. 4

    Behavior Preservation

    Check the Diff Stays Pure

    The staged diff is retold as an intent-grouped narrative with a coherence check, which is where a behavior change smuggled into a refactoring shows up.

    Claude Code
    /ase-meta-diff --coherence --risk
  5. 5

    Quick Mode

    Or Refactor In One Shot

    For a rename-sized refactoring, the plan ceremony is skipped and the change applied in place; for anything in between, the fused editor refactors, grills, and verifies in a single call.

    Claude Code
    /ase-code-refactor --direct rename parseArgs to parseOptions in src/ase-getopt.ts
    /ase-code-edit --mode refactor --grill --verify --worktree extract the shared option table of the CLI commands into src/ase-getopt.ts
npm install -g @rse/ase && ase setup install