{
  "$schema": "https://promptfoo.tech/schemas/workflow-template.json",
  "name": "Claude + MCP: An Autonomous Pull Request Review Agent",
  "slug": "claude-mcp-github-code-review-agent",
  "platform": "Claude",
  "category": "mcp-servers",
  "difficulty": "Intermediate",
  "tags": [
    "claude",
    "mcp",
    "github",
    "coding",
    "agents"
  ],
  "summary": "Wire the official GitHub MCP server into Claude and stand up an agent that reviews PRs against your team's style guide, security rules, and testing conventions.",
  "overview": "Human PR reviews are expensive and inconsistent. This workflow turns Claude into a first-pass reviewer that runs against every PR: it reads the diff, understands the surrounding code via the GitHub MCP server, checks it against a versioned rubric (style guide, security rules, test coverage), and leaves inline comments — never approving on its own, always deferring the final call to a human.",
  "variables": {
    "ANTHROPIC_API_KEY": "sk-ant-...",
    "GITHUB_TOKEN": "ghp_..."
  },
  "steps": [
    {
      "order": 1,
      "name": "Install the GitHub MCP server",
      "description": "Use the official @modelcontextprotocol/server-github package. Give it a fine-scoped PAT with pull_requests:write and contents:read on the target repos only."
    },
    {
      "order": 2,
      "name": "Author the review rubric",
      "description": "Write a single markdown file with your review rules grouped by category. This becomes the system prompt; commit it to the repo so history is auditable."
    },
    {
      "order": 3,
      "name": "Wire the webhook",
      "description": "A Cloudflare Worker verifies the GitHub HMAC signature, then invokes Claude with the PR number. Keep the worker small — no business logic, just secure hand-off."
    },
    {
      "order": 4,
      "name": "Prompt for humility",
      "description": "Instruct Claude to say 'I'm not sure' and defer, not guess. Ask it to cite the file and line for every claim so reviewers can verify quickly."
    },
    {
      "order": 5,
      "name": "Roll out on one repo",
      "description": "Enable on a low-traffic repo first. Read the first 20 reviews line-by-line and tighten the rubric before expanding."
    },
    {
      "order": 6,
      "name": "Add feedback loops",
      "description": "When a human overrides a comment, log the diff between what the agent said and what shipped. Weekly, feed the top disagreements back into the rubric."
    }
  ],
  "howItWorks": [
    "Claude Desktop (or a headless Claude client) connects to the GitHub MCP server with a scoped personal access token.",
    "A webhook on pull_request events triggers the agent via a small Cloudflare Worker.",
    "The agent uses MCP to read the diff, the surrounding files, and the PR description.",
    "A system prompt encodes your review rubric: naming, error handling, test presence, common security anti-patterns, and doc updates.",
    "Claude posts inline comments and a summary, tagging a human owner for the final approve/deny."
  ],
  "benefits": [
    "Every PR gets a review inside 60 seconds, not next-day.",
    "Reviewers spend their time on architecture, not nits.",
    "Style-guide drift disappears because the rubric is versioned in one file."
  ],
  "useCases": [
    "Small teams where the senior engineer is the bottleneck on reviews.",
    "Open-source projects with unpredictable contributor volume.",
    "Consultancies that want a consistent baseline across many client repos."
  ],
  "example": "PR comment: 'src/auth/session.ts:42 — new setCookie call is missing HttpOnly and Secure flags. Our rubric §3.2 requires both on any auth cookie. Suggested fix: pass { httpOnly: true, secure: true, sameSite: \"lax\" }.'",
  "faqs": [
    {
      "q": "Will Claude auto-merge?",
      "a": "No, and it shouldn't. The agent is a reviewer, not an approver. Enforce human approval via GitHub branch protection."
    },
    {
      "q": "What about secret leakage?",
      "a": "Never send private repo diffs to a model your legal team hasn't reviewed. Anthropic's zero-retention agreements exist for exactly this."
    },
    {
      "q": "Which Claude model?",
      "a": "Sonnet is the sweet spot for review depth vs cost. Opus for security-sensitive repos, Haiku only for typo/style-only bots."
    }
  ],
  "source": "https://promptfoo.tech/workflows/claude-mcp-github-code-review-agent",
  "updated": "2026-05-30",
  "license": "CC-BY-4.0"
}