Skip to content
←INDEX / Prompt library
TUTORIAL/Claude Code / Codex/Intermediate

Codex Rigorous Diff Reviewer: Correctness, Simplification, and Security in Three Tracks

Has Codex do a disciplined code review of your git diff across three tracks (correctness bugs / simplification-and-reuse / security), listing each finding with a confidence level and a pastable fix, and explicitly instructed to say so when nothing's wrong instead of manufacturing complaints.

SakuyaPromptCraft editor · Updated 2026-06-08
TutorialClaude Code / CodexIntermediate
01PROMPT
You are reviewing the current uncommitted change in this repository. Be a rigorous, skeptical reviewer — but only flag things you can defend. Do NOT invent problems to look useful.

## Step 0 — Gather the diff yourself
Run `git diff {{BASE_REF}}` (default to `git diff HEAD` if no base is given) and, if helpful, `git diff {{BASE_REF}} --stat`. Read the FULL surrounding context of each changed file, not just the hunk — open the file and read the functions the change touches and their callers. If an AGENTS.md / CLAUDE.md exists, read it for project conventions before judging style.

## Step 1 — Review on three independent tracks
Go through the diff three separate times, one lens each:

**Track A — Correctness (highest priority).** Logic errors, off-by-one, wrong operator, inverted condition, null/undefined/None deref, unhandled error path, async/await or promise misuse, race conditions, resource leaks (unclosed handles/connections), incorrect edge-case handling (empty input, zero, negative, very large), broken invariants, wrong type coercion. For each: explain the concrete input/scenario that triggers the bug.

**Track B — Simplification & reuse.** Duplicated logic that already exists elsewhere in the repo (search to confirm before claiming it), dead code, needless abstraction, a stdlib/existing-helper call that replaces hand-rolled code, over-broad scope, complex expression that has a clearer equivalent. Only suggest if it's a genuine, net simplification — not a lateral rewrite to your taste.

**Track C — Security.** Injection (SQL/command/template), missing input validation on a trust boundary, secrets/keys/tokens committed or logged, authz/authn check missing on a sensitive path, unsafe deserialization, SSRF/path-traversal, unparameterized queries, sensitive data in error messages. Flag only real, reachable issues in THIS diff.

## Step 2 — Output format
For each finding, output exactly:

```
[TRACK A/B/C] [CONFIDENCE: high/medium/low] file:line
What: <one-line description>
Why it matters: <the concrete failing scenario or risk>
Fix: <a minimal, ready-to-paste code suggestion or diff>
```

Order findings by track (A → B → C), then by confidence (high first). At the end, give a 2-3 line VERDICT: is this safe to merge, merge-after-fixes, or needs-rework — and the single most important thing to address.

## Hard rules
- If a track has no real issues, write `Track X: no issues found` and move on. Empty is a valid, good result.
- Never mark a guess as `high` confidence. Use `low` when you couldn't fully verify (e.g. behavior depends on code you couldn't read).
- Do NOT rewrite the whole file or restyle code that works. Scope = the diff.
- Cite real `file:line`. Do not fabricate line numbers — read the file to get them right.
- Focus on {{FOCUS_AREAS}} if specified; otherwise weight Track A heaviest.

Swap the variables inside the [ ] brackets for your own content, then paste into Claude Code / Codex.

◆ Open in toolClaude (paste it)
RUNTRY IT
▶ TRY IT ON-SITE

See what this prompt actually produces without leaving the site (live AI run, 1 credit).

SKILLINSTALL AS SKILL
INSTALL AS SKILLClaude Code Agent Skill

Don't just copy-paste — download and drop it at ~/.claude/skills/rigorous-diff-review/SKILL.md and every future session can use it automatically.

macOS / Linux
mkdir -p ~/.claude/skills/rigorous-diff-review && mv ~/Downloads/SKILL.md ~/.claude/skills/rigorous-diff-review/SKILL.md
Windows PowerShell
New-Item -ItemType Directory -Force "$env:USERPROFILE\.claude\skills\rigorous-diff-review" | Out-Null; Move-Item "$env:USERPROFILE\Downloads\SKILL.md" "$env:USERPROFILE\.claude\skills\rigorous-diff-review\SKILL.md"
02CONTEXT / Why it works

When to use it: before submitting a PR, or before asking someone to review it, to have Codex pass over it first and save the reviewer's time. Why it works: (1) it forces Codex to first run `git diff` to get the real diff (not comment on thin air), (2) running three tracks separately prevents it from 'only looking at correctness and missing security,' (3) confidence levels plus pastable patches let you quickly accept or reject findings, (4) explicitly permitting 'say so if nothing's wrong' breaks AI's habit of manufacturing findings out of nowhere just to have something to say. Technique: in Codex CLI, run `codex exec --sandbox read-only "<paste this prompt>"` for the safest read-only review; leave {{FOCUS_AREAS}} blank and it defaults to correctness, or fill in 'concurrency safety' or 'SQL injection' to focus it. In Claude Code, just paste it straight into the conversation.

03SAMPLE / Expected result

[TRACK A] [CONFIDENCE: high] src/cart.ts:42 What: applyDiscount 在 items 為空陣列時回傳 NaN Why it matters: 空購物車結帳會把 NaN 寫進訂單金額,下游付款端會拋錯 Fix: const subtotal = items.reduce((a, i) => a + i.price, 0); if (items.length === 0) return 0; [TRACK B] [CONFIDENCE: medium] src/cart.ts:55 What: 手寫的 round-to-2 與既有 utils/money.ts 的 toCents() 重複 Why it matters: 兩套四捨五入邏輯會在邊界分歧(0.005) Fix: import { toCents } from '../utils/money' Track C: no issues found VERDICT: merge-after-fixes。先修 src/cart.ts:42 的空陣列 NaN,這會直接影響結帳。

A description of the intended result. Check this entry's testing notes and try the prompt with your own inputs.

04VARIABLES
01[BASE_REF]

要 diff 的基準(如 main、HEAD~1、某 commit hash);留空預設 HEAD(即未提交的工作區變更)

02[FOCUS_AREAS]

想特別聚焦的面向(如「並發與資源洩漏」「輸入驗證」),留空則以正確性為主

05RESOLVER · 變數代入器0 / 2

填下面的欄位,上方 prompt 會即時替換 [方括號] 內容。填好後按「複製組好的 prompt」直接丟進工具。

修飾
Assembled · 填剩餘變數…
You are reviewing the current uncommitted change in this repository. Be a rigorous, skeptical reviewer — but only flag things you can defend. Do NOT invent problems to look useful.

## Step 0 — Gather the diff yourself
Run `git diff {{BASE_REF}}` (default to `git diff HEAD` if no base is given) and, if helpful, `git diff {{BASE_REF}} --stat`. Read the FULL surrounding context of each changed file, not just the hunk — open the file and read the functions the change touches and their callers. If an AGENTS.md / CLAUDE.md exists, read it for project conventions before judging style.

## Step 1 — Review on three independent tracks
Go through the diff three separate times, one lens each:

**Track A — Correctness (highest priority).** Logic errors, off-by-one, wrong operator, inverted condition, null/undefined/None deref, unhandled error path, async/await or promise misuse, race conditions, resource leaks (unclosed handles/connections), incorrect edge-case handling (empty input, zero, negative, very large), broken invariants, wrong type coercion. For each: explain the concrete input/scenario that triggers the bug.

**Track B — Simplification & reuse.** Duplicated logic that already exists elsewhere in the repo (search to confirm before claiming it), dead code, needless abstraction, a stdlib/existing-helper call that replaces hand-rolled code, over-broad scope, complex expression that has a clearer equivalent. Only suggest if it's a genuine, net simplification — not a lateral rewrite to your taste.

**Track C — Security.** Injection (SQL/command/template), missing input validation on a trust boundary, secrets/keys/tokens committed or logged, authz/authn check missing on a sensitive path, unsafe deserialization, SSRF/path-traversal, unparameterized queries, sensitive data in error messages. Flag only real, reachable issues in THIS diff.

## Step 2 — Output format
For each finding, output exactly:

```
[TRACK A/B/C] [CONFIDENCE: high/medium/low] file:line
What: <one-line description>
Why it matters: <the concrete failing scenario or risk>
Fix: <a minimal, ready-to-paste code suggestion or diff>
```

Order findings by track (A → B → C), then by confidence (high first). At the end, give a 2-3 line VERDICT: is this safe to merge, merge-after-fixes, or needs-rework — and the single most important thing to address.

## Hard rules
- If a track has no real issues, write `Track X: no issues found` and move on. Empty is a valid, good result.
- Never mark a guess as `high` confidence. Use `low` when you couldn't fully verify (e.g. behavior depends on code you couldn't read).
- Do NOT rewrite the whole file or restyle code that works. Scope = the diff.
- Cite real `file:line`. Do not fabricate line numbers — read the file to get them right.
- Focus on {{FOCUS_AREAS}} if specified; otherwise weight Track A heaviest.
RELATED
PRO01
TUTORIALSuno v5.5FEATURED
r/SunoAI (anonymous studio engineer)2026-06-12

Suno Engineer's Mindset: 4 Steps to a Song That Doesn't Sound Like AI

5.0(1)

A studio engineer's breakdown of Suno's fatal weaknesses (fried vocals, high-frequency artifacts), plus a 4-step DAW workflow and a Suno Studio cleanup prompt.

Advanced
Read

Free02
TUTORIALClaude 4.5 SonnetFEATURED
r/ClaudeAI2026-05-14

5 Claude Weekly Workflows That Stuck After 6 Months

Proposal generator / meeting processor / content repurposer / Friday review / shutdown reset — out of 40 I tried, only these 5 survived, each saving 30+ minutes per run.

Intermediate
Read

PRO03
TUTORIALClaude 4.5 SonnetFEATURED
r/PromptEngineering2026-05-14

7 Cross-Model A/B-Tested Prompt Techniques (Not Vibes)

Written after six months of A/B testing 200+ prompts on Claude, GPT-4, and Gemini with human raters. Covers persona + constraint stacking, anti-examples, role-reversal QA, cognitive scaffolds, emotional priming, uncertainty CoT, and steelman-first.

Advanced
Read

Free04
TUTORIALChatGPTFEATURED
r/ChatGPTPromptGenius2026-05-14

5 trust-checking one-liner prompts (no role-play)

After a year of role-play system prompts and 14-step frameworks, here's the takeaway: the thing that actually moved the needle on quality was 5 one-line prompts. No roles, no markdown, no "you are an expert."

Beginner
Read

COMMENTS · 討論區0 則
登入 後可留言。還沒帳號?註冊
目前沒有留言。第一個說說你的經驗。