bug-fix
Bug-fixing workflow that coordinates diagnosis, test-driven reproduction, root-cause analysis, and targeted fixes. Use when the user wants to fix a bug with…
Autonomous iterative refactoring workflow. Scans for tactical code quality improvements (DRY, dead code, naming, complexity), implements through SMEs, verifies with QA, commits atomically, and loops until no improvements remain.
$ npx -y skills add chrisallenlane/claude-swe-workflows --skill refactor --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/refactorContext preview
The summary Claude sees to decide when to auto-load this skill.
Autonomous iterative refactoring workflow. Scans for tactical code quality improvements (DRY, dead code, naming, complexity), implements through SMEs, verifies with QA, commits atomically, and loops until no improvements remain.
name: refactor description: Autonomous iterative refactoring workflow. Scans for tactical code quality improvements (DRY, dead code, naming, complexity), implements through SMEs, verifies with QA, commits atomically, and loops until no improvements remain. model: opus
Autonomous refactoring workflow that iteratively improves code quality within the existing architecture, always preferring the least aggressive change available, until no further opportunities exist.
**Clarity is the goal.** Every iteration should make the codebase easier to form a correct mental model of. Red diffs are the strongest signal - less code almost always means clearer code, and every iteration should delete more than it adds. But when reducing lines would hurt comprehensibility, clarity wins.
**Err on the side of trying.** When uncertain whether a refactoring is worthwhile, attempt it anyway. Git makes failed experiments free - the workflow will revert changes that don't pass QA. Missed opportunities are invisible; failed attempts teach you something. Be bold, knowing that version control provides the safety net.
**Work within the existing architecture.** This workflow improves code quality - DRY, dead code, naming, complexity - without questioning module boundaries or reorganizing the system. For architectural analysis (noun extraction, module dissolution, blueprint-driven restructuring), use `/review-arch` instead.
┌─────────────────────────────────────────────────────┐ │ REFACTORING LOOP │ ├─────────────────────────────────────────────────────┤ │ 1. Determine scope │ │ 2. Select aggression ceiling │ │ 3. Gather QA instructions │ │ 4. Spawn fresh swe-code-reviewer agent (full scan) │ │ 5. Select least aggressive changes available │ │ 6. If none remain → exit to summary │ │ 7. Spawn SME agent (implement batch) │ │ 8. Spawn QA agent (verify) │ │ ├─ PASS → commit, goto 4 │ │ └─ FAIL → retry (max 3), then abort batch │ │ 9. Completion summary │ │ 10. Update documentation (/tidy-docs) │ └─────────────────────────────────────────────────────┘
**Default:** Entire codebase.
**Boundary: version-controlled files only.** The refactoring workflow operates exclusively on files tracked by git. Untracked files and directories must never be modified or deleted — their loss could be irreversible. This boundary is non-negotiable regardless of scope setting.
**If user specifies scope:** Respect that scope (directory, files, module). Pass scope constraint to all spawned agents.
**Ask the user:** "How aggressive should refactoring be?"
Present these options:
The workflow still proceeds from least aggressive to more aggressive - this setting determines how far up the ladder to climb before stopping.
**Ask the user:** "Are there any special verification steps for the QA agent? For example: visual checks, manual testing commands, specific scenarios to validate."
**If provided:** Pass these instructions to the QA agent on every verification cycle, in addition to standard test suite execution.
**Examples of custom QA instructions:**
**If none provided:** QA agent runs standard verification (test suite, linters, formatters).
**Always make the least aggressive change available, up to the user's chosen ceiling (step 2).**
The `swe-code-reviewer` agent returns recommendations organized by risk level: **SAFEST → SAFE → MODERATE → AGGRESSIVE**. These aren't gates to pass through sequentially. Instead:
For each iteration:
**Spawn fresh `swe-code-reviewer` agent:**
**Why full scan every time:**
**Prompt the agent with:**
Scan for ALL refactoring opportunities across all aggression levels. Scope: [entire codebase | user-specified scope] Return recommendations organized by risk level (SAFEST → AGGRESSIVE). Prioritize changes that produce RED diffs (net code reduction) while improving clarity.
**Orchestrator selects least aggressive changes:**
A system of composable software engineering workflows for Claude Code. Plan projects, implement tickets, and run quality passes — from a single ticket to a multi-batch project, using the same layered architecture.
Repo: chrisallenlane/claude-swe-workflows
Bug-fixing workflow that coordinates diagnosis, test-driven reproduction, root-cause analysis, and targeted fixes. Use when the user wants to fix a bug with…
Proactive bug-hunting workflow. Assesses codebase risk through complexity, coverage, and structural analysis, then spawns focused investigators that write…
Multi-ticket batch workflow. Takes a batch of tickets, plans execution order, implements each via /implement in autonomous mode, runs cross-cutting quality…
Full-lifecycle project workflow. Takes batched tickets, implements via /implement-batch, runs smoke tests, then executes a comprehensive quality pipeline…
Iterative development workflow that coordinates implementation, refactoring, QA, and documentation agents to complete features systematically. Use when the…
Autonomous bug-elimination loop. Iteratively invokes /bug-hunt and /implement-batch until findings converge below an operator-specified severity floor. At…