๐Ÿ” Smart PR Review

March 22, 2026 ยท View on GitHub

An AI code reviewer with opinions. Not a yes-machine.

GitHub stars OpenClaw Skill License: MIT TypeScript Version

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.

FeatureGitHub Copilot Code ReviewSmart PR Review
Review stanceSuggestsJudges
Says "this approach is wrong"RarelyYes, in the Summary
Review depthLine-level suggestions6-layer deep analysis
Devil's Advocate modeNoBuilt-in
Architectural reviewLimitedDedicated layer
Output formatInline commentsStructured report (paste-ready)
Security auditBasicDedicated layer with OWASP checks
Severity disciplineFlat suggestionsMUST FIX / SHOULD FIX / SUGGESTION
Webhook automationBuilt-inSelf-hosted via index.ts
Language-specific checksGenericTS/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

ParameterValuesDefaultDescription
--focussecurity, performance, logic, allallFocus on a specific review dimension
--strictflagoffLower tolerance thresholds (see Strict Mode)
--langzh, enzhOutput 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:

QuestionWhat 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:

  1. Go to Settings โ†’ Webhooks โ†’ Add webhook
  2. Payload URL: https://your-server:3000/webhook/github
  3. Content type: application/json
  4. Secret: same as GITHUB_WEBHOOK_SECRET
  5. Events: select Pull requests

Environment Variables

VariableRequiredDefaultDescription
GITHUB_TOKENYesโ€”GitHub token with repo scope
GITHUB_WEBHOOK_SECRETYesโ€”Webhook signature secret
ANTHROPIC_API_KEYYesโ€”Anthropic API key
REVIEW_MODELNoclaude-sonnet-4-20250514Model for review
PORTNo3000Server port
MAX_DIFF_SIZENo512000 (500KB)Max diff chunk size in bytes
REVIEW_LANGUAGENozhOutput language (zh/en)
REVIEW_MAX_TOKENSNo4096Max tokens per review chunk

Endpoints

MethodPathDescription
GET/healthHealth check
POST/webhook/githubGitHub webhook receiver

Supported Languages

LanguageSpecific Checks
TypeScript / JavaScriptany abuse, unhandled Promise rejections, React useEffect dependency arrays, stale closures, ESM/CJS mixing
PythonMutable default arguments, bare except:, missing context managers, GIL concurrency traps, type annotation consistency
GoUnchecked errors, goroutine leaks, interface pollution, concurrent slice/map access, defer in loops
RustUnnecessary .clone(), unwrap()/expect() in non-test code, lifetime annotations, unnecessary unsafe, Error type design
All languagesHardcoded config, missing observability, inconsistent error handling, stale comments

vs GitHub Copilot Code Review

DimensionCopilot Code ReviewSmart PR Review
PersonalityNeutral, suggestiveOpinionated, decisive
Will say "this is wrong"NoYes
Review depthLine-level6-layer (logic โ†’ architecture)
Direction checkNoFlags wrong approaches in Summary
Devil's AdvocateNo5-question stress test
Output formatInline suggestionsStructured report with severity
Severity disciplineFlatMUST FIX / SHOULD FIX / SUGGESTION
Merge verdictNo explicit verdictAPPROVE / REQUEST_CHANGES / COMMENT
Replacement codeSometimesAlways for MUST FIX
Large PR handlingPer-fileAutomatic chunking with merge
Anti-pattern libraryBuilt-in rulesExtensible references/ knowledge base
Self-hosted webhookNo (GitHub native)Yes (index.ts)
Customizable focusNo--focus=security|performance|logic
Strict modeNo--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

  1. Fork this repository
  2. Add checks to references/review-checklist.md for new patterns
  3. Add anti-patterns to references/anti-patterns.md
  4. Submit a PR (and yes, it will be reviewed by Smart PR Review ๐Ÿ˜ˆ)

License

MIT


ไธญๆ–‡่ฏดๆ˜Ž

็ฎ€ไป‹

Smart PR Review ๆ˜ฏไธ€ไธชๆœ‰็ซ‹ๅœบ็š„ AI ไปฃ็ ๅฎกๆŸฅๅทฅๅ…ท โ€” ๅฎƒไธๆ˜ฏๆ— ่„‘็‚นๅคด็š„ๆฉก็šฎๅ›พ็ซ ๏ผŒ่€Œๆ˜ฏๅƒไธ€ไธชๆœ‰ 10 ๅนด็ป้ชŒ็š„ Staff Engineer ้‚ฃๆ ทๅฎกๆŸฅไฝ ็š„ไปฃ็ ใ€‚

ๆ ธๅฟƒๅทฎๅผ‚

  • ็›ด่จ€ไธ่ฎณ๏ผšๅ‘็Žฐ้—ฎ้ข˜็›ดๆŽฅ่ฏด"่ฟ™ไธชๆ–นๆกˆๆœ‰้—ฎ้ข˜"๏ผŒไธ่ฏด"่ฟ™ไนŸๆ˜ฏไธ€็งๆ–นๅผ"
  • ๆœ‰ๅˆคๆ–ญๅŠ›๏ผš่ƒฝๅŒบๅˆ†"ๅฟ…้กปไฟฎ"ๅ’Œ"ๅปบ่ฎฎๆ”น"๏ผŒไธๆŠŠๆ‰€ๆœ‰้—ฎ้ข˜้ƒฝๅˆ—ไธบ nit
  • ็ป™ๆ–นๆกˆ๏ผšๆฏไธช MUST FIX ้ƒฝ้™„ๅธฆๅฏๆ‰ง่กŒ็š„ๆ›ฟไปฃไปฃ็ 
  • ไธปๅŠจๅๅฏน๏ผšๅณไฝฟไปฃ็ ็œ‹่ตทๆฅๆฒก้—ฎ้ข˜๏ผŒไนŸไผšๅผบๅˆถ่ฟ›่กŒ 5 ไธช็ปดๅบฆ็š„ๅŽ‹ๅŠ›ๆต‹่ฏ•

6 ๅฑ‚ๅฎกๆŸฅ็ปดๅบฆ

  1. ๐Ÿง  ้€ป่พ‘ๆญฃ็กฎๆ€ง โ€” ๆŽงๅˆถๆตใ€็Šถๆ€ๅ˜ๆ›ดใ€ๅนถๅ‘็ซžๆ€ใ€็ฑปๅž‹ๅฎ‰ๅ…จ
  2. ๐Ÿ”ฒ ่พน็•Œๆกไปถ โ€” ็ฉบๅ€ผใ€็ฉบ้›†ๅˆใ€ๆ•ฐๅ€ผๆบขๅ‡บใ€Unicodeใ€ๆ—ถๅŒบ
  3. โšก ๆ€ง่ƒฝๅฝฑๅ“ โ€” N+1 ๆŸฅ่ฏขใ€ๅ†…ๅญ˜ๆณ„ๆผใ€็ฎ—ๆณ•ๅคๆ‚ๅบฆใ€็ผบๅฐ‘็ผ“ๅญ˜
  4. ๐Ÿ”’ ๅฎ‰ๅ…จ้ฃŽ้™ฉ โ€” ๆณจๅ…ฅๆ”ปๅ‡ปใ€็กฌ็ผ–็ ๅฏ†้’ฅใ€CSRF/SSRFใ€่ทฏๅพ„้ๅކ
  5. ๐Ÿ”ง ๅฏ็ปดๆŠคๆ€ง โ€” ๅ‘ฝๅใ€ๅ‡ฝๆ•ฐ่ฎพ่ฎกใ€่ฟ‡ๅบฆๅทฅ็จ‹ๅŒ–ใ€ๆต‹่ฏ•่ฆ†็›–
  6. ๐Ÿ—๏ธ ๆžถๆž„ไธ€่‡ดๆ€ง โ€” ๆจกๅผไธ€่‡ดๆ€งใ€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 ๅšๆทฑๅบฆๅฎกๆŸฅใ€‚