/groundwork:review-pr [PR number or URL] [--no-interactive]from groundwork
Reviews a GitHub PR using multi-agent verification. Runs specialized agents against PR changes and posts structured feedback to GitHub without modifying code.
Ships in groundwork. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Multi-agent PR review that runs specialized agents against PR changes and posts structured feedback to GitHub. It reports findings and never changes code — fixing is the validate skill's job.
Check for non-interactive mode from either source:
--no-interactive → strip it from the argument before PR number parsing, set non_interactive = trueGROUNDWORK_BATCH_MODE=true → set non_interactive = trueIf either condition is met, every AskUserQuestion prompt below is replaced with its documented auto-decision, and the pre-flight model check is skipped too.
Your current effort level is {{effort_level}}. Skip this step silently if effort is high, xhigh, or max (the scale is low < medium < high < xhigh < max, so xhigh and max are already above high) AND you are Sonnet or Opus. Otherwise ask via AskUserQuestion (header "Model check"; options "Continue anyway" / "Cancel — I'll switch first"):
"Do you want to switch? Multi-agent orchestration and deduplication judgment across the reviewer agents benefits from consistent reasoning.
Recommended: Sonnet or Opus at high effort.
To switch: cancel, run
/effort high(and/model sonnetif on Haiku), then re-invoke this skill."
If the user selects "Cancel — I'll switch first": output the switching commands and stop. Do not proceed with the skill. Ask once per conversation: a skill invoked by another skill skips this step when the recommendation was already shown. In a non-interactive run (--noninteractive, GROUNDWORK_RUNNER_MODE=true, or GROUNDWORK_BATCH_MODE=true), skip the prompt and continue on the current model.
Extract the PR number from the user's input. Accept any of these formats:
42#42https://github.com/owner/repo/pull/42If no PR identifier was provided:
AskUserQuestion to ask for one (free-text input, no options).Extract owner/repo by running:
gh repo view --json nameWithOwner --jq '.nameWithOwner'
Store the PR number as pr_number and the owner/repo as repo_slug.
Run all of these gh commands in parallel using the Bash tool:
PR metadata:
gh pr view <pr_number> --json title,body,baseRefName,headRefName,headRefOid,author,state,url,isCrossRepository,additions,deletions,changedFiles
PR diff — saved to a temp file; only its hunk headers enter this context:
PR_DIFF_FILE="$(mktemp "${TMPDIR:-/tmp}/groundwork-pr-diff-XXXXXX")" && gh pr diff <pr_number> > "$PR_DIFF_FILE" && grep -nE '^(diff --git|@@)' "$PR_DIFF_FILE"
The full diff never enters this context (the context-budget rule in Step 5). Keep the printed header lines as pr_hunk_headers — the diff --git file names and the @@ new-side line numbers that Step 6c maps findings with — and keep PR_DIFF_FILE for the cleanup in Step 9.
Changed file paths:
gh pr view <pr_number> --json files --jq '.files[].path'
Store as changed_file_paths.
Diff stat:
gh pr diff <pr_number> --stat
Store as diff_stat.
Existing reviews:
gh api repos/<repo_slug>/pulls/<pr_number>/reviews
Store as existing_reviews.
Existing review comments:
gh api repos/<repo_slug>/pulls/<pr_number>/comments
Store as existing_comments.
Validate state:
OPEN:
AskUserQuestion:
{
"questions": [{
"question": "This PR is **[state]**. Continue reviewing anyway?",
"header": "PR is not open",
"options": [
{ "label": "Yes, continue" },
{ "label": "Cancel" }
],
"multiSelect": false
}]
}
If "Cancel" → stop.git fetch origin +pull/<pr_number>/head:pr-<pr_number>-review && git checkout pr-<pr_number>-review
Concurrent same-PR reviews in one clone: the fetch above creates pr-<pr_number>-review or moves it to the PR's current headRefOid, so a branch left by a previous review is reused idempotently instead of fought over — note in your output that an existing review branch was reused. If the checkout is refused because another worktree has that branch checked out, a concurrent review holds it: report that and stop rather than moving the branch underneath it.
Search existing_reviews for reviews whose body contains the marker <!-- groundwork-review -->.
If groundwork reviews exist:
AskUserQuestion:
{
"questions": [{
"question": "Previous groundwork review(s) found on this PR. How would you like to proceed?",
"header": "Existing groundwork reviews detected",
"options": [
{ "label": "Fresh review", "description": "Post a fresh review (dismisses previous)" },
{ "label": "Incremental review", "description": "Only new findings since last groundwork review" },
{ "label": "Cancel" }
],
"multiSelect": false
}]
}
If "Fresh review" → proceed normally. If "Incremental review" → store previous groundwork findings to exclude duplicates in Step 6. If "Cancel" → stop.
If non-groundwork reviews or review comments exist, produce a brief summary as existing_human_feedback. Include:
This summary will be passed to agents so they avoid restating already-raised points.
If existing_comments contain replies to previous groundwork-authored comments. A comment is groundwork-authored when its review's body carries the <!-- groundwork-review --> marker; inline comments carry no marker of their own, so match them through their parent review or its author:
Parse changed_file_paths to determine which conditional agents to enable:
| Agent | Active | Skip when |
|---|---|---|
code-quality-reviewer | Always | -- |
test-quality-reviewer | Always | -- |
security-reviewer | Always | -- |
performance-reviewer | Always | -- |
code-simplifier | Always | -- |
housekeeper | Always | -- |
architecture-alignment-checker | Conditional | No architecture docs found at {{specs_dir}}/ |
design-consistency-checker | Conditional | No design system docs AND no CSS/styling files in changed_file_paths |
cloud-infrastructure-reviewer | Conditional | No IaC/config files in changed_file_paths |
conventions-reviewer | Conditional | No CLAUDE.md files found in the repo |
spec-alignment-checker | Conditional | No product specs found at {{specs_dir}}/ |
spec-alignment-checker covers the "did we build the right thing" axis: PRs that went through the full lifecycle already had it checked by validate (with fix authority); activating it here catches PRs that bypassed the lifecycle — external contributions, manually assembled branches.
Check for architecture, design, and product-spec docs:
{{specs_dir}}/architecture.md or {{specs_dir}}/architecture/{{specs_dir}}/design_system.md or {{specs_dir}}/design_system/{{specs_dir}}/product_specs.md or {{specs_dir}}/product_specs/Record skipped agents with reason in the aggregation table (verdict: skipped).
CRITICAL — Context budget: Do NOT read file contents, full diffs, or docs into this orchestrating context. Collect only file paths and metadata. Agents have Read/Grep/Glob tools and will read files in their own context windows.
Spawn all active agents in parallel using the Agent tool with subagent_type. Each agent receives:
Agent (subagent_type) | Context to Provide |
|---|---|
groundwork:code-quality-reviewer:code-quality-reviewer | changed_file_paths, diff_stat, pr_description, existing_human_feedback |
groundwork:test-quality-reviewer:test-quality-reviewer | changed_file_paths, diff_stat, pr_description, existing_human_feedback |
groundwork:security-reviewer:security-reviewer | changed_file_paths, diff_stat, pr_description, existing_human_feedback |
groundwork:performance-reviewer:performance-reviewer | changed_file_paths, diff_stat, pr_description, existing_human_feedback |
groundwork:code-simplifier:code-simplifier | changed_file_paths, diff_stat, pr_description, existing_human_feedback |
groundwork:housekeeper:housekeeper | changed_file_paths, diff_stat, pr_description, existing_human_feedback |
groundwork:architecture-alignment-checker:architecture-alignment-checker | changed_file_paths, diff_stat, pr_description, architecture_path, existing_human_feedback |
groundwork:design-consistency-checker:design-consistency-checker | changed_file_paths, diff_stat, pr_description, design_system_path, existing_human_feedback |
groundwork:cloud-infrastructure-reviewer:cloud-infrastructure-reviewer | changed_file_paths, diff_stat, pr_description, architecture_path, existing_human_feedback |
groundwork:conventions-reviewer:conventions-reviewer | changed_file_paths, diff_stat, pr_description, existing_human_feedback |
groundwork:spec-alignment-checker:spec-alignment-checker | changed_file_paths, diff_stat, task_definition, specs_path, existing_human_feedback |
For spec-alignment-checker, task_definition is what it traces requirements to, so build it from the best available source. When the head branch is a task branch (task/TASK-NNN, or task/<project>/TASK-NNN in a monorepo), point the agent at the tasks file and the task ID and have it read that ### TASK-NNN section itself (goal, action items, acceptance criteria). Otherwise pass the PR title + body as the definition and say that the PR's stated intent is the scope. specs_path is the product-specs file or directory found in Step 4.
In each agent prompt, include these instructions:
Use the Read tool to examine these files. Do NOT expect file contents in this prompt — read them yourself.
PR Review context: You are reviewing a pull request, not a local task implementation. The
pr_descriptionbelow replacestask_definition. Focus ONLY on code within the PR diff. Do not flag issues in unchanged code unless the change directly impacts it.Existing feedback: Other reviewers have already raised the points summarized below. Do not restate these — focus on issues not yet covered.
Tooling boundary: Skip anything the project's tooling already enforces — linter, typechecker, formatter, CI gates. A finding must be actionable judgment beyond what a deterministic check catches; "the linter would flag this" is not a finding.
Review mode:
review_mode: initial-audit. Your baseline is the PR diff (the changed files below) together with the PR's stated intent: make one comprehensive pass over it and report every supported finding with concrete evidence.
Where pr_description is the PR title + body concatenated.
Each agent returns standard JSON:
{
"summary": "One-sentence assessment",
"score": 0-100,
"findings": [{"severity": "critical|major|minor", "category": "...", "file": "...", "line": N, "finding": "...", "recommendation": "..."}],
"verdict": "approve|request-changes"
}
## PR Review — Multi-Agent Report
| Agent | Score | Verdict | Critical | Major | Minor |
|-------|-------|---------|----------|-------|-------|
| Code Quality | 85 | approve | 0 | 1 | 2 |
| Test Quality | 88 | approve | 0 | 1 | 0 |
| Security | 95 | approve | 0 | 0 | 1 |
| Performance | 82 | approve | 0 | 1 | 1 |
| Code Simplifier | 92 | approve | 0 | 0 | 2 |
| Housekeeper | 90 | approve | 0 | 1 | 0 |
| Architecture | -- | skipped | -- | -- | -- |
| Design | -- | skipped | -- | -- | -- |
| Cloud Infrastructure | -- | skipped | -- | -- | -- |
| Conventions | 95 | approve | 0 | 0 | 1 |
| Spec Alignment | -- | skipped | -- | -- | -- |
Group all findings by file. For findings within 3 lines of each other with semantically similar text:
If running in incremental mode (from Step 3a), also exclude findings that match previous groundwork review comments.
Use pr_hunk_headers (from Step 2) to determine which finding lines fall within diff hunks. Each @@ -a,b +c,d @@ header places that hunk's new-side lines at c through c+d-1 of the file named by the preceding diff --git line.
line falls within a diff hunk on the RIGHT side → inline_findings[] (will be posted as inline review comments)line falls outside any diff hunk → general_findings[] (will be included in review body)AskUserQuestion:{
"questions": [{
"question": "- **Inline comments**: [N]\n- **General findings**: [N]\n- **Verdict**: [APPROVE / REQUEST_CHANGES / COMMENT]\n- **Agents run**: [N] ([N] skipped)",
"header": "PR Review Summary for [PR title] (#[pr_number])",
"options": [
{ "label": "Post review" },
{ "label": "Show full preview", "description": "Display all findings before posting" },
{ "label": "Cancel" }
],
"multiSelect": false
}]
}
If "Show full preview" → display the full aggregation table plus all findings with their file/line/severity, then re-ask:
{
"questions": [{
"question": "Review the findings above. Ready to post?",
"header": "Post review?",
"options": [
{ "label": "Post review" },
{ "label": "Cancel" }
],
"multiSelect": false
}]
}
If "Cancel" at either prompt → stop.
event: APPROVErequest-changes OR any critical/major findings exist → event: REQUEST_CHANGESevent: COMMENTEach inline finding becomes a review comment:
**[severity]** [category] *(from: agent1, agent2)*
[finding]
**Recommendation:** [recommendation]
Map each to the GitHub review comment format:
path: file path relative to repo rootline: line number on the RIGHT side of the diffside: RIGHTBuild the review body:
## Groundwork PR Review
[Aggregation table from 6a]
### General Findings
[List of general_findings not attached to inline comments]
---
*Reviewed by [N] agents | [N] findings ([N] inline, [N] general)*
<!-- groundwork-review -->
The <!-- groundwork-review --> marker at the end enables future identification of groundwork-authored reviews.
Post a single review using the GitHub API to avoid multiple notifications. Use --input - with a single-quoted heredoc to pass the JSON payload via stdin — this avoids shell interpolation issues with complex markdown bodies.
Do NOT generate Python, Node, or any helper scripts to post the review. Use the gh api --input - approach below directly.
cat <<'REVIEW_PAYLOAD' | gh api repos/<repo_slug>/pulls/<pr_number>/reviews --method POST --input -
{
"event": "<EVENT>",
"body": "<review_body>",
"comments": [
{
"path": "src/example.ts",
"line": 42,
"side": "RIGHT",
"body": "This condition doesn't handle the edge case where `input` is empty.\n\n```suggestion\nif (!input || input.length === 0) {\n return defaultValue;\n}\n```"
}
]
}
REVIEW_PAYLOAD
JSON escaping rules — inside the heredoc, the JSON must be valid:
\"\n\\<<'REVIEW_PAYLOAD') prevents shell expansion, so $, `, and \ are passed literally to ghFallback: If the API call fails due to an invalid line position, remove the offending comment from comments[], append it to the review body under a "Could not attach inline" heading, and retry using the same cat <<'REVIEW_PAYLOAD' | gh api --input - approach.
git checkout -
git branch -D pr-<pr_number>-review 2>/dev/null || true
A later review recreates it from the PR head, so this is safe even when you reused a branch a previous review left behind.rm -f "$PR_DIFF_FILE"
## PR Review Posted
**[PR title]** (#[pr_number]) — [url]
- Event: [APPROVE / REQUEST_CHANGES / COMMENT]
- Inline comments: [N]
- General findings: [N]
- Agents: [N] run, [N] skipped
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (etr/groundwork) — no native marketplace selected
npx claudepluginhub p/etr-groundwork44 skills in this plugin
/build-unplannedBuild a feature from a description with worktree isolation and TDD. Optional flag - --on-unrelated-failure stop-and-ask|expand-and-fix|ignore-and-merge - how validation treats gate failures unrelated to the active project (default stop-and-ask)./check-specs-alignmentVerify alignment between code and specs./create-tasksGenerate implementation tasks from architecture document./debugUse when investigating bugs, unexpected behavior, test failures, or any code that does not work as expected - enforces systematic root cause analysis before any fixOther plugins' skills for the same job