command

refactor

Arguments: $ARGUMENTS --- Apply targeted refactors to specific files or components following loaded skills and CLAUDE.md rules. This is the write counterpart to `/analyze` (read-only).

$ curl -fsSL https://skills.reveni.dev/install.sh | bash

Arguments: $ARGUMENTS


Purpose

Apply targeted refactors to specific files or components following loaded skills and CLAUDE.md rules. This is the write counterpart to /analyze (read-only).


Silent Execution


Argument Parsing

Valid flags: --file <path>, --finding <id>, --dry-run.

Any flag not in this list is invalid. If an unknown flag is found:


Flow

1. Determine scope

Show: Scope: N files — [file list]

2. Load rules

Same process as /analyze step 3:

a) Load all available skills and Read each SKILL.md file completely.

b) CLAUDE.md is already in context — use it as the highest priority rule source.

c) Rule precedence: CLAUDE.md > skills.

Show: Rules: CLAUDE.md + [skill names]

3. Read current state

Read each file in scope completely. Understand the full context before making changes — imports, exports, dependencies, component structure.

4. Plan changes

For each file, identify all applicable rule violations and plan the fix. Group related changes together.

Change categories (apply in this order):

  1. Structure — Extract components, split files, move logic to hooks
  2. Patterns — Fix anti-patterns (ternary rendering → early returns, derived state, missing cleanup, etc.)
  3. Cleanup — Remove dead code, commented code, console.log, unused imports

Rules for planning:

Show plan:

Plan for src/components/OrderPage/OrderPage.jsx:
  1. [Structure] Extract fetch logic to hooks/useOrders.js (business-logic-in-view)
  2. [Pattern] Replace ternary rendering with early returns (no-ternary-rendering)
  3. [Cleanup] Remove 2 console.log calls (console-remnants)

5. Apply changes

Execute the plan file by file. For each file:

After each file:

6. Generate report

If --dry-run:

====================================
   REFACTOR — DRY RUN
====================================

src/components/OrderPage/OrderPage.jsx:
  1. [Structure] Would extract fetch logic to hooks/useOrders.js
  2. [Pattern] Would replace ternary rendering with early returns (lines 45-62)
  3. [Cleanup] Would remove console.log (lines 12, 38)

src/hooks/useFoo.js:
  1. [Cleanup] Would remove commented-out code (lines 22-28)

No files were modified.
====================================

If not dry-run:

====================================
   REFACTOR — COMPLETE
====================================

Files modified:
  ✓ src/components/OrderPage/OrderPage.jsx — 3 changes
  ✓ src/hooks/useFoo.js — 1 change

Files created:
  + src/components/OrderPage/hooks/useOrders.js

Changes: 4 applied across 2 files (1 new file)
Rules applied: business-logic-in-view, no-ternary-rendering, console-remnants, dead-code

⚠ Run `/preflight` before committing to verify linter and tests pass.
====================================

Safety Rules