Help us improve
Share bugs, ideas, or general feedback.
From optimus
Reviews local changes, PRs/MRs, or branch diffs against project coding guidelines using 5-7 parallel review agents (bug detection, security/logic, guideline compliance, code simplification, test coverage, contract quality). High-signal findings only.
npx claudepluginhub oprogramadorreal/optimus-claude --plugin optimusHow this skill is triggered — by the user, by Claude, or both
Slash command
/optimus:code-reviewThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Analyze local git changes (or a PR/MR) against the project's coding guidelines, using 5 to 7 parallel review agents for comprehensive coverage. High-signal findings only: bugs, logic errors, security issues, guideline violations. Excludes style concerns, subjective suggestions, and linter-catchable issues.
Performs multi-agent code review of current git branch against main: detects bugs via specialist agents, verifies findings, ranks severity, generates persistent report before push/merge.
Performs thorough pull request reviews with parallel agents for bugs, security issues, guideline compliance, and error handling. Provides confidence-scored feedback and batched GitHub comments.
Performs code reviews using Codex MCP with severity-grouped findings and a merge gate. Supports fast (diff-only), full (diff + lint/build), and branch review variants.
Share bugs, ideas, or general feedback.
Analyze local git changes (or a PR/MR) against the project's coding guidelines, using 5 to 7 parallel review agents for comprehensive coverage. High-signal findings only: bugs, logic errors, security issues, guideline violations. Excludes style concerns, subjective suggestions, and linter-catchable issues.
Extract from the user's arguments:
--branch flag (present/absent) — overrides Step 3's PR auto-route. Has no effect when local changes are present or when an explicit PR is requested (--pr N, #N, or a PR URL). Recorded as force-branch-diff for Step 3.Examples:
/optimus:code-review → local changes/optimus:code-review src/auth → scope to path/optimus:code-review --pr 42 or /optimus:code-review #42 → PR mode/optimus:code-review --branch → branch diff against the detected base, skip PR auto-route/optimus:code-review "focus on src/auth" → scopedFor iterative auto-fix in a loop, use /optimus:code-review-deep instead.
Read $CLAUDE_PLUGIN_ROOT/skills/init/references/multi-repo-detection.md for workspace detection. If a multi-repo workspace is detected:
.git/, so git commands must target individual repos)Read $CLAUDE_PLUGIN_ROOT/skills/init/references/prerequisite-check.md and apply the prerequisite check (CLAUDE.md + coding-guidelines.md existence, fallback logic).
If your invocation prompt body contains HARNESS_MODE_INLINE, you are running inside the /optimus:code-review-deep orchestrator as a single iteration. Read $CLAUDE_PLUGIN_ROOT/references/harness-mode.md and follow its single-iteration execution protocol. The reference covers progress file reading, state initialization, scope and file-list rules, agent-prompt overrides, and the apply/output protocol. Proceed through Steps 3, 4, 5, 6, and 7 — skip the Step 8 "Offer Actions" prompt (the orchestrator handles iteration approval upfront), apply the fixes mechanically, then emit the structured JSON via the harness-mode output protocol and stop. Do not use AskUserQuestion. Do not loop.
If HARNESS_MODE_INLINE is NOT present, continue with the standard interactive flow below.
Detect and gather the changes to review. Use the scope/focus instructions parsed in Step 1.
Run the following git commands to gather all local changes:
# Staged changes
git diff --cached --stat
git diff --cached
# Unstaged changes to tracked files
git diff --stat
git diff
# Untracked files
git status --short
$CLAUDE_PLUGIN_ROOT/skills/pr/references/platform-detection.md and use the Platform Detection Algorithm section to determine if the project is GitHub, GitLab, or unknown.gh pr view --json number,state,baseRefName 2>/dev/null — only use number and baseRefName if state equals "OPEN"; if state is not "OPEN", treat as "no open PR"glab mr view --output json 2>/dev/null — only use iid and target_branch if state equals "opened"; if state is not "opened", treat as "no open MR". If the command fails, treat as no open MR — unless the failure appears to be an auth or connectivity error, in which case inform the user before falling back$CLAUDE_PLUGIN_ROOT/skills/pr/references/default-branch-detection.md<base-branch> and capture the current branch as <current-branch> via git rev-parse --abbrev-ref HEAD. Run git log --oneline origin/<base-branch>..HEADorigin/<base-branch> as <ref>. For GitLab, substitute "MR !N" for "PR #N" in the user-facing notices below:
force-branch-diff is set (from Step 1) → review the branch diff.git rev-list origin/<current-branch>..HEAD exits 0 with no output) → auto-enter PR mode for that PR. Reuse the PR/MR identifier captured in sub-step 2 above — jump to the PR mode (explicit request) block below without re-prompting. Tell the user, in one line: "Reviewing PR #N — using the PR description as author intent context. Pass --branch to review the branch diff instead."git rev-list returns lines or exits non-zero) → review the branch diff. Tell the user, in one line: "Reviewing the branch diff — PR #N exists but HEAD is not fully pushed. Pass --pr N to review only the PR's pushed state."When the user says "review PR #42", passes --pr, #123, or a PR URL:
Platform detection — read $CLAUDE_PLUGIN_ROOT/skills/pr/references/platform-detection.md and use the Platform Detection Algorithm section (including the Signal Conflict Resolution rule). If platform is unknown → inform the user and ask them to specify.
GitHub projects:
gh is available by running gh --version. If not available, inform the user that PR review requires the GitHub CLI (gh) and offer to review the branch diff insteadgh pr view <N> --json state,isDraft,title,body,baseRefName,headRefName to get PR metadatatitle and body fields as pr-description for use in Steps 5 and 6 (author intent context)gh pr diff <N> to get the actual diffGitLab projects:
glab is available by running glab --version. If not available, inform the user: "This project uses GitLab. PR/MR review requires the GitLab CLI (glab). You can use branch diff mode instead: /optimus:code-review changes since origin/main." Offer to review the branch diff as a fallback.glab mr view <N> --output json to get MR metadatatitle and description fields as pr-description for use in Steps 5 and 6 (author intent context)glab mr diff <N> to get the actual diffWhen the user says "review changes since main" or a similar reference:
git diff <ref>...HEAD for the diffgit diff --name-only <ref>...HEAD for the file listWhen the user specifies a path (e.g., "review src/auth"):
git diff -- <path> and git diff --cached -- <path>Present a brief summary before proceeding:
## Review Scope
- Mode: Local changes / PR #N / Branch diff since <ref>
- Files changed: [N]
- Lines: +[added] / -[removed]
If PR/MR mode is active, inspect the captured pr-description body and append a note to the Scope summary based on what's there:
/optimus:pr in the implementation conversation to add intent metadata."## Intent heading → append: "Note: PR description has no ## Intent section. Intent-vs-implementation checks will be skipped. Re-running /optimus:pr in the implementation conversation can add intent metadata."## Intent heading → no note (the intent-vs-implementation check will run).## Intent detection heuristic (used by both bullets above; not output text): see $CLAUDE_PLUGIN_ROOT/skills/pr/references/pr-template.md "Detecting ## Intent in an existing PR body" for the canonical heuristic (shared with /optimus:pr).
This is a soft warning — review proceeds normally either way.
If more than 50 files or 3000 lines are changed, warn the user and suggest narrowing the scope (e.g., specific path or directory).
If a multi-repo workspace was detected in Step 1, resolve prerequisites per-repo:
.claude/CLAUDE.md and .claude/docs/ independently (not the workspace root)Read $CLAUDE_PLUGIN_ROOT/skills/init/references/constraint-doc-loading.md for the full document loading procedure (single project and monorepo layouts, scoping rules).
These files define the review criteria. Every guideline-related finding must be justified by what these docs establish — never impose external preferences.
Apply the "Submodule Exclusion" rule from $CLAUDE_PLUGIN_ROOT/skills/init/references/constraint-doc-loading.md — exclude submodule directories from the review.
Before proceeding to the review, present a brief summary:
Proceed immediately to Step 5 — do not wait for user confirmation.
Launch every applicable agent as a general-purpose Agent tool call in a single message so they run in parallel. The full fan-out is the design — do not reduce the count to save tokens or time. See the agent overview below for which agents always run and which activate conditionally.
Each agent receives the list of changed file paths (from Step 3 in normal/interactive mode, or from scope_files.current in harness mode when pre-populated by the harness).
Read the agent prompt files from $CLAUDE_PLUGIN_ROOT/skills/code-review/agents/ for individual agent prompts. Read $CLAUDE_PLUGIN_ROOT/skills/code-review/agents/shared-constraints.md for the shared quality bar, exclusion rules, and false positive guidance applying to all agents.
If a pr-description was captured in Step 3 and its body is non-empty, prepend the PR/MR context block to every agent prompt before the file list. Read $CLAUDE_PLUGIN_ROOT/skills/code-review/agents/context-blocks.md for the template, truncation rule, and guardrail language.
When running under HARNESS_MODE_INLINE and the progress file's iteration.current is greater than 1, prepend the iteration context block to every agent prompt before the file list (after the PR/MR context block, if present). Read $CLAUDE_PLUGIN_ROOT/skills/code-review/agents/context-blocks.md for the template and format.
| Agent | Role | Prompt file |
|---|---|---|
| 1 — Bug Detector | Null access, off-by-one, race conditions, resource leaks, type mismatches | bug-detector.md |
| 2 — Security & Logic | SQL injection, XSS, hardcoded secrets, missing auth, security-relevant API violations | security-reviewer.md |
| 3 — Guideline Compliance A | Explicit violations of project docs with exact rule citations | guideline-reviewer.md |
| 4 — Guideline Compliance B | Same task as Agent 3 — independent review reduces false negatives | guideline-reviewer.md |
| 5 — Code Simplifier | Unnecessary complexity, naming, dead code, pattern violations | code-simplifier.md |
| 6 — Test Guardian | Test coverage gaps, structural barriers to testability | test-guardian.md |
| 7 — Contracts Reviewer | Backward compatibility, type safety, contract versioning, encapsulation | contracts-reviewer.md |
Agents 1–5 always run. Agent 6 (Test Guardian) runs when test infrastructure is detected (.claude/docs/testing.md or subproject docs/testing.md exists). Agent 7 (Contracts Reviewer) runs when changed files include contract-related paths (see activation rules below). Each agent returns a structured list of findings, bounded by the Finding Cap rule in $CLAUDE_PLUGIN_ROOT/references/shared-agent-constraints.md. Guideline agents (3–4) are constructed dynamically based on Step 4's doc loading results (single project vs monorepo paths).
Agent 7 activates when any changed file from Step 3 matches at least one of these patterns:
Directory patterns — file path contains any of: api/, routes/, controllers/, endpoints/, handlers/, graphql/, proto/, grpc/
File patterns — file name matches any of: *.dto.*, *.schema.*, *.contract.*, openapi.*, swagger.*, *.proto, *.graphql, *.gql
If no changed file matches, skip Agent 7 entirely (zero cost).
Wait for all launched agents to complete before proceeding to Step 6.
Independently verify each finding to filter false positives. Apply the verification protocol from $CLAUDE_PLUGIN_ROOT/skills/init/references/verification-protocol.md — treat agent-reported findings as claims that require independent evidence, not as ground truth.
For each finding from Step 5:
For each unique file that has findings, check recent git history for deliberate changes:
git log --no-merges --format="%h %s" -5 -- <file>
If a recent commit message clearly indicates deliberate code introduction (e.g., "fix null check", "add input validation", "harden auth flow") and a finding suggests removing or reverting that code → reduce the finding's confidence by one level (High → Medium, Medium → Low → drop).
For uninformative commit messages (fewer than 15 characters, or generic like "fix", "update", "changes"), run git show <sha> -- <file> to examine the actual diff for intent patterns: added null checks, validation logic, error handling, or security measures. Apply the same confidence reduction if the diff shows deliberate defensive code that a finding wants to remove.
If a pr-description was captured in Step 3 (PR/MR mode), use it as an additional intent signal during validation:
This is a soft adjustment only — it never hard-filters a finding. It reduces the chance of undoing deliberate previous work while still allowing genuinely problematic code to be flagged. The PR/MR description and git history are complementary signals — neither alone can suppress a finding.
Skip gracefully if git log fails or returns no results (e.g., shallow clone, newly created file, or file outside the repository).
Assign confidence:
Only findings with High or Medium confidence proceed to Step 7.
Merge validated findings from Steps 5–6. Deduplicate: if two agents flagged the same file and line range for the same category, keep the more detailed version. For guideline findings flagged by both Agents 3 and 4, merge into one finding and note "confirmed by independent review".
After deduplication, check for cross-agent contradictions — findings that target the same code region but recommend opposite directions (e.g., "add more validation" vs. "simplify this validation"). Keep the higher-severity finding and drop the other. When severities are equal, keep the security/correctness finding — security requirements justify proportionate complexity.
Before presenting findings, write a concise summary (2–4 sentences) of what the reviewed changes accomplish. Describe the intent and effect of the changes — what was added, modified, or removed and why. Base this on the diff and the agents' analysis. This lets the user verify the review understood their changes correctly.
See agents/shared-constraints.md "Severity" for the canonical Intent Mismatch mapping.
Maximum 15 domain findings across all sources (Bug / Security / Guideline / Code Quality / Test Gap / Contract Quality), prioritized by severity then confidence. Intent Mismatch findings are surfaced on top of the 15-cap, up to 5 in the aggregated report — deduplicated across the emitting agents (each agent's per-pass +5 budget is registered canonically in $CLAUDE_PLUGIN_ROOT/references/shared-agent-constraints.md "Per-category budget exceptions"), sorted by severity, and presented after the domain findings. If more issues exist, note the count (e.g., "15 of ~24 findings shown") and suggest re-running with a narrower scope or using /optimus:code-review-deep for exhaustive review.
Present findings using the output format below, then proceed to Step 8.
## Code Review
### Summary
- Scope: [local changes / PR #N / branch diff since X]
- Files reviewed: [N]
- Lines changed: +[A] / -[R]
- Findings: [N] (Critical: [N], Warning: [N], Suggestion: [N])
- Docs used: [list of docs loaded]
- Agents: bug-detector, security-reviewer, guideline-A, guideline-B, code-simplifier[, test-guardian][, contracts-reviewer]
- Verdict: CHANGES LOOK GOOD / ISSUES FOUND
### Change Summary
[2–4 sentences describing what the changes do — their intent, what was added/modified/removed, and the overall effect. Keep it factual and concise.]
### Findings
**[N]. [Finding title]** (Critical/Warning/Suggestion — [Bug/Security/Guideline/Quality/Test Gap/Contract/Intent Mismatch])
- **File:** `file:line`
- **Category:** [Bug | Security | Guideline Violation | Code Quality | Test Coverage Gap | Contract Quality | Intent Mismatch]
- **Guideline:** [which project guideline, or "General: bug/security/contract quality" — for Intent Mismatch, the literal string "Intent (see Intent claim)"]
- **Intent claim:** [only for Intent Mismatch — the quoted claim from `## Intent`]
- **Issue:** [concrete description]
- **Current:**
[code snippet — max 5 lines]
- **Suggested:**
[fix or recommendation — max 5 lines]
[Findings ordered: Critical → Warning → Suggestion, each sorted by file path]
### No Issues Found
[If applicable: "The changes follow project guidelines. No bugs, security issues, or guideline violations detected."]
For PR mode, include full-SHA code links:
https://github.com/owner/repo/blob/[full-sha]/path#L[start]-L[end]git remote get-url origin (e.g., https://gitlab.company.com), then use: https://[gitlab-host]/owner/repo/-/blob/[full-sha]/path#L[start]-L[end]If the verdict is CHANGES LOOK GOOD (no findings), skip this step — do not present any action prompt. Go directly to the recommendation in the "Important" section below.
If the verdict is ISSUES FOUND, use AskUserQuestion to present actions. The options depend on the review mode determined in Step 3:
Use AskUserQuestion — header "Action", question "How would you like to proceed with the review findings?":
Use AskUserQuestion — header "Action", question "How would you like to proceed with the review findings?":
Write the review summary to a temp file in the current working directory: TMPFILE=$(mktemp ./review-summary-XXXXXX.md). Always clean up after the posting attempt (whether it succeeds or fails): rm -f "$TMPFILE". (Use a relative path, not /tmp — on Windows, Git Bash's /tmp mount is unresolvable by the native gh.exe/glab.exe, which would silently submit an empty comment.)
For GitHub PRs: gh pr comment <N> --body-file "$TMPFILE"
For GitLab MRs: glab api -X POST "projects/:id/merge_requests/<N>/notes" -F body=@"$TMPFILE" — this avoids shell metacharacter issues that glab mr note --message "$(cat ...)" would have with code snippets in the summary
git diff before committingAfter the review is complete, recommend the next step based on the outcome:
/optimus:commit to commit the fixes/optimus:pr to create a pull request (skip this if already reviewing a PR/MR)Tell the user:
$CLAUDE_PLUGIN_ROOT/references/skill-handoff.md "Closing tip wording" — if the "issues found and fixed" bullet fires, use Variant A with <continuation-skill(s)> = /optimus:commit. If the "no issues / fixes skipped" bullet fires, use Variant A with <continuation-skill(s)> = /optimus:pr./optimus:code-review-deep to iterate automatically — it fixes, tests, and repeats until clean (default 8 passes, hard cap 20). Requires a test command in .claude/CLAUDE.md.