What Are We Building?
A code review agent that reads your pull request, checks it against your project’s conventions, flags real issues, and outputs a structured summary. It combines the three layers you learned in the previous lessons. CLAUDE.md sets the code style rules. A skill defines the review workflow. A GitHub MCP server gives Claude access to your PRs without leaving the terminal.
By the end of this guide, you will run one command and get a review that catches the issues you care about, not generic lint output.
Add Review Rules to CLAUDE.md
Open your project’s CLAUDE.md and add a review section. These rules tell Claude what matters when it reviews code in your project.
# CLAUDE.md (add to your existing file)
## Code Review Standards
- Flag any function over 50 lines. It probably needs extraction.
- No default exports. Named exports only.
- Every API endpoint must have error handling. No bare try/catch.
- Test files colocate with source: Component.test.tsx next to Component.tsx.
- No console.log in production code. Use the project logger.
- Commit messages follow Conventional Commits (feat:, fix:, chore:).
These are your project’s rules, not generic best practices. Claude already knows that error handling matters. What it does not know is that your team requires the project logger instead of console.log, or that you use colocated test files. The specifics are what make the review useful.
Create a Review Skill
Claude Code ships with a built-in /code-review skill that runs a general-purpose review. You can extend it with a custom skill that applies your project’s specific checklist.
mkdir -p .claude/skills/pr-review
Create .claude/skills/pr-review/SKILL.md with this content:
---
description: Reviews a pull request against project conventions.
Use when the user asks to review a PR, check a diff, or
prepare code for merge.
disable-model-invocation: true
---
## Review Workflow
1. Read the current diff with `git diff main...HEAD`.
2. Check every changed file against the Code Review Standards
in CLAUDE.md.
3. For each issue found, report:
- File and line number
- What the violation is
- A suggested fix (one line, not a rewrite)
4. Score confidence: only report issues you are 80%+ certain about.
5. End with a summary: total issues, files reviewed, and whether
the PR is ready to merge.
If no issues are found, say so. Do not invent problems.
The disable-model-invocation: true flag means Claude will not trigger this skill on its own. You invoke it by typing /pr-review. This is intentional for review workflows where you want to control when the review happens, not have Claude auto-trigger it mid-task.
Connect GitHub via MCP
If your project is on GitHub, connecting the GitHub MCP server lets Claude read pull requests, check CI status, and post review comments directly. Without it, Claude can still review your local diff. With it, Claude can pull the PR description, check whether CI passed, and see comments from other reviewers.
# Add the GitHub MCP server
claude mcp add --transport http github https://api.github.com/mcp
# Verify it connected
claude mcp list
The GitHub server exposes tools for reading repositories, pull requests, issues, and actions workflows. Once connected, you can ask Claude to review a specific PR by number instead of relying on your local diff.
Run Your First Agent Review
Start a Claude Code session in your project directory. All three layers load automatically. CLAUDE.md injects your code review standards. The skill registers as /pr-review. The GitHub MCP server connects in the background.
Run the review:
# Option 1: Review your local changes against main
/pr-review
# Option 2: Review a specific GitHub PR (requires MCP)
> Review PR #42 against our code review standards
Claude reads the diff, checks each changed file against your CLAUDE.md rules, and outputs a structured report. A typical review on a 200-line PR takes 30 to 60 seconds and catches convention violations that human reviewers spend time flagging manually.
If the output misses something you expected, update your CLAUDE.md rules. If the workflow needs adjustment (different output format, different confidence threshold), edit the skill’s SKILL.md. The system is designed for iteration. Every correction you make to the rules or skill persists across future sessions.
What to Build Next
The code review agent is a starting point. The same three-layer pattern (rules, skill, MCP) works for any repeatable developer workflow. A deployment agent that checks tests, builds, and pushes to staging. A documentation agent that reads changed files and updates relevant docs. A bug triage agent that pulls error reports from Sentry and creates tickets in Linear.
Each one follows the same structure. Define the rules in CLAUDE.md. Write the workflow in a SKILL.md. Connect external tools through MCP. The pieces you learned in this course are the building blocks for all of them.
