Skip to content
Development
Skill

/code-review

Reviews local changes, an open PR/MR, or a branch diff for bugs, security issues, and violations of the project's own coding guidelines, through review lenses applied inline on a small diff or in parallel agents on a larger one. Excludes style and linter-catchable issues.

From plugin
optimus
7519 skills2 agents1 hook

Claude Code

$ npx -y skills add oprogramadorreal/optimus-claude --skill code-review --agent claude-code

SKILL.md

code-review.SKILL.md
description: >-
  Reviews local changes, an open PR/MR, or a branch diff for bugs, security issues, and
  violations of the project's own coding guidelines, through review lenses applied inline on a
  small diff or in parallel agents on a larger one. Excludes style and linter-catchable issues.
  Read-only: applies fixes or posts PR/MR comments only on explicit approval. For an iterative
  auto-fix loop, use /optimus:deep review.
disable-model-invocation: true
argument-hint: "[--pr N | --branch | path]"

Code Review

Analyze local git changes (or a PR/MR) against the project's coding guidelines through the review lenses in Step 5 — inline on a small diff, in parallel agents on a larger one. Out of scope: style concerns, subjective preferences, and anything a linter already catches.

Step 1: Parse Arguments and Verify Prerequisites

  • `--branch` → force the branch diff in Step 3, skipping the PR auto-route. No effect when local changes exist or an explicit PR is requested (`--pr N`, `#N`, or a PR URL).
  • Everything else is natural-language scope/focus: paths, PR numbers, refs (e.g., "review src/auth", "review PR #42", "changes since main").

**Multi-repo**: if `git rev-parse --is-inside-work-tree` does not return `true`, read `$CLAUDE_PLUGIN_ROOT/skills/init/references/multi-repo-detection.md` and apply it. When it returns `true`, resolve the repository root with `git rev-parse --show-toplevel`, including in a linked worktree or subdirectory. In a workspace, run Step 3's git commands inside each child repo and require the user to name a repo for PR/MR mode; if changed files map to no child repo, ask which repo's context applies.

**Prerequisites**: if `.claude/CLAUDE.md` or `.claude/docs/coding-guidelines.md` is missing, recommend `/optimus:init` first. On the user's choice to continue, fall back to the bundled baseline: read `$CLAUDE_PLUGIN_ROOT/skills/init/templates/docs/coding-guidelines.md` and review against it plus general best practices for the detected stack — a shared, versioned anchor keeps findings reproducible where ad-hoc judgment would not. Note in the report that findings are generic, not project-specific.

Step 2: Inline Harness Mode Detection

If your invocation prompt body contains `HARNESS_MODE_INLINE`, you are running inside the `/optimus:deep` orchestrator as a single iteration. Read `$CLAUDE_PLUGIN_ROOT/references/harness-mode.md` and follow it — that reference governs which of the steps below run, how scope and agent prompts are overridden, and how this run ends.

Step 3: Determine Review Scope

**Local changes (default)**: gather staged + unstaged + untracked via `git diff --cached`, `git diff`, and `git status --short`. If local changes exist, review them.

**No local changes → auto-route** (no user prompt):

1. Detect the platform per the **Platform Detection Algorithm** in `$CLAUDE_PLUGIN_ROOT/skills/pr/references/platform-detection.md`. 2. Check for an open PR/MR on the current branch: GitHub `gh pr view --json number,state,baseRefName` (use only when `state` is `"OPEN"`); GitLab `glab mr view --output json` (use `iid`/`target_branch` only when `state` is `"opened"`; a failed command means no MR — unless it looks like an auth or connectivity error, in which case tell the user before falling back). Platform unknown: try both, use the first confirmed open PR/MR. 3. Base = the PR/MR target branch; with no open PR/MR or no CLI, detect the default branch per `$CLAUDE_PLUGIN_ROOT/skills/pr/references/default-branch-detection.md`. If detection fails, ask the user for a base ref — never guess; if they have none, report there is nothing to review. 4. Run `git log --oneline origin/<base>..HEAD`; if commits exist, route (branch diffs use Branch/ref mode with `<ref>` = `origin/<base>`; for GitLab say "MR !N" instead of "PR #N"):

  • `--branch` set → branch diff.
  • Open PR/MR found AND HEAD fully pushed (`git rev-list origin/<current-branch>..HEAD` exits 0 with no output) → enter PR mode for that PR 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."*
  • Open PR/MR found BUT HEAD has unpushed commits or pushed state cannot be determined → 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."*
  • No open PR/MR (or CLI unavailable) → branch diff.

**Nothing at all** → inform the user there are no changes to review; suggest staging changes or specifying a PR.

PR mode

Entered on explicit request or via the auto-route. Detect the platform per the **Platform Detection Algorithm** (including **Signal Conflict Resolution**) in `$CLAUDE_PLUGIN_ROOT/skills/pr/references/platform-detection.md`; if unknown, ask the user.

| | GitHub | GitLab | |---|---|---| | Metadata | `gh pr view <N> --json state,isDraft,title,body,baseRefName,headRefName,headRefOid` | `glab mr view <N> --output json` | | `pr-description` fields | `title` + `body` | `title` + `description` | | Diff | `gh pr diff <N>` | `glab mr diff <N>` | | Head SHA field | `headRefOid` | `sha` | | Checkout | `gh pr checkout <N>` | `glab mr checkout <N>` |

  • Verify the CLI first (`gh --version` / `glab --version`); if unavailable → tell the user PR/MR review requires it and offer the branch diff instead.
  • Store the metadata's title + body as `pr-description` for Steps 5–6 (author intent context).
  • PR/MR closed or merged → warn and stop.
  • **Head mismatch**: if the head SHA differs from `git rev-parse HEAD`, offer the checkout command before continuing — Step 5's agents and Step 6's validation read the local working tree, so a mismatched checkout silently reviews the wrong file content. If declined, proceed with a warning that finding validation and line context come from the local tree, not the PR head.

**Branch/ref mode**: `git diff <ref>...HEAD` for the diff; `git d

Read more
@oprogramadorreal
Ships withoptimus

Primes your project for peak Claude Code performance

7519 skills2 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
75
Star history of oprogramadorreal/optimus-claude on GitHub, a chart by star-history.com

Other skills on optimus.

brainstorm

brainstorm

Runs a structured design conversation — clarifies intent, proposes 2-3 approaches with trade-offs, iterates the design — and…

commit

commit

Stages, commits, and optionally pushes local changes with a Conventional Commits message — always previews and confirms first,…

deep

deep

Runs an iterative auto-fix loop on a chosen target — review, refactor, or coverage — dispatching the base skill into fresh…

dream

dream

Prunes and consolidates the project's auto-memory to keep it minimal — deletes stale, wrong, or redundant memories, merges…

gauntlet

gauntlet

Runs a Gauntlet Loop: turns an ambitious goal into a builder/critic prompt judged against a concrete quality bar, confirms with…

handoff

handoff

Compacts the current conversation into one self-contained, tool-agnostic handoff document at docs/handoffs/<slug>.md so any fresh…

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills11d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc12d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react2d252k
@facebook@facebookInstall Skill

Questions about code-review.

Which coding agents can use code-review?
code-review installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.