Skip to content

Latest commit

 

History

History
95 lines (64 loc) · 3.52 KB

File metadata and controls

95 lines (64 loc) · 3.52 KB
diataxis_type how-to
diataxis_goal Run targeted refactoring with --focus to constrain analysis to specific disciplines

How to Run Focused Refactoring

Overview

The --focus flag constrains a refactoring run to specific disciplines, spawning only the agents needed for that analysis. This reduces overhead and speeds up targeted reviews.

Prerequisites

Focus areas

Value Agents spawned Scores produced
security refactor-test, refactor-code, code-reviewer Security Posture
architecture refactor-test, refactor-code, architect Clean Code, Architecture
simplification refactor-test, refactor-code, simplifier Simplification
code refactor-test, refactor-code, architect, code-reviewer Clean Code, Architecture, Security Posture
discovery refactor-test, refactor-code, code-explorer (Discovery only — codebase map)
(none) all 6 Clean Code, Architecture, Security Posture

The refactor-test and refactor-code agents always spawn regardless of focus. They provide the safety net (tests must pass) and fix capability (resolve failures).

Steps

1. Run a security-only refactor

/refactor --focus=security src/auth/

Only the code-reviewer agent analyzes your code (quality + security). The run defaults to 1 iteration. The final report includes a Security Posture Score.

2. Run an architecture-only refactor

/refactor --focus=architecture src/api/

The architect agent reviews structure and the refactor-code agent implements the top 3 optimizations. Produces Clean Code and Architecture scores.

3. Run a simplification-only pass

/refactor --focus=simplification src/utils/

The simplifier agent operates directly on the scope (no architect plan). Focuses on naming clarity, control flow, redundancy, and style. Produces a Simplification Score.

4. Run a code-only refactor

/refactor --focus=code src/models/

Equivalent to --focus=architecture — the architect provides the optimization plan, the code agent implements it. No security review or simplification pass.

5. Combine focus areas

/refactor --focus=security,architecture src/

Multiple values are comma-separated. The agent set is the union of each focus area's agents. This example spawns: refactor-test, refactor-code, architect, and code-reviewer (4 of 6 agents).

6. Override iteration count in focused mode

Focused runs default to 1 iteration. Override with --iterations:

/refactor --focus=security --iterations=3 src/auth/

7. When to use each focus mode

Scenario Recommended focus
Security audit before release --focus=security
Design review for architecture discussion --focus=architecture
Quick cleanup of messy code --focus=simplification
Full refactor with code improvements --focus=code or no flag
Pre-merge security + architecture check --focus=security,architecture

Related