
Step-by-step tutorial on creating an agent that reviews pull requests, detects security vulnerabilities, and suggests improvements.
Code review is one of the most impactful use cases for AI agents — it requires understanding context, applying domain-specific rules, and communicating feedback clearly. In this tutorial, we'll build a production-ready code review agent that integrates with GitHub and catches real issues.
What We're Building
Automatically triggered on new pull requests via GitHub webhook
Analyzes diff for security vulnerabilities, performance regressions, and style violations
Posts inline review comments with suggested fixes
Learns from accepted/rejected suggestions to improve over time
Respects a configurable .review-policy file in each repository
Step 1: Define the Agent
We start by defining an agent with access to the tools it needs: GitHub's API for reading diffs and posting comments, a code analysis tool for static analysis, and the Meridian memory API for learning from feedback.

Step 2: Configure the Webhook
Meridian's webhook integration makes it easy to trigger agents from external events. We'll configure the agent to listen for pull_request.opened and pull_request.synchronize events.

Step 3: Define Review Policies
Review policies let repository owners customize what the agent looks for. This is defined as a .review-policy.yaml file in the repository root.

Step 4: Deploy and Test
Deploy the agent and create a test pull request with some known issues. The agent should automatically post a review within seconds.

Full Source Code
The complete source code for this tutorial is available on GitHub at meridian-examples/code-review-agent, including tests, CI configuration, and a sample review policy.














