Help us improve
Share bugs, ideas, or general feedback.
From optimus
Iterative auto-fix code review loop that runs review-fix-test cycles in isolated subagents until convergence or iteration cap. Use for thorough cleanup before release.
npx claudepluginhub oprogramadorreal/optimus-claude --plugin optimusHow this skill is triggered — by the user, by Claude, or both
Slash command
/optimus:code-review-deepThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Orchestrate `/optimus:code-review` in an iterative auto-fix loop. Each iteration runs in a fresh subagent context, so the loop is not bounded by single-conversation context decay. All state lives in `.claude/code-review-deep-progress.json`. The orchestrator skill itself stays slim — it dispatches subagents, parses their structured output, and uses the `harness_common.cli` helper to apply fixes,...
Iterative code review loop that runs /deep-review multiple times, applying safe fixes inline, routing large decidable fixes to /big-plan for implementation, and deferring human decisions to GitHub issues. Use for autonomous review-fix cycles before finalizing code.
Iteratively reviews code for critical issues with code-reviewer, auto-fixes via fixer agent, verifies tests pass, repeats up to 5 cycles until clean.
Orchestrates multi-pass automated code review: simplifies code first, runs review iterations dispatching subagents to triage and fix issues per finding, commits changes. For PR branch prep and thorough quality reviews.
Share bugs, ideas, or general feedback.
Orchestrate /optimus:code-review in an iterative auto-fix loop. Each iteration runs in a fresh subagent context, so the loop is not bounded by single-conversation context decay. All state lives in .claude/code-review-deep-progress.json. The orchestrator skill itself stays slim — it dispatches subagents, parses their structured output, and uses the harness_common.cli helper to apply fixes, run tests, bisect failures, and decide termination.
If your invocation prompt body already contains HARNESS_MODE_INLINE, stop immediately with: "Deep mode cannot run inside deep mode." This prevents a misbehaving subagent from spawning a recursive deep run.
Extract from the user's arguments:
--resume flag (present/absent)--no-commit flag (present/absent)--yes flag (present/absent) — auto-confirm the Step 3 prompt; required when invoked under claude -p or any other non-interactive session that cannot answer AskUserQuestion.--max-iterations N (optional, default 8, hard cap 20)--allow-red-baseline flag (present/absent) — proceed even if the Step 4 pre-loop baseline finds the suite already failing"focus on src/auth") is recorded as intent only — it does not filter the diff, so the full branch diff is still reviewed.Examples:
/optimus:code-review-deep → 8 iterations on the branch diff/optimus:code-review-deep --max-iterations 12 → 12 iterations/optimus:code-review-deep src/auth → scope the review to an existing path/optimus:code-review-deep --resume → continue from existing progress file/optimus:code-review-deep --no-commit → skip per-iteration checkpoint commitsclaude -p "/optimus:code-review-deep --yes 'src/auth'" → headless / CI usage; skips the Step 3 confirmation promptResolve plugin_root (the absolute path to the installed plugin) and keep it for every CLI call and subagent dispatch below — the env var does not persist across separate Bash tool calls and reads empty on some platforms (notably Windows):
echo $CLAUDE_PLUGIN_ROOT via Bash. If it is non-empty and <value>/scripts/harness_common exists (test -d), use it./skills/... segment (this skill's own directory) — and use it if <derived>/scripts/harness_common exists.scripts/harness_common, stop: "Cannot resolve plugin root — ensure optimus-claude is installed via the Claude Code plugin system."Wherever the steps below (and orchestrator-loop-*.md) write $CLAUDE_PLUGIN_ROOT, use this resolved plugin_root; if echo $CLAUDE_PLUGIN_ROOT was empty, substitute the absolute path literally.
Read $CLAUDE_PLUGIN_ROOT/skills/init/references/prerequisite-check.md and apply the prerequisite check. If .claude/CLAUDE.md is missing, stop: "Deep mode requires /optimus:init to set up project context first."
Read .claude/CLAUDE.md and capture the documented test command verbatim — store the exact string (e.g. npm test, pytest) as test_command. If none is documented, stop and recommend /optimus:init to set one up first. You pass this captured command to init in Step 4 via --test-command; init can also parse .claude/CLAUDE.md itself, but its parser is stricter than a human read, so passing the command you just read avoids a spurious "No test command found" failure on a command the CLI can't parse.
Run git status --porcelain via Bash. On a fresh (non---resume) run, refuse to proceed if the working tree has uncommitted changes (except when --no-commit is passed) — uncommitted state would be ambiguous with the orchestrator's own per-iteration commits.
On --resume, the existing progress file's _snapshot.pre_head is the recovery anchor; uncommitted state is preserved.
Skip this step entirely when --resume is given, or when --yes is given (headless / CI: the caller has pre-approved the run).
Warn the user with:
Deep mode runs up to [N] iterative review-fix passes. Each iteration spawns a fresh subagent — credit and time consumption multiplies with iteration count. Fixes are applied automatically at each iteration without per-change approval. Low test coverage increases the chance of undetected breakage; consider running
/optimus:unit-testfirst to strengthen the safety net. Press Esc twice to interrupt — state is saved per-iteration; resume with/optimus:code-review-deep --resume.Test command:
[test command]Mid-iteration interrupts may leave the working tree inconsistent; clean iterations are fully recoverable via
--resume.
Use AskUserQuestion — header "Deep code review", question "Proceed with deep code review?":
If the user selects Cancel, stop.
--resumePYTHONPATH="$CLAUDE_PLUGIN_ROOT/scripts" python -m harness_common.cli resume \
--progress-file ".claude/code-review-deep-progress.json" \
[--max-iterations N] \
--project-dir "."
If exit code is non-zero, surface the error and stop. Pass --max-iterations N through when the user supplied a higher cap on --resume — resume raises the persisted iteration cap (and clears a prior diminishing-returns stop) so the loop continues past the previous limit.
PYTHONPATH="$CLAUDE_PLUGIN_ROOT/scripts" python -m harness_common.cli init \
--skill code-review \
--max-iterations [N] \
--test-command "<test_command>" \
[--scope "<scope>"] \
[--no-commit] \
--progress-file ".claude/code-review-deep-progress.json" \
--project-dir "."
Pass --no-commit through to init when the user supplied it — the mode is persisted in the progress file, so --resume keeps it without re-passing the flag (and commit-checkpoint self-skips regardless).
If exit code is non-zero, surface the error and stop. Likely errors:
--resume to continue the prior run, or re-invoke this skill with --force to discard the prior progress and start fresh..claude/CLAUDE.md does not document a test command. Recommend /optimus:init.If the user explicitly wants to discard a prior run, pass --force to cli.py init (no separate user-visible orchestrator flag is needed — the CLI's --force is sufficient).
Skip on --resume — the baseline already ran and the calibrated timeout is persisted. On a fresh run, after init succeeds, verify the suite is green before the loop:
PYTHONPATH="$CLAUDE_PLUGIN_ROOT/scripts" python -m harness_common.cli baseline \
--progress-file ".claude/code-review-deep-progress.json" \
[--allow-red]
baseline runs the test command once and calibrates the per-iteration timeout from how long it takes (so a slow suite, re-run repeatedly during bisection, doesn't spuriously time out). It prints baseline-green (continue) or, on a failing suite, baseline-red with a non-zero exit. On baseline-red, stop and show the user the failing tests — a red starting tree makes bisection blame the iteration's fixes and revert good work. Pass --allow-red only when the user supplied --allow-red-baseline (proceed without a green safety net; the timeout is left at its default).
Read $CLAUDE_PLUGIN_ROOT/references/orchestrator-loop-single.md and follow its 8-step per-iteration body, with these parameters:
<base-skill> = code-review<progress-path> = .claude/code-review-deep-progress.json<max> = the iteration cap from Step 1Brief, single-line status updates per iteration are appropriate (e.g., "Iteration 3/8: dispatching subagent…" then "Iteration 3/8: applied 5 fixes, 2 reverted, tests pass."). Do not narrate the subagent's findings in conversation prose — the report at Step 6 covers them.
PYTHONPATH="$CLAUDE_PLUGIN_ROOT/scripts" python -m harness_common.cli final-report \
--progress-file ".claude/code-review-deep-progress.json" \
--archive
This prints the cumulative report (fixed / reverted / persistent counts, per-finding table, termination reason, git rollback guidance) and moves the progress file to .done.json so a stray --resume cannot pick up a completed run. Exception: on a diminishing-returns soft-exit the CLI leaves the active progress file in place (prints not-archived) so the run stays resumable via --resume, matching that termination's "re-run to continue" guidance.
The orchestrator skill applies fixes automatically across all iterations; user approval is recorded once at Step 3 and stands for the whole loop. The base skill's harness-mode protocol is the source of truth for which fixes get applied.
Recommend the user run /optimus:commit next, followed by /optimus:pr once the branch is ready. Tell the user: Tip: stay in this conversation when running /optimus:commit and /optimus:pr so the implementation context is captured. Other downstream skills (/optimus:code-review, /optimus:unit-test) should still run in fresh conversations.
--resume continues a run whose progress file is still on disk — after an interrupt, or after a diminishing-returns soft-exit (the CLI leaves that run un-archived). /optimus:code-review-deep --resume --max-iterations <new-cap> raises the cap and continues in the same branch.
A run that finished cleanly (convergence / cap) was archived to .done.json, so --resume no longer finds it (init would report no progress file). For a fresh second-opinion pass after that — e.g. after pulling new changes — just re-run /optimus:code-review-deep (optionally --max-iterations <cap>); it starts a new run and, on a clean tree, converges on the first iteration.