๐ Smart PR Review
March 22, 2026 ยท View on GitHub
An AI code reviewer with opinions. Not a yes-machine.
If you find this useful, please give it a star โ it helps others discover it.
Why Another Code Review Tool?
Most AI code review tools are yes-machines โ they surface linting issues, suggest minor refactors, and approve everything else. Smart PR Review is different: it acts like a Staff Engineer who's seen production meltdowns and won't let your code ship until the hard questions are answered.
| Feature | GitHub Copilot Code Review | Smart PR Review |
|---|---|---|
| Review stance | Suggests | Judges |
| Says "this approach is wrong" | Rarely | Yes, in the Summary |
| Review depth | Line-level suggestions | 6-layer deep analysis |
| Devil's Advocate mode | No | Built-in |
| Architectural review | Limited | Dedicated layer |
| Output format | Inline comments | Structured report (paste-ready) |
| Security audit | Basic | Dedicated layer with OWASP checks |
| Severity discipline | Flat suggestions | MUST FIX / SHOULD FIX / SUGGESTION |
| Webhook automation | Built-in | Self-hosted via index.ts |
| Language-specific checks | Generic | TS/JS, Python, Go, Rust specific |
Overview
Smart PR Review is an opinionated AI code reviewer that performs 6-layer deep analysis with a Devil's Advocate mechanism โ it actively challenges your assumptions and stress-tests your code against real-world failure modes.
It doesn't just check if your code works. It asks: what happens when it doesn't?
Core values:
- Direct โ "This approach is wrong" beats "This is an interesting choice"
- Actionable โ Every issue comes with replacement code, not vague advice
- Prioritized โ Clear severity levels that map to merge decisions
- Holistic โ Reviews architecture, not just syntax
Features
- 6-layer review โ Logic โ Boundaries โ Performance โ Security โ Maintainability โ Architecture
- Devil's Advocate mode โ Forces worst-case thinking on every critical change
- Structured output โ MUST FIX / SHOULD FIX / SUGGESTION / What's Good / Verdict
- 4 input modes โ PR URL, local diff, commit hash, file path
- Webhook integration โ Auto-review PRs via GitHub webhooks
- Language-aware โ TypeScript/JS, Python, Go, Rust with language-specific checks
- Large PR handling โ Automatic diff chunking for PRs > 1000 lines
- Strict mode โ Raises severity thresholds for critical codebases
Quick Start
As a Claude Code Skill (CLI)
# Install the skill
openclaw install smart-pr-review
# Review a GitHub PR
/review https://github.com/your-org/repo/pull/123
# Review your staged changes
/review --diff
# Review a specific commit
/review --commit=abc1234
# Review with security focus in strict mode
/review https://github.com/your-org/repo/pull/123 --focus=security --strict
As a Webhook Service
# Set environment variables
export GITHUB_TOKEN="ghp_..."
export GITHUB_WEBHOOK_SECRET="your-secret"
export ANTHROPIC_API_KEY="sk-ant-..."
# Install dependencies & start
npm install hono @hono/node-server
npx tsx index.ts
# ๐ Smart PR Review webhook started: http://localhost:3000
Commands
/review [PR-URL]
Review a GitHub Pull Request by URL.
/review https://github.com/acme/api/pull/42
/review https://github.com/acme/api/pull/42 --focus=security
/review https://github.com/acme/api/pull/42 --strict --lang=en
Requires: gh CLI installed and authenticated.
/review --diff
Review local uncommitted changes (staged โ unstaged โ last commit fallback).
/review --diff
/review --diff --focus=performance
/review --commit=<hash>
Review a specific commit.
/review --commit=a1b2c3d
/review a1b2c3d # shorthand
Parameters
| Parameter | Values | Default | Description |
|---|---|---|---|
--focus | security, performance, logic, all | all | Focus on a specific review dimension |
--strict | flag | off | Lower tolerance thresholds (see Strict Mode) |
--lang | zh, en | zh | Output language |
--commit | <hash> | โ | Review a specific commit |
The 6-Layer Review
Every review systematically walks through six dimensions, from correctness to architecture:
flowchart TD
INPUT["๐ฅ PR / Diff / Commit"] --> PREP["๐ Load Review Knowledge Base"]
PREP --> L1
subgraph REVIEW ["6-Layer Deep Review"]
direction TB
L1["๐ง Layer 1: Logic Correctness\nControl flow, state mutations,\nconcurrency, type safety, error propagation"]
L2["๐ฒ Layer 2: Boundary Conditions\nNull/empty handling, numeric overflow,\nUnicode, timezones, env differences"]
L3["โก Layer 3: Performance\nN+1 queries, memory leaks,\nalgorithm complexity, missing caches"]
L4["๐ Layer 4: Security\nInjection, hardcoded secrets,\nCSRF/SSRF, path traversal, auth gaps"]
L5["๐ง Layer 5: Maintainability\nNaming, function design,\nover/under-engineering, test coverage"]
L6["๐๏ธ Layer 6: Architecture\nPattern consistency, API design,\nbackward compatibility, module boundaries"]
L1 --> L2 --> L3 --> L4 --> L5 --> L6
end
L6 --> DA["๐ Devil's Advocate"]
DA --> OUT["๐ Structured Verdict"]
Layer 1: Logic Correctness ๐ง
Control flow completeness, state mutation consistency, race conditions, type safety, error propagation chains.
Layer 2: Boundary Conditions ๐ฒ
Null/undefined/nil handling, empty collections, integer overflow, floating-point precision, Unicode edge cases, timezone & daylight saving, cross-platform path differences.
Layer 3: Performance โก
N+1 queries, unnecessary re-renders (React), memory leaks (listeners, timers, closures), O(nยฒ) on large datasets, missing database indexes, redundant network requests.
Layer 4: Security ๐
Hardcoded secrets, SQL/XSS/command injection, CSRF/SSRF, unsafe deserialization, path traversal, missing auth checks, sensitive data in logs, vulnerable dependencies.
Layer 5: Maintainability ๐ง
Naming clarity, single responsibility, over/under-abstraction, magic numbers, meaningful error handling, test coverage for new logic.
Layer 6: Architecture ๐๏ธ
Consistency with existing patterns, dependency coherence, API design conventions, backward compatibility, module boundary violations, circular dependencies.
Devil's Advocate Mode
This is the core differentiator. Even when code looks fine, the reviewer forces itself through five stress tests:
| Question | What it catches |
|---|---|
| What if traffic is 100x current? | Scaling bottlenecks, connection pool exhaustion |
| What if input is maliciously crafted? | Injection attacks, DoS vectors |
| What if this needs to change in 6 months? | Rigid coupling, poor extensibility |
| What if a dependency goes down? | Missing fallbacks, cascading failures |
| What if a junior dev maintains this? | Implicit knowledge, unclear control flow |
Only when all five questions have satisfactory answers does the reviewer give APPROVE.
Output Format
Every review produces a structured, GitHub-pasteable report:
## ๐ Code Review: PR #247 โ Add user search API endpoint
### Summary
New user search API with name/email fuzzy matching. **The approach has security risks**:
the search endpoint has no auth and contains a SQL injection vulnerability. Must fix before merge.
---
### ๐จ MUST FIX (2 issues)
**[MF-1] SQL Injection Vulnerability**
๐ `src/routes/users.ts:45`
```typescript
const results = await db.query(
`SELECT * FROM users WHERE name LIKE '%${req.query.q}%'`
);
Problem: User input directly concatenated into SQL. An attacker can craft
q=%'; DROP TABLE users; -- to destroy the database.
Impact: P0 security vulnerability โ arbitrary database read/write.
Suggested fix:
const results = await db.query(
"SELECT id, name, email FROM users WHERE name LIKE \$1",
[`%${req.query.q}%`]
);
[MF-2] Search endpoint missing authentication
๐ src/routes/users.ts:38
Problem: No authMiddleware โ anyone can search user data including emails.
Impact: Privacy violation, potential GDPR non-compliance.
โ ๏ธ SHOULD FIX (2 issues)
[SF-1] Returns unnecessary user fields
๐ src/routes/users.ts:45
Problem: SELECT * exposes password_hash, reset_token.
Suggestion: Explicitly select id, name, email, avatar_url.
[SF-2] No pagination โ OOM risk at scale
๐ src/routes/users.ts:45-48
Suggestion: Add LIMIT \$2 OFFSET \$3, default 20 results per page.
๐ก SUGGESTION (1 issue)
[SG-1] Add minimum search length
๐ src/routes/users.ts:40
Suggestion: if (q.length < 2) return res.status(400)... to prevent single-char queries.
โ What's Good
- Clean route organization following existing
src/routes/patterns - Proper async/await usage, good readability
๐ Verdict
[x] REQUEST CHANGES โ Must fix critical issues
Two P0 security issues (SQL injection + missing auth) must be resolved before merge.
### Severity Rules
| Tag | Meaning | Merge Impact |
|---|---|---|
| ๐จ **MUST FIX** | Bugs, security holes, data loss risk | **Blocks merge** |
| โ ๏ธ **SHOULD FIX** | Performance, maintainability, missing tests | Strongly recommended |
| ๐ก **SUGGESTION** | Style, naming, better practices | Non-blocking |
### Strict Mode (`--strict`)
When `--strict` is enabled:
- Missing tests โ **MUST FIX** (normally SHOULD FIX)
- Any `any` type usage โ **SHOULD FIX**
- Missing error handling โ **MUST FIX**
- Complex logic without comments โ **SHOULD FIX**
---
## Webhook Integration (OpenClaw)
The `index.ts` webhook server enables **automatic PR review** โ every PR opened or updated gets reviewed without manual invocation.
### Architecture
```mermaid
sequenceDiagram
participant GH as GitHub
participant WH as index.ts (Webhook)
participant AI as Anthropic API
participant PR as PR Comments
GH->>WH: PR opened/synchronize/reopened
WH->>WH: Verify webhook signature (HMAC-SHA256)
WH-->>GH: 202 Accepted
WH->>GH: Fetch PR files + diff
WH->>WH: Filter reviewable files
WH->>WH: Chunk large diffs (500KB limit)
loop Each chunk
WH->>AI: Send review prompt
AI->>WH: Structured review
end
WH->>WH: Merge chunk results + extract verdict
WH->>PR: Post review (APPROVE / REQUEST_CHANGES / COMMENT)
Setup
1. Start the webhook server:
export GITHUB_TOKEN="ghp_..."
export GITHUB_WEBHOOK_SECRET="your-webhook-secret"
export ANTHROPIC_API_KEY="sk-ant-..."
export REVIEW_MODEL="claude-sonnet-4-20250514" # optional
export PORT=3000 # optional
npm install hono @hono/node-server
npx tsx index.ts
2. Configure GitHub repository:
- Go to Settings โ Webhooks โ Add webhook
- Payload URL:
https://your-server:3000/webhook/github - Content type:
application/json - Secret: same as
GITHUB_WEBHOOK_SECRET - Events: select Pull requests
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
GITHUB_TOKEN | Yes | โ | GitHub token with repo scope |
GITHUB_WEBHOOK_SECRET | Yes | โ | Webhook signature secret |
ANTHROPIC_API_KEY | Yes | โ | Anthropic API key |
REVIEW_MODEL | No | claude-sonnet-4-20250514 | Model for review |
PORT | No | 3000 | Server port |
MAX_DIFF_SIZE | No | 512000 (500KB) | Max diff chunk size in bytes |
REVIEW_LANGUAGE | No | zh | Output language (zh/en) |
REVIEW_MAX_TOKENS | No | 4096 | Max tokens per review chunk |
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /health | Health check |
POST | /webhook/github | GitHub webhook receiver |
Supported Languages
| Language | Specific Checks |
|---|---|
| TypeScript / JavaScript | any abuse, unhandled Promise rejections, React useEffect dependency arrays, stale closures, ESM/CJS mixing |
| Python | Mutable default arguments, bare except:, missing context managers, GIL concurrency traps, type annotation consistency |
| Go | Unchecked errors, goroutine leaks, interface pollution, concurrent slice/map access, defer in loops |
| Rust | Unnecessary .clone(), unwrap()/expect() in non-test code, lifetime annotations, unnecessary unsafe, Error type design |
| All languages | Hardcoded config, missing observability, inconsistent error handling, stale comments |
vs GitHub Copilot Code Review
| Dimension | Copilot Code Review | Smart PR Review |
|---|---|---|
| Personality | Neutral, suggestive | Opinionated, decisive |
| Will say "this is wrong" | No | Yes |
| Review depth | Line-level | 6-layer (logic โ architecture) |
| Direction check | No | Flags wrong approaches in Summary |
| Devil's Advocate | No | 5-question stress test |
| Output format | Inline suggestions | Structured report with severity |
| Severity discipline | Flat | MUST FIX / SHOULD FIX / SUGGESTION |
| Merge verdict | No explicit verdict | APPROVE / REQUEST_CHANGES / COMMENT |
| Replacement code | Sometimes | Always for MUST FIX |
| Large PR handling | Per-file | Automatic chunking with merge |
| Anti-pattern library | Built-in rules | Extensible references/ knowledge base |
| Self-hosted webhook | No (GitHub native) | Yes (index.ts) |
| Customizable focus | No | --focus=security|performance|logic |
| Strict mode | No | --strict raises severity thresholds |
Architecture
Smart PR Review operates in two complementary modes:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Smart PR Review โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ CLI Mode โ Webhook Mode โ
โ (SKILL.md) โ (index.ts) โ
โโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โข Manual invocation โ โข Auto on PR events โ
โ โข /review command โ โข Hono HTTP server โ
โ โข Full project โ โข Diff-only context โ
โ context access โ โข Anthropic API direct โ
โ โข Claude Code tools โ โข GitHub Review API โ
โ โข Terminal output โ โข Async processing โ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Shared Knowledge Base โ
โ references/review-checklist.md โ per-language checksโ
โ references/anti-patterns.md โ pattern library โ
โ references/review-examples.md โ output templates โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Recommended workflow: Use webhook mode for automatic first-pass review on every PR, then use CLI mode for deep-dive reviews on critical changes.
Contributing
- Fork this repository
- Add checks to
references/review-checklist.mdfor new patterns - Add anti-patterns to
references/anti-patterns.md - Submit a PR (and yes, it will be reviewed by Smart PR Review ๐)
License
ไธญๆ่ฏดๆ
็ฎไป
Smart PR Review ๆฏไธไธชๆ็ซๅบ็ AI ไปฃ็ ๅฎกๆฅๅทฅๅ ท โ ๅฎไธๆฏๆ ่็นๅคด็ๆฉก็ฎๅพ็ซ ๏ผ่ๆฏๅไธไธชๆ 10 ๅนด็ป้ช็ Staff Engineer ้ฃๆ ทๅฎกๆฅไฝ ็ไปฃ็ ใ
ๆ ธๅฟๅทฎๅผ
- ็ด่จไธ่ฎณ๏ผๅ็ฐ้ฎ้ข็ดๆฅ่ฏด"่ฟไธชๆนๆกๆ้ฎ้ข"๏ผไธ่ฏด"่ฟไนๆฏไธ็งๆนๅผ"
- ๆๅคๆญๅ๏ผ่ฝๅบๅ"ๅฟ ้กปไฟฎ"ๅ"ๅปบ่ฎฎๆน"๏ผไธๆๆๆ้ฎ้ข้ฝๅไธบ nit
- ็ปๆนๆก๏ผๆฏไธช MUST FIX ้ฝ้ๅธฆๅฏๆง่ก็ๆฟไปฃไปฃ็
- ไธปๅจๅๅฏน๏ผๅณไฝฟไปฃ็ ็่ตทๆฅๆฒก้ฎ้ข๏ผไนไผๅผบๅถ่ฟ่ก 5 ไธช็ปดๅบฆ็ๅๅๆต่ฏ
6 ๅฑๅฎกๆฅ็ปดๅบฆ
- ๐ง ้ป่พๆญฃ็กฎๆง โ ๆงๅถๆตใ็ถๆๅๆดใๅนถๅ็ซๆใ็ฑปๅๅฎๅ จ
- ๐ฒ ่พน็ๆกไปถ โ ็ฉบๅผใ็ฉบ้ๅใๆฐๅผๆบขๅบใUnicodeใๆถๅบ
- โก ๆง่ฝๅฝฑๅ โ N+1 ๆฅ่ฏขใๅ ๅญๆณๆผใ็ฎๆณๅคๆๅบฆใ็ผบๅฐ็ผๅญ
- ๐ ๅฎๅ จ้ฃ้ฉ โ ๆณจๅ ฅๆปๅปใ็กฌ็ผ็ ๅฏ้ฅใCSRF/SSRFใ่ทฏๅพ้ๅ
- ๐ง ๅฏ็ปดๆคๆง โ ๅฝๅใๅฝๆฐ่ฎพ่ฎกใ่ฟๅบฆๅทฅ็จๅใๆต่ฏ่ฆ็
- ๐๏ธ ๆถๆไธ่ดๆง โ ๆจกๅผไธ่ดๆงใAPI ่ฎพ่ฎกใๅๅๅ ผๅฎนใๆจกๅ่พน็
ไฝฟ็จๆนๅผ
# ๅฎกๆฅ GitHub PR
/review https://github.com/owner/repo/pull/123
# ๅฎกๆฅๆฌๅฐๅๆด
/review --diff
# ๅฎกๆฅ็นๅฎ commit
/review --commit=abc1234
# ่็ฆๅฎๅ
จๅฎกๆฅ + ไธฅๆ ผๆจกๅผ
/review https://github.com/owner/repo/pull/123 --focus=security --strict
# ่ฑๆ่พๅบ
/review --diff --lang=en
ๅๆจกๅผๆถๆ
- CLI ๆจกๅผ๏ผSKILL.md๏ผโ ๆๅจ่ฐ็จ
/review๏ผๅฏ่ฎฟ้ฎๅฎๆด้กน็ฎไธไธๆ๏ผ้ๅๆทฑๅบฆๅฎกๆฅ - Webhook ๆจกๅผ๏ผindex.ts๏ผโ GitHub PR ไบไปถ่ชๅจ่งฆๅ๏ผไป ๅบไบ diff ๅฎกๆฅ๏ผ้ๅ CI/CD ้ๆ
ๆจ่ๆญ้ ไฝฟ็จ๏ผWebhook ่ชๅจๆ่ทๆฏไธช PR ๅๅๆญฅๅฎกๆฅ๏ผๅผๅ่ ๅฏน้่ฆ PR ๅ็จ CLI ๅๆทฑๅบฆๅฎกๆฅใ