AGENT SKILL

review

Orchestrates comprehensive PR review combining analysis, code review, security, documentation, and risk-gated quality-review passes, posted as one unified GitHub comment. Use when asked to review a pull request, run a full review on a PR, or right after opening a PR that should be reviewed before merge — including when that instruction arrives as part of a larger task such as "open a PR and review it".

License 许可
MIT
最近更新
2026-11-14
Stars
★ 1
Forks
0

01 前言 Front Matter

name
review
description
Orchestrates comprehensive PR review combining analysis, code review, security, documentation, and risk-gated quality-review passes, posted as one unified GitHub comment. Use when asked to review a pull request, run a full review on a PR, or right after opening a PR that should be reviewed before merge — including when that instruction arrives as part of a larger task such as "open a PR and review it".
allowed-tools
Bash Read Write Skill Task Agent
disable-model-invocation
false

02 资源文件 1

03 SKILL.md 正文

Orchestrate Full PR Review

Master orchestrator. Runs comprehensive PR review by coordinating specialized skills. Produces single unified review comment with all findings and recommendations.

Overview

Workflow:

Phase 1: Foundation

  1. Capture the PR diff once, for every pass; analyze changes (languages, frameworks, impact, risk_class)
  2. Deep code review (2-pass bug hunting — expanded concurrency) in parallel with risk-gated QR passes

Phase 2: Quality Checks (parallel) 3. Security scanning (OWASP deepen) 4. Documentation validation (incl. light DX fold)

Phase 3: Synthesis 5. Combine all findings (bug-finder + QR passes + security + docs) 6. Determine merge recommendation (Clean Code blockers count as critical/high) 7. Post comprehensive review to PR

Usage

# Invoke with PR URL
> /review:review https://github.com/org/repo/pull/123

# The skill will automatically:
# - Analyze the PR
# - Run applicable reviews
# - Post results to PR

Step 1: Validate Environment

1.1 Check gh CLI

gh --version && gh auth status

If not authenticated:

Error: GitHub CLI not authenticated
Run: gh auth login
Or for enterprise: gh auth login --hostname <host>

1.2 Extract PR Number and Create Session Directory

PR_NUMBER=$(echo "$PR_URL" | grep -oE 'pull/[0-9]+' | grep -oE '[0-9]+')
SESSION_ID=$(uuidgen | tr '[:upper:]' '[:lower:]' | cut -d'-' -f1)
OUTPUT_DIR="/tmp/pr-review-${PR_NUMBER}-${SESSION_ID}"
mkdir -p "$OUTPUT_DIR" && chmod 700 "$OUTPUT_DIR"
echo "Session output directory: $OUTPUT_DIR" >&2

If PR URL not found, ask user for it.

1.3 Locate this plugin's scripts

Steps 7.5 and 8 run bundled scripts. A bare relative path resolves against the reviewed repo's working directory, not this plugin — the same trap called out in Step 3.1 — so resolve the root once, here.

PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-}"
if [ ! -f "$PLUGIN_ROOT/scripts/review_formatter.py" ]; then
  PLUGIN_ROOT="$(cd "${CLAUDE_SKILL_DIR:-.}/../.." 2>/dev/null && pwd)"
fi
[ -f "$PLUGIN_ROOT/scripts/review_formatter.py" ] \
  || echo "WARN: plugin scripts not found; Glob for review_formatter.py" >&2

If both variables are unset, Glob for **/scripts/review_formatter.py and use that file's parent-of-parent.

1.4 Capture the PR once

gh pr diff "$PR_URL" > "$OUTPUT_DIR/pr.diff"
gh pr diff "$PR_URL" --name-only > "$OUTPUT_DIR/pr.files"
gh pr view "$PR_URL" --json number,title,url,body,baseRefName,headRefName,headRefOid,author,state,additions,deletions,files,commits \
  > "$OUTPUT_DIR/pr-view.json"

Every pass reads these three files and fetches nothing itself. They are the pass's inputs, read-only: passes run in parallel in one $OUTPUT_DIR, so a pass that rewrote pr.diff would change the diff under every other pass mid-read. A pass run standalone, with no pr.diff in its directory, fetches its own.

If gh pr diff fails, stop — there is nothing to review.

Step 2: Run Change Analysis (Foundation)

Use Skill tool:
- skill: "review:analyze"
- args: "<PR_URL> <OUTPUT_DIR>"

Wait for completion and read analysis:

Read tool: $OUTPUT_DIR/pr-analysis-<PR_NUMBER>.json

Store key findings:

  • primary_language
  • security_sensitive
  • impact_analysis
  • risk_class (array)

If analysis fails: continue with limited info; note in final review.

Step 3: Deep Code Review + Risk-Gated QR Passes (parallel Tasks)

3.1 Two-pass bug-finder (always)

Spawn 2 independent bug-finders in parallel with Task tool. Different models per pass — one model twice shares one set of blind spots, so a finding both models agree on is far stronger signal:

Pass model Model ID Role
1 opus claude-opus-4-8 Deepest reasoning — subtle logic, races, security data-flow
2 sonnet claude-sonnet-5 Strong, different family — diversifies findings

Each:

  • subagent_type: general-purpose
  • model: from table. Do not omit — an omitted model inherits the session model, collapsing both passes onto one.
  • description: Bug hunter pass [1 opus / 2 sonnet]
  • prompt: Bug-Finder Prompt below, with the contents of $OUTPUT_DIR/pr.diff as {{DIFF}} and the contents of references/anti-patterns.md as {{ANTI_PATTERNS}}.

Read references/anti-patterns.md yourself and paste it in. These are raw Task prompts, not skill invocations — the subagents run with the reviewed repo as their working directory and cannot resolve a path in this skill.

Fresh eyes

A pass's prompt is its template with the placeholders filled — nothing else. Every pass reviews the diff cold: what another pass found, and what you suspect, stays out of the prompt. The QR, security and docs passes read the analysis JSON themselves; the bug-finders see only the diff. Two passes primed with the same hunch report the same hunch, and the "[Found by 2/2 models]" agreement in Step 5 stops meaning two independent reads.

Bug-Finder Prompt (both passes)

You are a bug hunter. Find bugs that will crash production or create security vulnerabilities. Trace, don't scan.

## Anti-patterns
{{ANTI_PATTERNS}}

## Critical Checks
- **NPE / null-deref:** for every dereference, trace the variable's lifecycle (declared? assigned? set null in cleanup/error paths? nulled by another thread?). Show the full trace for each risk.
- **Resource leaks:** every opened resource (connection, stream, file, cursor) — is it closed on all paths, including exceptions?
- **Security:** trace every external input to dangerous sinks (SQL, HTML, shell, file paths, logs) without sanitization. Also flag hardcoded secrets, sensitive data in logs, missing auth checks.
- **Race conditions:** shared mutable state without synchronization; check-then-act gaps.
- **Concurrency (expanded):** deadlocks / lock ordering; TOCTOU (filesystem/authz); async cancellation / lost wakeups / unstructured concurrency; concurrent idempotency (handler unsafe under parallel retries; missing unique constraints); poison messages / missing DLQ isolation.
- **Control flow:** missing returns after cleanup/error handling, early exits that skip cleanup, unreachable code.
- **Architectural:** inconsistent patterns (mixing two APIs for one purpose), wrappers/utilities removed without justification.
- **Clean Code (blocking):** silent catch / swallowed errors, shared mutable globals, or craft issues that hit correctness/invariants — emit as critical/high, not nits, **regardless of module reach**. Blast radius sets critical-vs-high, not blocking-vs-not. Name the resolving refactoring (Fowler/Kerievsky) in `suggestion`. Style-only with no domain-language conflict → omit or nitpick.

## Output
Return a JSON array of findings, each: {"severity":"critical|high|medium","label":"issue|suggestion|nitpick|question|thought|praise","decoration":"blocking|non-blocking|if-minor","path":"exact/path","line":N,"title":"5-10 words","body":"explanation with lifecycle/data-flow trace","suggestion":"concrete fix","suggested_change":"exact replacement for lines start_line..line"}.
- `severity`: `critical` (crashes/security), `high` (fix soon), `medium` (fix later).
- `label`/`decoration` optional — omit for severity defaults (`critical`/`high` → `issue (blocking)`, `medium` → `suggestion (non-blocking)`).
- `path`/`line` required when mapped to diff (`line` = NEW-file line); add `start_line` for a multi-line range. Omit both for general findings.
- `suggested_change` posts as a GitHub suggested change — one click commits it to the branch. Emit it only when **every** condition holds: the fix is confined to the commented lines (no new import, no second call site, no cross-file edit); you can reproduce every line from `start_line` through `line` verbatim, indentation included, from the diff you were given; the whole range is inside the diff; and it is under ~10 lines. Otherwise omit it. It is the file's new text for that range — never a fragment, a `...` elision, or a diff with `+`/`-` markers. Always set `suggestion` as well; it is what the author reads when the range cannot be anchored.
- Wrap code refs in backticks; keep `body` to 1–2 terse sentences.
- After the JSON, add a 1-2 sentence summary. Focus on crashes and vulnerabilities, not style.

## Code to Review
{{DIFF}}

Merge (Step 5): group by path+line; prepend "[Found by 2/2 models]" when both passes agree; take highest severity.

3.2 Risk-gated QR passes (parallel with bug-finder)

Read shared/risk-class-routing.md. From risk_class, decide which of these skills to run:

Gate Skill
domain ∈ risk_class review:domain-architecture
data or api ∈ risk_class review:data-contracts
ops or concurrency ∈ risk_class review:ops-reliability
Large/mixed/CD/design signals review:change-evolution

For each selected skill, spawn a Task (prefer sonnet unless domain/architecture needs opus):

Use Task tool:
- subagent_type: "general-purpose"
- model: "sonnet"   # use "opus" for domain-architecture when risk is high
- description: "QR pass <name>"
- prompt: |
    Invoke Skill "review:<name>" with args "<PR_URL> <OUTPUT_DIR>".
    Follow that skill exactly — it scopes its own anti-pattern slice.
    Write $OUTPUT_DIR/<name>-<PR_NUMBER>.json. Return a one-line finding-count summary.

These invoke the skill, so they resolve its references themselves — unlike the bug-finders, they need nothing inlined.

If risk_class is empty, skip QR passes (bug-finder still runs).

Do not dispatch yet — Step 4's Tasks go out in the same message.

Step 4: Run Phase 2 Skills (Parallel)

4.1 Security Scanner (Sonnet subagent)

Use Task tool:
- subagent_type: "general-purpose"
- model: "sonnet"
- description: "Security scan (sonnet)"
- prompt: |
    Invoke Skill "review:security-scan" with args "<PR_URL> <OUTPUT_DIR>".
    Deepen OWASP authz/IDOR, business-logic abuse, SSRF, PII-in-logs per that
    skill. Write security-scan-<PR_NUMBER>.json. One-line summary.

4.2 Documentation Validator (Haiku subagent)

Use Task tool:
- subagent_type: "general-purpose"
- model: "haiku"
- description: "Docs drift check (haiku)"
- prompt: |
    Invoke Skill "review:docs-drift" with args "<PR_URL> <OUTPUT_DIR>".
    Include light DX fold (ADR/runbook/caller migration) per that skill.
    Write docs-drift-<PR_NUMBER>.json. One-line summary.

Send every Step 3 and Step 4 Task in ONE message — 2 bug-finders, 0–4 QR passes, security-scan, docs-drift. They are independent and all read the same Step 1.4 capture. Collect in Step 5.

Step 5: Collect Results

Wait for: bug-finder ×2, QR passes (if any), security-scan, docs-drift.

Parse:

  • $OUTPUT_DIR/pr-analysis-*.json — risk_class
  • Bug-finder merged findings
  • $OUTPUT_DIR/domain-architecture-*.json, data-contracts-*.json, ops-reliability-*.json, change-evolution-*.json — each findings array
  • $OUTPUT_DIR/security-scan-*.json
  • $OUTPUT_DIR/docs-drift-*.json

Both bug-finders return their findings in context, not on disk. Write the merged array to $OUTPUT_DIR/bug-finder-<PR_NUMBER>.json as {"findings": [...]} — Step 7.5 collects the ledger from these files, and a pass with no file on disk is a pass whose findings /review:fix will never see.

Step 6: Determine Merge Recommendation

IF (any finding carries decoration "blocking"):
  RECOMMENDATION = "REQUEST CHANGES"
  RATIONALE = "<N> blocking findings — <top 3 titles by priority stack>"

ELIF (missing_critical_docs) OR (security_sensitive === true):
  RECOMMENDATION = "COMMENT"
  RATIONALE = "Non-blocking findings; manual review required"

ELSE:
  RECOMMENDATION = "COMMENT"
  RATIONALE = "Review completed - findings noted for consideration"

A finding decorated (blocking) that yields a COMMENT verdict teaches the author to ignore the decoration. One blocking finding is enough for REQUEST CHANGES; counts and severity tiers only order the output.

Always default to COMMENT (never APPROVE) — human-in-the-loop.

Step 7: Build structured JSON for shared formatter

Sections

  1. Change Analysis — body: languages, impact, risk_class. No inline findings.
  2. Code Review Results (2 Passes) — bug-finder findings (inline when path+line).
  3. Domain & Architecture — from domain-architecture (omit if skipped/empty).
  4. Data & Contracts — from data-contracts (omit if skipped/empty).
  5. Ops & Reliability — from ops-reliability (omit if skipped/empty).
  6. Change & Evolution — from change-evolution (omit if skipped/empty).
  7. Security Analysis — security-scan findings.
  8. Documentation Check — docs-drift body (+ inline if path+line).

Set review_metadata.model to your model ID. Note bug-finder pass models in Code Review body. Set tool_version from .claude-plugin/plugin.json (do not hardcode).

Conventional Comments

Formatter applies <label> [decoration]: <subject>. Finding fields match bug-finder schema. Severity defaults per shared/severity-rubric.md. Clean Code and category 4 design quality → blocking regardless of module reach.

Suggested changes

Carry each finding's suggested_change through to the section findings array verbatim — the formatter renders it as a committable inline suggestion and drops the prose remedy for that comment. QR, security and docs passes use the same field; where one reports only prose (fix, remedy) and the diff gives you the exact replacement for the mapped range, write suggested_change yourself under the Bug-Finder Prompt's conditions. Where it does not, leave prose.

Do not invent the replacement from the finding's description. The author commits it with one click, so a suggestion reconstructed from memory lands as a broken commit under your name.

Formatting rules

  • Code refs in backticks; bullets not paragraphs; lead with takeaway.

Ordering required_actions

Blocking design and craft dimensions mean most non-trivial PRs return REQUEST CHANGES. Order required_actions by the taxonomy priority stack (shared/quality-review-pr-review-taxonomy.md, "QR / Staff-style priority stack"): intent → system fit → domain invariants → failure behavior → contracts → test adequacy → design simplicity → security → maintainability → craft.

List every blocking finding. Do not cap, summarize, or elide. The consumer may be an agent working the list to completion, so an omitted action is an unfixed finding. Ordering sets the sequence; it never sets the membership.

Each entry must be actionable on its own, without reading the rest of the review: name the path (and line, when mapped), the symptom, and the fix. For a craft or design finding, name the resolving refactoring.

Build JSON

{
  "pr_url": "<FULL_PR_URL>",
  "recommendation": "<REQUEST_CHANGES|COMMENT>",
  "rationale": "<Brief summary from Step 6>",
  "required_actions": ["<action1>"],
  "optional_improvements": ["<suggestion1>"],
  "sections": [
    {"title": "Change Analysis", "summary_line": "...", "body": "..."},
    {"title": "Code Review Results (2 Passes)", "summary_line": "...", "body": "...", "findings": []},
    {"title": "Domain & Architecture", "summary_line": "...", "body": "...", "findings": []},
    {"title": "Data & Contracts", "summary_line": "...", "body": "...", "findings": []},
    {"title": "Ops & Reliability", "summary_line": "...", "body": "...", "findings": []},
    {"title": "Change & Evolution", "summary_line": "...", "body": "...", "findings": []},
    {"title": "Security Analysis", "summary_line": "...", "body": "...", "findings": []},
    {"title": "Documentation Check", "summary_line": "...", "body": "..."}
  ],
  "review_metadata": {
    "tool_name": "review",
    "review_title": "Review",
    "tool_version": "<from plugin.json>",
    "model": "<orchestrator model ID>"
  }
}

Omit skipped/failed/empty QR sections. Formatter omits empty sections.

Write this JSON to $OUTPUT_DIR/review-payload.json — Steps 7.5 and 8 both read it from there.

Step 7.5: Persist findings to the durable ledger

Steps 1-7 wrote everything to $OUTPUT_DIR, which is a /tmp dir keyed on a random session id. A later session cannot find it, so the findings — and the refactorings they name — die with this run. Write them somewhere durable instead, so /review:fix can work the list to completion.

LEDGER=$(python3 "$PLUGIN_ROOT/scripts/findings_ledger.py" build \
  --pr-url "$PR_URL" \
  --analysis "$OUTPUT_DIR/pr-analysis-${PR_NUMBER}.json" \
  --payload  "$OUTPUT_DIR/review-payload.json" \
  --run "$SESSION_ID" \
  $(for f in "$OUTPUT_DIR"/*-${PR_NUMBER}.json; do
      case "$(basename "$f")" in
        pr-analysis-*) continue ;;
      esac
      printf ' --source %s=%s' "$(basename "$f" | sed "s/-${PR_NUMBER}\.json$//")" "$f"
    done) \
  | cut -f1)

The script derives ~/.claude/review-findings/<owner>__<repo>/pr-<N>.json from the PR URL, normalizes all four finding shapes into one schema, and copies the test_setup / build_system / languages slice of the analysis into the ledger. That slice is copied rather than referenced because $OUTPUT_DIR is gone by the time fix runs.

The ledger holds source excerpts from security findings, so the script writes it 0600 under a 0700 directory and replaces any reported credential with a digest. Do not copy ledger contents into a log line or a PR comment.

If this step fails, the review is still complete — report the failure and move on. The ledger is an optimization for fix, not part of the review verdict.

Step 8: Post review via shared formatter

cat "$OUTPUT_DIR/review-payload.json" \
  | python3 "$PLUGIN_ROOT/scripts/review_formatter.py" --post

On failure, --dry-run and show the user.

Step 9: Provide User Summary

Comprehensive Review Complete

Summary:
- Languages: <primary>
- Risk classes: <list or none>
- Code Review: <X Critical, Y High, Z Medium>
- QR passes: <which ran>
- Security: <counts>
- Documentation: <status>
- Recommendation: <REQUEST CHANGES | COMMENT>

View full review: <PR_URL>

Error Handling

  • analyze fails → continue; omit Change Analysis; note in rationale
  • bug-finder fails → omit Code Review section; recommend manual review
  • a QR pass fails → omit that section; continue
  • both analyze and bug-finder fail → do not post incomplete review
  • Step 1.4 capture fails → stop; no pass can run without the diff
  • GitHub rejects the review (422) → the formatter re-posts suggested changes as prose, then without inline comments at all; nothing to do by hand
  • post fails → dry-run + save JSON under $OUTPUT_DIR

Notes

  • Entry point for comprehensive reviews
  • Model-diverse 2-pass bug-finder (opus+sonnet) + risk-gated QR skills (domain-architecture, data-contracts, ops-reliability, change-evolution) + security-scan + docs-drift
  • Each pass owns its anti-pattern slice at skills/<pass>/references/anti-patterns.md, so it can address no other
  • Clean Code and category 4 design-quality findings are blockers regardless of module reach; blast radius sets severity only. Each names its resolving refactoring
  • A finding whose fix is mechanical and confined to the lines it flags posts as a committable GitHub suggestion, not a prose remedy in the body
  • Test execution/coverage left to CI
  • Never auto-approves/merges
  • Cost: higher when QR passes gate on; still prefer gated runs over always-on four extras

04 同仓库更多 Skills

ozzycodes2
ozzycodes2/claudellum

writing-design-docs

Use when the user wants to write a problem-statement design doc, says "let's plan a feature properly" / "write a design doc" / "I'm thinking about how to do X" for a non-trivial X, or before committing to a non-obvious technical direction

★ 1
ozzycodes2
ozzycodes2/claudellum

write-doc

Use when the user asks to write or draft a README, ADR, runbook, tutorial, how-to, explanation, or reference doc, or a caller passes "type ADR" or "type README". Picks the type, fills a template, adds diagrams. RFCs and design docs belong to writing-design-docs.

★ 1
ozzycodes2
ozzycodes2/claudellum

review-doc

Use when the user asks to review, critique, score, grade, or "how good is this doc" for a Markdown doc or pasted text. Read-only. Scores it on the 20 Practical Prose dimensions and emits a findings table. Does not edit; fix-doc applies the findings next.

★ 1
ozzycodes2
ozzycodes2/claudellum

fix-doc

Use when the user asks to fix, edit for prose quality, polish, tighten, humanize, or de-slop a Markdown doc or pasted text, or says "make this read less AI". Applies review-doc findings, generates flagged diagrams, lists substantive issues for the author, then runs the AI-tell pass last. Modifies the target.

★ 1
ozzycodes2
ozzycodes2/claudellum

create-slides

Use when the user asks for a slide deck, presentation, talk, or slides from a document, report, PR, notes, or topic. Builds one self-contained Machinify-branded HTML deck in a minimalist style, with headline-plus-visual slides, speaker notes, and every diagram drawn by architecture-design:create-diagram.

★ 1
ozzycodes2
ozzycodes2/claudellum

start-session

Open a Claude Code working session in a fresh, isolated git worktree, so the user can start a task with a single /start-session <name>. Use at the START of a session when the user says "start session", "start a worktree", "spin up a worktree for ABC-123", "begin work on <ticket>", or passes a name/ticket to work under. Creates and ENTERS a worktree via the EnterWorktree tool (never `git worktree add`) under .claude/worktrees/, named exactly after the argument, on a local branch `worktree-<argument>`. Reports what the worktree inherited (`.worktreeinclude` copies, symlinked node_modules) and whether its `.env` still points at the main checkout's stack. If the argument is a JIRA key (e.g. ABC-123, PROJ-1505), also loads that story with the Atlassian CLI (`acli`) when available and summarizes the implementation ask. Also renames the session to the argument (the same effect as `/rename <NAME>`) so it's easy to find in `/resume`. Then stops and waits — it sets up the workspace and context, it does not implement.

★ 1