Iteratively refactors code by running subagents, applying automated fixes, and verifying results against tests.

Install

mkdir -p .claude/skills/refactor-deep && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/19432" && unzip -o skill.zip -d .claude/skills/refactor-deep && rm skill.zip

Installs to .claude/skills/refactor-deep

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Iterative refactoring of the feature-branch diff (full project when no diff exists) — runs `/optimus:refactor` in a fresh subagent context per iteration, applies fixes, runs tests, bisects failures, and continues until convergence or the iteration cap (default 8, hard cap 20). Supports `testability` or `guidelines` focus to prioritize finding categories. Fixes are applied automatically without per-change approval; for a single supervised pass, use /optimus:refactor. Creates a git checkpoint commit after each iteration (skip with --no-commit). Requires a test command in .claude/CLAUDE.md. Use for thorough guideline alignment or testability cleanup before /optimus:unit-test.
681 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Execute iterative refactoring in fresh subagent contexts
  • Apply code fixes and run test suites automatically
  • Bisect failures to isolate issues
  • Create git checkpoint commits per iteration
  • Support testability or guideline-focused refactoring

How it works

The orchestrator runs a loop of refactoring passes, spawning fresh subagents to apply changes and verify them against the project's test suite until convergence or iteration limits are reached.

Inputs & outputs

You give it
Focus keyword and optional path
You get back
Refactored codebase with cumulative progress report

When to use refactor-deep

  • Clean up feature branch code before merging
  • Improve testability of legacy modules
  • Enforce coding guidelines across a project
  • Automate repetitive code improvement tasks

About refactor-deep

Runs a series of refactoring iterations in fresh subagent contexts. It applies code changes, executes test suites, identifies failures, and continues until reaching a convergence point or iteration limit.

Iterative refactoring of the feature-branch diff (full project when no diff exists) — runs `/optimus:refactor` in a fresh subagent context per iteration, applies fixes, runs tests, bisects failures, and continues until convergence or the iteration cap (default 8, hard cap 20). Supports `testability`

When not to use it

  • Running deep mode inside another deep mode session
  • Projects lacking a documented test command

Prerequisites

optimus-claude plugin installationProject initialized with /optimus:initDocumented test command in .claude/CLAUDE.md

Limitations

  • Default iteration limit of 8, hard cap of 20
  • Requires uncommitted changes to be committed or skipped

How it compares

This approach automates multi-pass iterative cleanup and verification, whereas standard refactoring typically requires manual intervention per change.

Compared to similar skills

refactor-deep side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
refactor-deep (this skill)02moReviewAdvanced
migrate16moReviewIntermediate
tdd-workflows-tdd-refactor14moNo flagsIntermediate
tdd-migrate17moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry