An automated GitHub PR review agent powered by the Claude Agent SDK, running in isolated E2B sandboxes with a real-time analytics dashboard.
- Receives GitHub webhooks when a PR is opened or updated
- Spins up an isolated E2B sandbox for each review
- Runs Claude Agent SDK to analyze the code - it can read files, search the codebase, and run commands
- Posts a review comment back to the GitHub PR
- Tracks analytics - cost, tokens, duration, tool usage
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ GitHub Webhook │─────▶│ Orchestrator │─────▶│ E2B Sandbox │
│ (PR opened) │ │ (Local Express) │ │ (Claude Agent) │
└─────────────────┘ └────────┬─────────┘ └────────┬────────┘
│ │
▼ │
┌──────────────────┐ │
│ SQLite + Web UI │◀──────────────┘
│ (Analytics) │
└──────────────────┘
| Component | Technology |
|---|---|
| Runtime | Node.js + TypeScript |
| Server | Express.js |
| Agent | @anthropic-ai/claude-agent-sdk |
| Sandbox | E2B |
| Database | SQLite (better-sqlite3) |
| GitHub API | Octokit |
| Dashboard | Vanilla HTML/JS + Chart.js |
npm installcp .env.example .envEdit .env with your API keys:
ANTHROPIC_API_KEY=sk-ant-...
GITHUB_TOKEN=ghp_...
GITHUB_WEBHOOK_SECRET=your-secret
E2B_API_KEY=e2b_...
PORT=3001
npm run devVisit http://localhost:3001
Either:
- Use the "Manual Trigger" form in the dashboard with any GitHub PR URL
- Or set up a GitHub webhook (see below)
-
Expose your local server with ngrok:
ngrok http 3001
-
In your GitHub repo, go to Settings → Webhooks → Add webhook
-
Configure:
- Payload URL:
https://your-ngrok-url.ngrok.io/webhook/github - Content type:
application/json - Secret: Same as
GITHUB_WEBHOOK_SECRETin your.env - Events: Select "Pull requests"
- Payload URL:
-
Now when you open a PR, the agent will automatically review it!
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Analytics dashboard |
/webhook/github |
POST | GitHub webhook receiver |
/api/reviews |
GET | List all reviews |
/api/reviews/:id |
GET | Get review details with traces |
/api/analytics |
GET | Summary statistics |
/api/trigger |
POST | Manually trigger a review |
Inside the E2B sandbox, the Claude Agent SDK:
- Fetches PR metadata and diff from GitHub
- Clones the repository
- Analyzes the changes using tools:
Read- read file contentsGlob- find files by patternGrep- search codeBash- run commands
- Generates a structured review
- Posts the review as a PR comment
The agent captures detailed traces for debugging:
# Get trace events for a review
curl http://localhost:3001/api/reviews | jq '.[0].traceEvents'Traces include:
- GitHub API call timing
- Git clone duration
- Each tool invocation with inputs/outputs
- Token usage per turn
- Total cost calculation
pr-review-agent/
├── src/
│ ├── index.ts # Express server + routes
│ ├── orchestrator.ts # E2B sandbox management + agent code
│ ├── agent/
│ │ └── reviewer.ts # Standalone agent (reference)
│ ├── analytics/
│ │ ├── store.ts # SQLite operations
│ │ └── types.ts # TypeScript interfaces
│ └── web/
│ └── dashboard.html # Analytics UI
├── docs/
│ └── dashboard.png # Screenshot
├── package.json
├── tsconfig.json
└── .env.example
MIT
