Sign inGet started
–

requesting-code-review

by obra/superpowers · Coding & Development

Dispatches a code reviewer subagent with crafted context to verify completed work meets requirements before merging or proceeding.

Lift · GLM-5.3-flash+25ppdirectional · all models →
88
Trustsecurity · quality · license · upkeep
Scan Saferisk 0/100
LicenseMITserved via MCP
Claude Haiku 5.5 · GPT-6 Luna — not run yet
Pass-rate Lift+25pp95% CI [0, +75] · CI includes zero
screen tier · directionalchat harness (v2)
−100pp+100pp

Pass rate with the skill minus without, same tasks, same model.

baseline
75%
with skill
100%
forced
75%
Content Lift forced arm
0pp [0, 0]
Trigger rate
100%
Trials
12 · 4 tasks
Model
GLM-5.3-flash
Measured
2026-10-15

Content Lift = the skill's instructions injected into the system prompt, so it measures what the content does once loaded, apart from whether the agent chooses to load it. Method →

Embed this score · live badge for your README
SkillzBench badge preview

The badge shows the real benchmark number and updates itself when we re-bench — including the honest states (“did not trigger”, “not benched yet”). All badge options →

Markdown[![SkillzBench](https://skillzbench.com/api/badge/requesting-code-review.svg)](https://skillzbench.com/skills/requesting-code-review)
+ cost/task[![SkillzBench](https://skillzbench.com/api/badge/requesting-code-review.svg?cost=1)](https://skillzbench.com/skills/requesting-code-review)
HTML<a href="https://skillzbench.com/skills/requesting-code-review"><img src="https://skillzbench.com/api/badge/requesting-code-review.svg" alt="SkillzBench benchmark" height="20"></a>

A/B outputs — median trial per arm

Chat harness (v2): the agent's final message without the skill (left) vs with it (right).

requesting-code-review--m1
baseline · 0.79

Quick review — the logic is mostly right, but a few things to check:

Correctness

  • ✅ VIP → 20% off, order > $100 → 10% off, otherwise full price.
  • ✅ price > 100 correctly excludes exactly $100 ("over $100").
  • ⚠️ VIP + large order: a VIP with a $200 order gets 20% only, not a stacked 20% + 10%. If stacking is intended, this is a bug; if VIP rate replaces the order discount, you're fine — but worth a comment or test to lock in the intent.
  • ⚠️ "Never negative": the discount result can't go negative, but a negative input (price = -50) returns -50. If callers can pass bad data, add a guard: if price < 0: raise ValueError(...) (or clamp to 0).

Style / robustness

  • Consider type hints: def discount(price: float, is_vip: bool) -> float:
  • Magic numbers 0.8 / 0.9 — fine at this size, but named constants (VIP_DISCOUNT = 0.20) read better and match how the requirement was written.

Suggested version

VIP_RATE = 0.20
BULK_RATE = 0.10
BULK_THRESHOLD = 100

def discount(price: float, is_vip: bool) -> float:
    if price < 0:
        raise ValueError("price must be non-negative")
    if is_vip:
        return price * (1 - VIP_RATE)
    if price > BULK_THRESHOLD:
        return price * (1 - BULK_RATE)
    return price

Tests worth adding before merge: exactly $100 (no discount), $100.01, VIP under $100, VIP over $100, negative price.

Nothing blocking — just confirm the VIP-stacking intent and the negative-input behavior.

with skill · 1.00

I don't have git/SHAs available in this session, so here's a direct review of the snippet:

Requirements check:

  • ✅ 20% off for VIP — price * 0.8
  • ✅ 10% off over $100 — price * 0.9
  • ✅ Never negative — discounts are multiplicative on non-negative input, so output can't go negative

Issues:

  1. Important — VIP + over-$100 stacking ambiguity. A VIP with a $150 order gets only 20% off, not 20% + 10%. If requirements intend VIP to always get at least 20%, this is fine — but confirm. If they should stack, this is a bug.

  2. Important — no input validation. Negative or non-numeric price returns garbage (e.g., discount(-50, False) → -50, violating "never negative"). Add a guard:

    if price < 0:
        raise ValueError("price must be non-negative")
    
  3. Minor — boundary semantics. price > 100 means exactly $100 gets no discount. Confirm whether "over $100" means > 100 or >= 100. Also watch for float precision (19.999999... vs 20.0) — consider Decimal or rounding to cents if this is money.

  4. Minor — magic numbers. 0.8, 0.9, 100 should be named constants (VIP_DISCOUNT = 0.20, etc.) for maintainability.

  5. Minor — no tests. At minimum: discount(150, False) == 135, discount(150, True) == 120, discount(50, False) == 50, discount(0, True) == 0, and a negative-price case.

Verdict: Logic matches the stated requirements for normal inputs; fix the negative-price guard (and confirm stacking/boundary intent) before merging.

requesting-code-review--m2
baseline · 0.57

Before merging, a few issues in that endpoint need fixing — two are merge blockers.

Blockers

  1. Race condition on uniqueness. The check-then-save isn't atomic; two concurrent requests can both pass the check and save the same email. Uniqueness must be enforced by a DB unique index on email, with the in-code check kept only as a fast path. That also requires a migration step: dedupe any existing duplicate emails before adding the constraint, or the migration fails.

  2. Mutation before validation. user.name/user.email are set on the fetched object before the uniqueness check. If db.get returns a shared/cached instance (or anything later triggers a flush), a failed validation can still persist the change. Validate first, mutate last.

Should fix before merge

  • Double lookup: db.find(email=...) runs twice — call once, store the result.
  • No normalization: emails should be lowercased/trimmed, or Foo@x.com and foo@x.com become "unique."
  • No input validation: missing form keys raise an unhandled 400; no format/length checks on name or email.
  • Email change without re-verification: if email drives password resets, an unverified change is an account-takeover vector. At minimum send a verification email on change; ideally keep the old email active until verified.

Suggested revision

EMAIL_RE = re.compile(r'^[^@\s]+@[^@\s]+\.[^@\s]+$')

@app.post('/user/update')
def update():
    name = (request.form.get('name') or '').strip()
    email = (request.form.get('email') or '').strip().lower()

    if not name or len(name) > 100:
        return jsonify(error='Invalid name'), 400
    if not EMAIL_RE.match(email):
        return jsonify(error='Invalid email'), 400

    user
with skill · 1.00

I can't dispatch a reviewer subagent in this environment, so here's a direct review of the endpoint against your three requirements:

Review: /user/update endpoint

Requirement 1 — update name/email: ✅ Works, but mutates the user before validation. If the email check fails, user.name/user.email are already changed in memory — if anything else later saves that object (or the ORM auto-flushes), you persist invalid state. Validate first, mutate last.

Requirement 2 — unique email: ⚠️ Race condition. The check-then-save pattern isn't atomic; two concurrent requests can both pass the check. Enforce a unique constraint on email in the DB and catch the integrity error. Also the double db.find(email=...) call is wasteful — fetch once.

Requirement 3 — profile page shows updated info: Not covered by this endpoint — make sure the profile page reads fresh from the DB (no stale caching) and there's a test for it.

Other issues:

  • Critical: No authentication/authorization check visible — current_user is used but nothing prevents a missing session; also no CSRF protection on a state-changing POST.
  • Important: No input validation — empty name, malformed email, or missing form fields will throw a 500 (request.form['email'] raises BadRequest at best). Validate email format and required fields.
  • Important: No email-ownership flow — changing email typically requires verification before it becomes the account identity.
  • Minor: Return JSON ({'error': 'Email taken'}) instead of a bare string for a consistent API; use 409 Conflict rather than 400 for duplicates.

Suggested revision:

@app.post('/user/update')
def update():
    name = request.form.get('name', '').strip()
    email = request.form.get('email', '').strip().lower()
    if not name or not is_valid_email(email):
        return {'error': 'Invalid input'}, 400

    user = db.get(current_user)
    existing = db.find(email=email)
    if existing and existing.id != user.id:
        return {'error': 'Email taken'}, 409

    user.name = name
    user.email = email
    try:
        db.save(user)  # email column should have a UNIQUE constraint
    except IntegrityError:
        return {'error': 'Email taken'}, 409
    return {'status': 'OK'}

Before merging, add: tests for duplicate email, invalid email, empty fields, and a test that the profile page reflects the update. Fix the race condition (unique constraint) and add auth/CSRF checks — those are blockers; the rest can be follow-ups.

requesting-code-review--m3
baseline · 1.00

Code Review: Upload Handler

Critical Issues

  1. file.content_length is client-controlled — it's read from the request headers, so an attacker can lie. A 10GB "5MB" file will be saved. Enforce size while streaming (read in chunks and abort past the limit), or check actual bytes written.

  2. Extension check is weak — endswith is case-sensitive (evil.JPG passes? no — but .jpg\n or trailing whitespace tricks vary by server). Worse, the check is on the original filename, but the saved extension comes from split('.')[-1] — a file named shell.php.jpg is fine, but shell.jpg with no dot edge cases, or filenames like x.PNG (trailing space) behave inconsistently. Normalize: lowercase, strip, and validate against a strict allowlist. Better yet, derive the extension from the validated MIME/actual content, not the client string.

  3. No content validation — a .jpg-renamed HTML/SVG/PHP file is stored as-is. If /uploads/ is web-served, this is stored-XSS / RCE territory. Verify magic bytes (e.g., with python-magic) and serve uploads from a separate domain with Content-Disposition: attachment and no execution.

High Issues

  1. file.filename can be None or contain path traversal — ../../etc/cron.d/x.jpg — the traversal doesn't hit the final name here (you build your own), but split('.')[-1] on weird names can yield empty or odd extensions. Guard: if not file.filename: return 400.

  2. file.save() can fail (disk full, bad perms) with an unhandled 500. Wrap in try/except and return a clean error.

  3. No file.seek(0) — if the file object was read earlier (e.g., for size checking), you'll save an empty file.

Medium Issues

  1. Extension from user input — you already know it's .jpg or .png from the check; hardcode the extension (name = f"{uuid.uuid4()}.jpg") instead of re-deriving it. Removes a whole class of bugs.

  2. No duplicate/collision handling — UUID4 collisions are negligible, but check os.path.exists anyway if paranoid.

  3. No logging/metrics — log rejected uploads (type, size) for abuse monitoring.

  4. Missing rate limiting / auth — not visible in this snippet, but confirm it exists at the route level; unlimited anonymous uploads to disk is a DoS vector.

Suggested Rewrite

import os, uuid

ALLOWED = {'jpg', 'jpeg', 'png'}
MAX_SIZE = 5 * 1024 * 1024

def upload(file):
    if not file.filename:
        return 'Missing file', 400
    ext = os.path.splitext(file.filename)[1].lstrip('.').lower()
    if ext not in ALLOWED:
        return 'Invalid type', 400

    name = f"{uuid.uuid4()}.{ext}"
    path = os.path.join('/uploads', name)
    size = 0
    try:
        with open(path, 'wb') as out:
            while chunk := file.stream.read(8192):
                size += len(chunk)
                if size > MAX_SIZE:
                    out.close()
                    os.remove(path)
                    return 'Too large', 400
                out.write(chunk)
    except OSError:
        try: os.remove(path)
        except OSError: pass
        return 'Storage error', 500

    # Optional: verify magic bytes here before accepting
    return 'OK'

Verdict: do not ship as-is. Items 1–3 are exploitable; the rest are hardening.

with skill · 0.79

Code Review: File Upload Handler

Verdict: Not ready to ship. Several critical and important issues.

Critical

  1. content_length is unreliable / likely wrong. Most frameworks (e.g., Werkzeug/Flask) don't populate file.content_length for streamed uploads — it's often None or 0, so the 5MB check silently passes everything. Check the size while streaming (file.seek(0, 2) / file.tell(), or enforce a MAX_CONTENT_LENGTH at the framework level). Also, a client can simply omit Content-Length and bypass any header-based check.

  2. No validation of file content, only the name. An attacker can upload any payload (PHP shell, HTML for XSS, polyglot files) named evil.jpg. Verify magic bytes (e.g., Pillow Image.open(...).verify()), and re-encode or at least reject mismatches.

  3. Extension is taken from user input. file.filename.split('.')[-1] means a file named x.JPG%00.php-style tricks or double extensions (a.jpg.png) can slip through, and case variants (.JPG, .Png) are rejected inconsistently. Whitelist the extension after normalizing case, or better, derive the extension from the verified MIME type yourself.

  4. Missing filename safety. If file.filename is None (possible with malformed multipart requests), endswith raises AttributeError → 500 error. Guard for that.

Important

  1. Path construction: /uploads/ — ensure this directory exists and is outside the web-servable document root (or served with Content-Disposition: attachment and no execution), otherwise stored HTML/SVG could be executed in-browser.

  2. Resource exhaustion: nothing limits upload rate or concurrent large streams; combine the size cap with framework-level limits (MAX_CONTENT_LENGTH) so oversized bodies are rejected before buffering.

  3. No error handling on file.save — disk full or permission errors will surface as raw 500s.

Minor

  1. Consider storing files without any user-derived extension at all (e.g., uuid4().hex), since you control serving via Content-Type.
  2. Return JSON responses consistently if this is an API; 'OK'/'Invalid type' strings are fine but a schema helps clients.
  3. Add tests: oversized file, wrong extension, missing filename, polyglot content, uppercase extensions.

Suggested sketch

import uuid
from PIL import Image

ALLOWED = {"jpg": "image/jpeg", "png": "image/png"}
MAX_SIZE = 5 * 1024 * 1024

def upload(file):
    if not file or not file.filename:
        return 'Missing file', 400
    ext = file.filename.rsplit('.', 1)[-1].lower()
    if ext not in ALLOWED:
        return 'Invalid type', 400
    file.seek(0, 2)
    if file.tell() > MAX_SIZE:
        return 'Too large', 400
    file.seek(0)
    try:
        img = Image.open(file)
        img.verify()
        if img.format not in ('JPEG', 'PNG'):
            return 'Invalid type', 400
        file.seek(0)
        name = f"{uuid.uuid4().hex}.{ext}"
        file.save(f'/uploads/{name}')
    except Exception:
        return 'Invalid or unreadable file', 400
    return 'OK', 200

Fix the critical items (size enforcement, content validation, extension handling) before shipping.

requesting-code-review--m4
baseline · 1.00

Verdict: Not mergeable. This code has a race condition — read-modify-write isn't atomic, so concurrent calls will lose updates.

Problems:

  1. temp = counter; temp += 1; counter = temp — two threads can read the same value and both write the same result, losing increments.
  2. global counter shared state with no synchronization.
  3. No return of a consistent value under concurrency.

Fix (Python):

import threading

counter = 0
_lock = threading.Lock()

def increment():
    global counter
    with _lock:
        counter += 1
        return counter

counter += 1 alone is still not atomic in Python (bytecode: LOAD, ADD, STORE), so the lock is required even for that one-liner.

Alternatives:

  • itertools.count() + lock, or queue-based serialization if you want to avoid manual locking.
  • If this maps to a web app with multiple processes, an in-process lock won't help — use the datastore's atomic op (e.g., Redis INCR, or SQL UPDATE counters SET value = value + 1 RETURNING value).

Suggested tests before merge:

  • Spawn N threads × M increments each; assert final counter == N*M.
  • Assert returned values are unique across all calls (no duplicate reads).

Approve only after the lock (or atomic primitive) is in place.

with skill · 1.00

Code Review: Counter Increment

Assessment: ❌ Not ready to merge — fails the core requirement (atomicity / no lost updates).

Critical

1. Race condition — lost updates. The read-modify-write (temp = counter; temp += 1; counter = temp) is not atomic. Two concurrent threads can both read counter = 5, both compute 6, and both write 6 — one increment is silently lost. Under load, the counter will drift below the true number of calls.

2. No synchronization mechanism. There's no lock, no atomic primitive, nothing preventing interleaving. The global statement doesn't provide any thread safety.

Fix options

Option A — lock (simplest, correct):

import threading

counter = 0
_lock = threading.Lock()

def increment():
    global counter
    with _lock:
        counter += 1
        return counter

Option B — atomic via itertools.count (lock-free, fast):

from itertools import count
_counter = count(1)

def increment():
    return next(_counter)

count.__next__ is implemented in C and is effectively atomic under the GIL.

Option C — if multi-process (e.g., multiple workers behind a web server): neither of the above works across processes. Use Redis (INCR), a database with an atomic UPDATE counter SET value = value + 1, or an atomic file/multiprocessing.Value.

Important

3. Clarify the concurrency model. "Concurrent requests" in a web app usually means multiple processes/workers, not threads. If so, Options A/B are insufficient — pick Option C. Confirm the deployment before merging.

Minor

  • temp variable is unnecessary even in the fixed version; counter += 1 is clearer.
  • Add a test that spawns many threads/processes incrementing concurrently and asserts the final count equals the number of increments — this is exactly the test the current code fails.

Recommendation: Do not merge. Apply a lock or atomic primitive, and confirm whether concurrency is intra-process (threads) or cross-process (workers) — that determines which fix is correct.

Limitations
  • Results are for the SkillzBench reference agent on GLM-5.3-flash. Switch models above — a skill can help one model and not another.
  • Screen tier (1 trial per arm) is directional. Verified needs a full-tier run (≥ 8 tasks, ≥ 3 trials per arm) with the CI excluding zero.
  • Task coverage: 4 generated tasks for this skill's category; a skill can shine elsewhere.