Capafy
Loslegen
AI Code Review — Catch Bugs Before You Merge

AI Code Review — Catch Bugs Before You Merge

US$5, one-time purchase. Review a diff or pull request for real bugs before merge: four reviewer lenses (one model applying each in turn) check each other and tag findings CONFIRMED, CORROBORATED or DISPUTED. #Ingenieurwesen

Rating
Weitere Bewertungen erforderlich
Sold
0
How to use
Herunterladen

You paste: a diff, pull request or code change.

You get: findings from four review lenses (security, reliability, maintainability, performance), each tagged CONFIRMED / CORROBORATED / DISPUTED, and one merge recommendation line.

How it works

Reviews pasted code changes with a three-phase board process. Phase 1: four reviewer lenses (security, reliability, maintainability, performance) review one at a time. Phase 2: each lens challenges or corroborates the other lenses' findings to cut false positives. Phase 3: one verdict tags every finding CONFIRMED, CORROBORATED or DISPUTED and ends with a merge recommendation. Disputed items appear with the challenge beside them. Secrets or PII found in the diff are flagged by file/line without echoing the value. It does not run code, set up CI, or review from memory: if no diff is provided it asks for one. The lenses are roles applied by one model (or by sub-agents if your agent supports them), so the cross-checks are self-checks; spot-check the findings.

Sample output

Sample input:

Use the Code Review Board on this (a sample I wrote). Please tell me if it is safe
to merge.

PR "Add webhook for order refunds" (fictional shop backend, Python/Flask):

--- a/app/refunds.py
+++ b/app/refunds.py
@@ -0,0 +1,20 @@
+import os, requests
+from flask import request, jsonify
+from app import app, db
+
+API_KEY = "demo_key_do_not_use_123"
+
[email protected]("/webhook/refund", methods=["POST"])
+def refund_webhook():
+    data = request.get_json()
+    order_id = data["order_id"]
+    order = db.execute(f"SELECT * FROM orders WHERE id = '{order_id}'").fetchone()
+    amount = order["total"]
+    r = requests.post("https://payments.example.com/refund",
+                      json={"order": order_id, "amount": amount},
+                      headers={"Authorization": API_KEY})
+    db.execute(f"UPDATE orders SET status='refunded' WHERE id='{order_id}'")
+    for item in db.execute("SELECT * FROM items WHERE order_id = ?", (order_id,)):
+        stock = db.execute("SELECT qty FROM stock WHERE sku = ?",
(item["sku"],)).fetchone()
+        db.execute("UPDATE stock SET qty = ? WHERE sku = ?", (stock["qty"] +
item["qty"], item["sku"]))
+    return jsonify(ok=True)

Real, unedited output:

## Phase 1 — Lens findings
Mode: one lens at a time (each lens finished before the next began)

### 🔒 Security Skeptic
- **S1. No authentication on the webhook** (`refund_webhook`, line 8). No signature
  check, shared secret, or IP allowlist. Anyone who finds `/webhook/refund` can POST
  `{"order_id": "<any id>"}` and trigger a real refund and a restock for any order.
- **S2. SQL injection via `order_id`** (lines 11 and 16, f-string queries). A
  payload like `x' OR '1'='1` on the UPDATE marks every order refunded; the SELECT
  can be abused to probe other data.
- **S3. Hardcoded payment credential** (line 5). It sits in source, so it ends up in
  forks, CI logs and backups. The value is not repeated here. `os` is already
  imported, so an env-var lookup was probably intended.
- **S4. No input validation.** `order_id` can be any JSON type or empty; nothing
  constrains it before it reaches SQL and the payment API.

### ⚙️ Reliability Realist
- **R1. Not idempotent.** Nothing checks whether the order is already refunded.
  Webhook senders retry routinely, so a duplicate delivery means a double refund and
  a double restock.
- **R2. Payment response ignored** (`r`, lines 13-15). On a 4xx/5xx the order is
  still marked refunded and stock is still returned.
- **R3. No timeout on `requests.post`.** If the payment host hangs, the worker hangs
  with it.
- **R4. Ordinary bad input crashes with a 500:** `get_json()` returning `None` (line
  10 `TypeError`), missing `order_id` (`KeyError`), unknown order (`order` is
  `None`, line 12 `TypeError`), SKU missing from `stock` (line 19 `TypeError`,
  mid-loop).
- **R5. Side effects are ordered unsafely.** The external refund (line 13) happens
  before any local record exists. If the process dies after the POST, nothing marks
  the order as pending, so a retry refunds again.
- **R6. Lost-update race on stock** (lines 18-19). Read-modify-write in Python means
  two concurrent refunds, or a refund racing a sale, overwrite each other.
- **R7. No `db.commit()` visible** in the handler, so the status and stock updates
  may never persist.

### 🧹 Maintainability Pragmatist
- **M1. Inconsistent query style.** f-strings (lines 11, 16) sit next to
  parameterized queries (lines 17-19) in one function; the next editor will copy
  whichever they see first.
- **M2. Dead code that signals unfinished intent:** `os` is imported but unused, and
  `r` is assigned but never read.
- **M3. Everything is in the route handler** (parsing, lookup, payment call, state
  change, inventory), so none of it can be tested without Flask and a live payment
  endpoint.
- **M4. Always returns `ok=True`, bare `'refunded'` literal, and `SELECT *`** with
  column access by name. A caller or log reader cannot tell what happened, and a
  schema change breaks it silently.

### 🚀 Performance Pessimist
- **P1. N+1 queries in the restock loop.** Each item costs a SELECT plus an UPDATE,
  so a 50-line order is about 100 round trips; one `UPDATE stock SET qty = qty + ?
  WHERE sku = ?` per item does the same work.
- **P2. Blocking outbound HTTP call on the request thread with no timeout** (same
  root cause as R3). A slow provider ties up Flask workers.

## Phase 2 — Cross-examination
- [S1 no auth] Challenge: none, nothing in the diff verifies the caller.
  Corroborated by Reliability: "A forged or replayed request behaves like a
  duplicate delivery; with R1 an attacker can refund one order repeatedly."
- [S2 SQL injection] Challenge: none, `order_id` goes straight from JSON into an
  f-string. Corroborated by Reliability: "Even benign IDs containing `'` break the
  query." Corroborated by Maintainability (M1 is the root cause).
- [S3 hardcoded credential] Challenge from Maintainability: "The value is named as a
  demo placeholder, so it is not a live leak in this sample." Rebuttal from
  Security: "The pattern is the bug; the real key lands on the same line." The
  challenge lowers severity for this value only. Corroborated by Maintainability
  (M2: the unused `os` import points to the intended env-var fix).
- [S4 input validation] Challenge: none. Corroborated by Reliability (R4: wrong
  types and missing fields crash the handler).
- [R1 idempotency] Challenge: none, there is no status check anywhere. Corroborated
  by Security: "It turns S1 into repeatable theft."
- [R2 payment response ignored] Challenge: none. Corroborated by Security: "The
  record claims money moved when it did not, which poisons fraud and dispute
  investigations." Corroborated by Maintainability (M2: `r` is unused; M4: always
  `ok=True`).
- [R3 / P2 no timeout] Flagged independently by Reliability and Performance.
  Challenge: none.
- [R4 crashes on bad input] Corroborated by Security (S4) and Maintainability (M4:
  every failure looks the same to the caller). Challenge: none.
- [R5 side-effect ordering] Challenge from Maintainability: "`db` is not shown and
  may wrap the handler in a transaction." Rebuttal from Reliability: "The external
  refund cannot be rolled back by any DB transaction." The challenge only touches
  the DB part, which is covered under R7. Corroboration from other lenses: none.
- [R6 stock race] Corroborated by Performance: "The atomic `qty = qty + ?` fix for
  P1 also removes the race." Challenge: none.
- [P1 N+1] Challenge from Reliability: "Orders usually have few items, so impact is
  low." That argues severity, not correctness, so the finding stands. Corroborated
  by Reliability (R6 shares the same fix).
- [R7 missing `db.commit()`] Challenge from Maintainability: "`db` comes from `app`
  and is not in the diff; it may autocommit or commit in a teardown hook." Challenge
  from Security: none. This is a concrete reason for doubt.
- [M3, M4] No challenges and no cross-lens corroboration beyond what is noted above.
  These are testability and clarity issues.

## Phase 3 — Board verdict
1. **[CORROBORATED]** SQL injection through f-string queries (lines 11, 16). Fix:
   parameterized `?` placeholders as on lines 17-19, and validate `order_id` format
   first.
2. **[CORROBORATED]** Unauthenticated webhook (line 8). Fix: verify an HMAC
   signature header from the payment provider with `hmac.compare_digest` and reject
   otherwise.
3. **[CORROBORATED]** Not idempotent; duplicate or replayed deliveries double-refund
   and double-restock. Fix: `UPDATE orders SET status='refunding' WHERE id=? AND
   status='paid'` and proceed only if `rowcount == 1`; also send an idempotency key
   to the payment API.
4. **[CORROBORATED]** Payment API result ignored; the order is marked refunded even
   if the refund failed (lines 13-16). Fix: `r.raise_for_status()` or check the
   body, and only update status and stock on confirmed success.
5. **[CORROBORATED]** No timeout on the outbound call (R3/P2). Fix:
   `requests.post(..., timeout=(3, 10))` and handle `requests.RequestException`.
6. **[CORROBORATED]** Missing input validation and crashes on bad or missing data
   (S4/R4). Fix: 400 on missing or invalid JSON or `order_id`, 404 on unknown order,
   explicit handling of a missing stock row.
7. **[CORROBORATED]** Hardcoded API credential (line 5). Fix:
   `os.environ["PAYMENTS_API_KEY"]`. The value is a placeholder here and
   Maintainability's severity challenge is noted, but the pattern must not ship.
8. **[CORROBORATED]** Stock lost-update race plus N+1 queries (R6/P1). Fix: `UPDATE
   stock SET qty = qty + ? WHERE sku = ?`, which is atomic and removes the SELECT.
9. **[CONFIRMED]** Refund fires before any local record exists (R5). Fix: record a
   `refunding` state before the external call so a crash is recoverable and
   reconcilable.
10. **[CONFIRMED]** Handler does everything, always returns `ok=True`, uses `SELECT
    *` and a bare status literal (M3/M4, low priority). Fix: extract a
    `process_refund(order_id)` function, use named constants and explicit columns,
    return meaningful status codes.
11. **[DISPUTED]** Missing `db.commit()` / transaction scope (R7) — challenge: "`db`
    is not in the diff and may autocommit or commit on teardown." Human judgment
    call: check `app/__init__.py`.

**Merge recommendation:** Block merge — 8 CORROBORATED findings, including two
independently exploitable security issues (unauthenticated refund trigger and SQL
injection) that together let anyone refund arbitrary orders repeatedly. Fix items
1-6 at minimum before re-review.

Handling secrets and PII in the diff

If the diff you're given contains real secrets, API keys, tokens, or customer PII, treat that as
a Security Skeptic finding in its own right (flag it), and do not echo the actual secret value
back verbatim in your output — reference it by file/line only. This Skill sends the diff you
paste as-is to the model; redact anything genuinely sensitive before pasting if you can.

Use cases

  • Get a structured second pass on a PR before merging, without setting up a CI pipeline
  • Push back on "looks good overall" reviews by asking for a concrete failure scenario with each finding
  • Built for Claude Code; other agents that read SKILL.md files (such as Codex CLI or OpenClaw) should also work. No network access or extra tools needed. Paste a diff and go.

FAQ

Does this replace static analysis tools (linters, SAST)? No — it's a reasoning-based review layer, not a substitute for running your existing linter/type-checker/test suite.

What if my diff contains secrets or real customer data? Redact them before pasting. The Skill treats any secret it spots as a Security finding, but it has no server and does not collect your code itself; whatever you paste is sent as-is to your agent's model, and your agent or model provider may retain it under its own policy.

The four lenses are roles applied by one model (or by sub-agents if your agent supports them), so the cross-checks are self-checks; spot-check the findings.

Anthropic, OpenAI and OpenClaw are trademarks of their respective owners. This Skill is an independent product and is not affiliated with, endorsed by, or sponsored by any of them.