# Code Review Gate for AI-Written Code: 120+ Scripted Checks

> Turn a git diff and its PR description into a scored MERGE / FIX FIRST / BLOCK review: 120+ deterministic checks for secrets, auth gaps, injection, RLS, migrations, swallowed errors, tests and breaking changes, claim verification, and SARIF for GitHub.

Code Review Gate for AI-Written Code: 120+ Scripted Checks is a paid AI agent skill on Agensi by Duncan Bentley, in Code Quality & Review. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $14 (one-time purchase)
- Creator: [Duncan Bentley](https://www.agensi.io/creators/duncan-bentley)
- Category: [Code Quality & Review](https://www.agensi.io/skills/code-quality-review)
- Version: 1.0
- Last updated: 2026-10-11
- Security: scan passed (2026-10-11); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/code-review-gate-for-ai-written-code-120-scripted-checks
- Tags: code-review, security, testing, python, github-actions, pull-request, pr-review, security-scan

## About this skill

Your agent reviews its own code the way a senior engineer would: with evidence, not vibes.

Every other review skill hands your agent a checklist and hopes. This one ships the tooling: tell your agent *"review this PR before I merge"* and it runs 120+ deterministic checks on the diff, verifies every claim in the PR description against what the code actually does, scores the change 0-100, gives a MERGE / FIX FIRST / BLOCK verdict, and writes a review you can paste straight into the pull request. Then SKILL.md walks it through the judgement pass no script can do: intent vs implementation, edge cases, concurrency, money, rollout order.

On the bundled sample PR (a Next.js + Supabase + Stripe app, written by a coding agent whose description promises validation, error handling, tests and no breaking changes) the gate returns **0/100 BLOCK** with 12 critical findings and 5 of 6 claims unsupported or contradicted. The fixed version of the same PR scores **97/100 MERGE**, with 62 findings resolved against the baseline.

### What you get

- **One command, four outputs**: `review.md` (PR-comment ready), `report.html` (printable: score ring, verdict, points by category, claims table, findings with the exact line, why it matters and the fix), `review.json`, and `findings.sarif` for GitHub code scanning. Exit code 2 on BLOCK so CI can fail.
- **Claims vs diff**: "added input validation", "handles errors gracefully", "includes tests", "no breaking changes", "fixes #142", "refactor only" are each checked against evidence in the diff and reported VERIFIED / UNSUPPORTED / CONTRADICTED with the lines that prove it. A contradicted description blocks the merge.
- **Secrets that actually matter**: 40 provider patterns (AWS, Stripe live/test/webhook, OpenAI, Anthropic, GitHub, Google, Slack, SendGrid, Twilio, npm, Supabase...), private-key blocks, database URLs with passwords, committed `.env` files, Supabase `service_role` JWTs (the payload is decoded; the public anon key is not flagged), and secret-named variables behind `NEXT_PUBLIC_` / `VITE_` prefixes that end up in the browser bundle.
- **Access control**: Next.js route handlers and server actions, Express/Fastify and FastAPI/Flask mutating routes with no auth check, webhooks that never verify a signature, `.delete().eq('id', param)` without an owner check, Supabase tables created without RLS, `USING (true)` policies, `GRANT ALL TO anon`, Firebase rules open to everyone.
- **The classics, deterministically**: SQL and shell built from strings, `eval`, `dangerouslySetInnerHTML`, pickle/yaml.load, open redirects, path traversal, wildcard CORS with credentials, TLS verification off, `alg: none`, `jwt.decode` without verify, weak hashes, `Math.random()` tokens, prices taken from the client, stack traces returned to users, env vars dumped to logs.
- **What AI code leaves behind**: empty catch blocks, `except: pass`, promises never awaited, `.only`/`.skip` tests, tests without assertions, `console.log`/`print`, breakpoints, TODOs, commented-out code, merge-conflict markers, `as any`, duplicated blocks, 200-line functions, N+1 loops in `for` + `await`.
- **Change-aware checks**: exported symbols removed or re-signed (callers break at runtime), endpoint files deleted, auth / rate-limit / validation / security lines that were removed, destructive migrations (DROP, RENAME, type changes, NOT NULL without default, mass UPDATE), `latest`/`*` dependencies, `postinstall` scripts, unpinned GitHub Actions and script injection.
- **Test deltas**: 15+ lines of code and no test touched, new functions no test references, test files deleted, snapshot-only tests.
- **Baselines**: `--baseline previous/review.json` reports fixed / new / unchanged after a fix loop.
- **CI in one command**: `ci --github` prints a workflow that diffs against the base branch, uploads SARIF, comments the review on the PR and fails on BLOCK; `ci --pre-push` prints a hook. GitLab snippet in the docs.
- **Whole-repo audit** (`--full`) for the "what did the agent leave in my codebase" question.
- **Noise control**: `.reviewgate.json` (ignored paths, disabled rules, severity overrides, intentionally public routes, allow-listed test values) and `// reviewgate-ignore RG-xxx reason` on a line. Severity says impact; confidence says how sure the matcher is.

### Why it beats prompting

| Prompting a chat agent | Code Review Gate |
|---|---|
| "Looks good, a few suggestions" | 0-100 score, verdict, every finding at file:line with the snippet and the fix |
| Trusts "includes tests" in the description | Finds that the tests have no assertions and marks the claim unsupported |
| Misses the service-role key because it looks like the anon key | Decodes the JWT, sees `role: service_role`, flags it critical |
| "Consider adding error handling" | Points at the empty catch on line 41 and the stack trace returned on line 52 |
| Different answer every run | Same diff, same findings; diffable with `--baseline` |
| Nothing for CI | SARIF upload, PR comment, exit code 2 on BLOCK |

### Honest by design

The scripts produce the score and verdict; the agent's judgement findings are listed separately and may override the recommendation, and the review says when they do. Every rule cites its reference (CWE, OWASP, Supabase, Firebase, Stripe, PostgreSQL, GitHub docs) and carries a confidence level. "No findings" means the checks found nothing, not that the code is correct. This is a review aid, not a security assessment.

### What's inside

`SKILL.md` (7-step workflow, judgement pass, honesty rules, quality checklist) · 10 Python scripts (unified-diff parser, 90 line rules, secrets engine, structural checks, test deltas, claim verifier, scoring, Markdown/HTML/JSON/SARIF writers, CLI) · 6 references (every check with severity, confidence and fix; the judgement-pass method and review template; claim types; scoring; config and suppressions; CI recipes) · a sample PR in three states (before, as submitted, fixed) with diffs and descriptions · pre-built sample output.

### Requirements

An agent that can run code with Python 3.8+. Standard library only: no installs, no API keys, no network. Works on diffs from git, GitHub (`gh pr diff`), GitLab or any unified diff.

## Requires

- Python

## Known limitations

- Pattern-based: rules are practitioner heuristics with references and a confidence level, not a full static analyser or a security assessment. Expect occasional false positives (suppress with a reason) and false negatives (the judgement pass exists for those).
- Deepest coverage for JavaScript/TypeScript, Python and SQL; Go, Ruby, PHP, Java, Kotlin, C# get the language-agnostic rules (secrets, config, migrations, leftovers) plus a subset of code rules.
- Route-handler auth detection recognises common patterns (Next.js, Express/Fastify, FastAPI/Flask, Supabase, Clerk, Auth.js, JWT); unusual auth layers may need `public_routes` or a suppression.
- Claim patterns are English; a claim phrased unusually is not checked and nothing is reported for it.
- Breaking-change detection compares exported symbols within the diff; it does not search call sites across other repositories.
- Does not run tests, type checkers or linters, and does not fetch dependency advisories (offline by design); combine with those in CI.
- The HTML report uses no external resources; the SARIF targets GitHub code scanning (SARIF 2.1).

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Code Review Gate for AI-Written Code: 120+ Scripted Checks skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### Isn't this what my coding agent already does when I ask for a review?

It reads and reasons; this adds what reading cannot: 120+ deterministic checks with file:line evidence, JWT decoding, claim verification against the diff, a reproducible score, SARIF for CI. The SKILL.md then makes the agent do the reading part properly too.

### How is it different from the free code-reviewer skills?

They are prompts. This ships scripts that find the same issue every time at the same line, prove or disprove the PR description, compare runs against a baseline, and plug into GitHub code scanning.

### Does it need git or GitHub?

It needs a unified diff, from anywhere (git diff, gh pr diff, GitLab, or a .diff file), plus the working tree for context. With no diff at all, --full audits a folder.

### Will it block my merges?

Only if you wire the exit code into CI. The generated workflow fails on BLOCK (critical findings, a contradicted description or 3+ high findings); you can keep it advisory by removing that step.

### What about false positives?

Every finding carries a confidence level and a rule id. Suppress a line with // reviewgate-ignore RG-xxx reason or tune .reviewgate.json; the review lists suppressions so nothing disappears silently.

### Which stacks does it understand best?

JavaScript/TypeScript (Next.js, Express, Fastify, Prisma, Supabase, Stripe), Python (FastAPI, Flask, Django, requests), SQL migrations (Postgres/Supabase), Firebase rules, Dockerfiles, GitHub Actions and package manifests.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
