Skip to content
cccskills

Test log of ponytail-audit

For each task: the request, the rubric and the score for each item, time and tokens for every run, Claude Code’s full logs, and the files it produced. The raw data is here too, so the score can be recomputed if the weighting changes.

Run on Nov 6, 2026 (runs: claude-sonnet-5-5 / judge: claude-opus-5-5). Figures are medians. The tasks were written by AI from SKILL.md, so they may lean toward situations where the skill helps.

No outputs were saved for this test.

Task 1: Quality audit of an inherited Python order tool

Request

I'm taking over this small order/invoice tool from a colleague who left. Before I touch anything, I want an honest review of the whole repo: real bugs, security problems, things that will break with how it's actually deployed (see the README), risky logic with no tests, slow spots, and code we could just delete. Put the most important problems first, and for each one tell me where it is, what goes wrong in a concrete case, and the smallest fix. Number them so I can tell you which ones to fix later. Please don't change any code yet, I only want the report.

Rubric

  1. Flags the SQL injection in app/db.py find_orders_by_customer (f-string with user-supplied customer name) as a top-priority problem and proposes parameterized queries.
  2. Identifies the password-reset weaknesses: the token is returned in the /reset/start HTTP response (anyone can reset any account) and/or is made with the non-cryptographic random module; also notes hardcoded secrets and MD5 password hashing.
  3. Finds the stock race/oversell in place_order (read stock, then write stock - qty, across 4 concurrent server copies, with two separate commits) and suggests an atomic update/transaction such as UPDATE ... SET stock = stock - ? WHERE stock >= ?; also notes zero/negative qty is not rejected.
  4. Finds the invoice bugs: invoice_lines skips the last item (range(len(items) - 1)) and the bulk discount rule differs between orders.py (qty > 10, rounded) and invoice.py (qty >= 10, unrounded), so a 10-item order is priced differently.
  5. Report is ordered by severity, findings are numbered with file locations, a concrete failing case and a small fix each, and it mentions missing tests for risky logic and deletable code (duplicate money formatters, unused legacy_csv_export, one-product factory).
  6. No source files were modified; the result is a report only.

Score per rubric item (1 = met, 0.5 = partly, 0 = not met)

#Run 1
Without skill / With skill
Run 2
Without skill / With skill
Run 3
Without skill / With skill
11 / 11 / 11 / 1
21 / 0.50.5 / 11 / 1
31 / 11 / 11 / 1
41 / 10.5 / 10 / 0
50.5 / 0.50.5 / 0.50.5 / 0.5
61 / 11 / 11 / 1
Starting files(10)

README.md

# shop-orders

Internal order and invoice tool for our shop staff (about 40 people use it during the day).

Run: `python -m app.server`

Production: 4 copies of the server run at the same time behind a load balancer, all using the same `shop.db` file on a shared disk.

Tests: `python -m unittest discover tests`

app/__init__.py

app/db.py

import sqlite3

DB_PATH = "shop.db"


def connect():
    return sqlite3.connect(DB_PATH)


def init():
    con = connect()
    con.executescript("""
    CREATE TABLE IF NOT EXISTS products(id INTEGER PRIMARY KEY, name TEXT, price REAL, stock INTEGER);
    CREATE TABLE IF NOT EXISTS orders(id INTEGER PRIMARY KEY, customer TEXT, product_id INTEGER, qty INTEGER, total REAL);
    CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, email TEXT, password TEXT, reset_token TEXT);
    """)
    con.commit()
    con.close()


def find_orders_by_customer(name):
    con = connect()
    rows = con.execute(
        f"SELECT id, product_id, qty, total FROM orders WHERE customer = '{name}'"
    ).fetchall()
    con.close()
    return rows

app/orders.py

from app.db import connect


def unit_price_after_discount(price, qty):
    # 10% off for bulk orders
    if qty > 10:
        return round(price * 0.9, 2)
    return price


def place_order(customer, product_id, qty):
    con = connect()
    row = con.execute(
        "SELECT price, stock FROM products WHERE id = ?", (product_id,)
    ).fetchone()
    if row is None:
        con.close()
        return None
    price, stock = row
    if stock < qty:
        con.close()
        return None
    total = unit_price_after_discount(price, qty) * qty
    con.execute(
        "INSERT INTO orders(customer, product_id, qty, total) VALUES (?, ?, ?, ?)",
        (customer, product_id, qty, total),
    )
    con.commit()
    con.execute(
        "UPDATE products SET stock = ? WHERE id = ?", (stock - qty, product_id)
    )
    con.commit()
    con.close()
    return total

app/invoice.py

from app.utils import money_str


def bulk_price(price, qty):
    # bulk discount, same as in orders
    if qty >= 10:
        return price * 0.9
    return price


def invoice_lines(items):
    """items: list of dicts with name, price, qty"""
    lines = []
    for i in range(len(items) - 1):
        item = items[i]
        unit = bulk_price(item["price"], item["qty"])
        lines.append(f"{item['name']} x{item['qty']}: {money_str(unit * item['qty'])}")
    return lines


def invoice_total(items):
    total = 0
    for item in items:
        total += bulk_price(item["price"], item["qty"]) * item["qty"]
    return money_str(total)

app/auth.py

import random
import hashlib

from app.db import connect

SECRET_KEY = "s3cr3t-prod-key-2023"
ADMIN_PASSWORD = "admin123"


def hash_password(pw):
    return hashlib.md5((SECRET_KEY + pw).encode()).hexdigest()


def make_reset_token():
    return str(random.randint(100000, 999999))


def start_reset(email):
    token = make_reset_token()
    con = connect()
    try:
        con.execute("UPDATE users SET reset_token = ? WHERE email = ?", (token, email))
        con.commit()
    except Exception:
        pass
    con.close()
    return token


def finish_reset(email, token, new_password):
    con = connect()
    row = con.execute("SELECT reset_token FROM users WHERE email = ?", (email,)).fetchone()
    if row and row[0] == token:
        con.execute(
            "UPDATE users SET password = ? WHERE email = ?",
            (hash_password(new_password), email),
        )
        con.commit()
        con.close()
        return True
    con.close()
    return False

app/utils.py

def format_money(value):
    return "%.2f EUR" % value


def money_str(value):
    return "{:.2f} EUR".format(value)


def legacy_csv_export(rows, path):
    # old export, kept just in case
    with open(path, "w") as f:
        for r in rows:
            f.write(",".join(str(x) for x in r) + "\n")


class OrderRepositoryFactory:
    def create(self):
        from app import db
        return db

app/server.py

import json
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import urlparse, parse_qs

from app import db, orders, auth


class Handler(BaseHTTPRequestHandler):
    def _send(self, code, body):
        data = json.dumps(body).encode()
        self.send_response(code)
        self.send_header("Content-Type", "application/json")
        self.end_headers()
        self.wfile.write(data)

    def do_GET(self):
        url = urlparse(self.path)
        if url.path == "/orders":
            name = parse_qs(url.query).get("customer", [""])[0]
            self._send(200, db.find_orders_by_customer(name))
        else:
            self._send(404, {"error": "not found"})

    def do_POST(self):
        length = int(self.headers.get("Content-Length", 0))
        body = json.loads(self.rfile.read(length) or b"{}")
        if self.path == "/order":
            total = orders.place_order(body["customer"], body["product_id"], int(body["qty"]))
            if total is None:
                self._send(400, {"error": "cannot order"})
            else:
                self._send(200, {"total": total})
        elif self.path == "/reset/start":
            token = auth.start_reset(body["email"])
            self._send(200, {"ok": True, "token": token})
        elif self.path == "/reset/finish":
            ok = auth.finish_reset(body["email"], body["token"], body["password"])
            self._send(200 if ok else 403, {"ok": ok})
        else:
            self._send(404, {"error": "not found"})


if __name__ == "__main__":
    db.init()
    HTTPServer(("0.0.0.0", 8000), Handler).serve_forever()

tests/__init__.py

tests/test_utils.py

import unittest

from app.utils import format_money


class TestMoney(unittest.TestCase):
    def test_format(self):
        self.assertEqual(format_money(3), "3.00 EUR")


if __name__ == "__main__":
    unittest.main()

Run 1: Without skill (Rubric met 91.7% / 83.3%)

A also flags the hardcoded secrets and MD5 password hashing, which are missing from B's visible report.

Without skill91.7%

No outputs were saved for this test.

With skill83.3%

No outputs were saved for this test.

Run 2: With skill (Rubric met 75% / 91.7%)

B's visible text covers MD5, hardcoded secrets and the >10 vs >=10 discount gap; A's visible text covers none.

Without skill75%

No outputs were saved for this test.

With skill91.7%

No outputs were saved for this test.

Run 3: Tie (Rubric met 75% / 75%)

Both cover SQLi, reset and stock race well, but both truncate before invoice bugs and dead code.

Without skill75%

No outputs were saved for this test.

With skill75%

No outputs were saved for this test.

Task 2: Full-repo review of a Node.js URL shortener

Request

We're about to open our little link shortener (plain Node, no framework) to the whole company, maybe a few thousand clicks an hour. Can you go through the repo and tell me what's wrong with it before we do that? I care most about anything that's broken or unsafe, then what won't hold up under that traffic, then missing tests, performance, and stuff we can remove. Give me a prioritized, numbered list with file and line references, a concrete example of how each problem shows up, and the simplest fix. Just the report for now, don't edit the code.

Rubric

  1. Flags the path traversal in the /static/ handler (path.join with a decoded user path, e.g. /static/..%2F..%2Fetc%2Fpasswd or ../data/links.json is served) as must-fix and proposes checking the resolved path stays inside public/.
  2. Flags isValidUrl (u.includes('http')) accepting things like javascript:alert('http') and the unescaped url in the /stats HTML (stored XSS), with a concrete fix (parse with URL and allow only http/https, escape HTML).
  3. Identifies that makeCode has no collision check, so a new link can silently overwrite an existing one (4 chars ≈ 1.7M codes, collisions likely at scale), and suggests checking for an existing code and/or longer codes.
  4. Identifies load problems: every click rewrites the whole JSON file synchronously (writeFileSync on each redirect), the clicks array grows forever, and a crash during the write can corrupt or lose data; also notes JSON.parse on the POST body can crash the request or server on bad input.
  5. Finds the logic bugs: /stats pagination skips the first 20 links because page starts at 1 (slice(page*PAGE_SIZE)), and clicksToday compares a local-time day key to UTC day keys so counts are wrong near midnight.
  6. Gives a numbered, severity-ordered report with file references and smallest fixes, notes missing tests for the risky parts, lists removable code (unused uuid/lodash dependencies, makeLegacyCode, duplicate isUrl), and does not modify any files.

Score per rubric item (1 = met, 0.5 = partly, 0 = not met)

#Run 1
Without skill / With skill
Run 2
Without skill / With skill
Run 3
Without skill / With skill
10.5 / 11 / 11 / 1
21 / 11 / 11 / 1
31 / 11 / 11 / 1
40.5 / 11 / 11 / 1
50.5 / 01 / 0.51 / 0
60.5 / 0.50.5 / 0.50.5 / 0.5
Starting files(9)

README.md

# shorty

Tiny link shortener. `node server.js` starts it on port 3000.

- POST /shorten {"url": "https://..."} -> {"code": "abc123"}
- GET /r/<code> redirects
- GET /stats?page=1 shows an HTML table of links, 20 per page (page numbers start at 1)
- GET /static/<file> serves files from ./public

Data lives in data/links.json. Single process.

package.json

{
  "name": "shorty",
  "version": "1.0.0",
  "main": "server.js",
  "scripts": { "start": "node server.js", "test": "node --test test/" },
  "dependencies": {
    "uuid": "^9.0.0",
    "lodash": "^4.17.21"
  }
}

server.js

const http = require('node:http');
const fs = require('node:fs');
const path = require('node:path');
const store = require('./lib/store');
const { makeCode } = require('./lib/codes');
const { isValidUrl } = require('./lib/validate');

const PUBLIC_DIR = path.join(__dirname, 'public');
const PAGE_SIZE = 20;

function readBody(req) {
  return new Promise((resolve) => {
    let data = '';
    req.on('data', (c) => (data += c));
    req.on('end', () => resolve(data));
  });
}

const server = http.createServer(async (req, res) => {
  const url = new URL(req.url, 'http://localhost');

  if (req.method === 'POST' && url.pathname === '/shorten') {
    const body = JSON.parse(await readBody(req));
    if (!isValidUrl(body.url)) {
      res.writeHead(400);
      return res.end('bad url');
    }
    const code = makeCode();
    store.put(code, body.url);
    res.writeHead(200, { 'Content-Type': 'application/json' });
    return res.end(JSON.stringify({ code }));
  }

  if (req.method === 'GET' && url.pathname.startsWith('/r/')) {
    const code = url.pathname.slice(3);
    const link = store.get(code);
    if (!link) {
      res.writeHead(404);
      return res.end('not found');
    }
    store.recordClick(code);
    res.writeHead(302, { Location: link.url });
    return res.end();
  }

  if (req.method === 'GET' && url.pathname === '/stats') {
    const page = parseInt(url.searchParams.get('page') || '1', 10);
    const all = store.all();
    const rows = all.slice(page * PAGE_SIZE, page * PAGE_SIZE + PAGE_SIZE);
    let html = '<table><tr><th>code</th><th>url</th><th>clicks today</th></tr>';
    for (const l of rows) {
      html += `<tr><td>${l.code}</td><td>${l.url}</td><td>${store.clicksToday(l.code)}</td></tr>`;
    }
    html += '</table>';
    res.writeHead(200, { 'Content-Type': 'text/html' });
    return res.end(html);
  }

  if (req.method === 'GET' && url.pathname.startsWith('/static/')) {
    const file = path.join(PUBLIC_DIR, decodeURIComponent(req.url.slice('/static/'.length)));
    fs.readFile(file, (err, data) => {
      if (err) {
        res.writeHead(404);
        return res.end('not found');
      }
      res.writeHead(200);
      res.end(data);
    });
    return;
  }

  res.writeHead(404);
  res.end('not found');
});

server.listen(3000, () => console.log('listening on 3000'));

lib/store.js

const fs = require('node:fs');
const path = require('node:path');

const FILE = path.join(__dirname, '..', 'data', 'links.json');

let links = {};
try {
  links = JSON.parse(fs.readFileSync(FILE, 'utf8'));
} catch (e) {
  links = {};
}

function save() {
  fs.writeFileSync(FILE, JSON.stringify(links, null, 2));
}

function put(code, url) {
  links[code] = { code, url, created: Date.now(), clicks: [] };
  save();
}

function get(code) {
  return links[code];
}

function recordClick(code) {
  links[code].clicks.push(Date.now());
  save();
}

function all() {
  return Object.values(links).sort((a, b) => a.created - b.created);
}

function dayKeyUTC(ts) {
  return new Date(ts).toISOString().slice(0, 10);
}

function dayKeyLocal(ts) {
  const d = new Date(ts);
  return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
}

function clicksToday(code) {
  const today = dayKeyLocal(Date.now());
  return links[code].clicks.filter((ts) => dayKeyUTC(ts) === today).length;
}

module.exports = { put, get, recordClick, all, clicksToday, save };

lib/codes.js

const ALPHABET = 'abcdefghijklmnopqrstuvwxyz0123456789';

function makeCode(len = 4) {
  let out = '';
  for (let i = 0; i < len; i++) {
    out += ALPHABET[Math.floor(Math.random() * ALPHABET.length)];
  }
  return out;
}

// old format, before we switched to short codes
function makeLegacyCode() {
  return 'L' + Date.now().toString(36);
}

module.exports = { makeCode, makeLegacyCode };

lib/validate.js

function isValidUrl(u) {
  return typeof u === 'string' && u.includes('http');
}

function isUrl(u) {
  try {
    new URL(u);
    return true;
  } catch {
    return false;
  }
}

module.exports = { isValidUrl, isUrl };

public/index.html

<!doctype html><html><body><h1>shorty</h1></body></html>

data/links.json

{}

test/codes.test.js

const test = require('node:test');
const assert = require('node:assert');
const { makeCode } = require('../lib/codes');

test('code has 4 chars', () => {
  assert.strictEqual(makeCode().length, 4);
});

Run 1: With skill (Rubric met 66.7% / 75%)

B makes path traversal top must-fix and covers per-click full rewrites and growth; A does not.

Without skill66.7%

No outputs were saved for this test.

With skill75%

No outputs were saved for this test.

Run 2: Without skill (Rubric met 91.7% / 83.3%)

Both are cut off; A covers both the pagination and clicksToday timezone bugs, B stops mid-pagination.

Without skill91.7%

No outputs were saved for this test.

With skill83.3%

No outputs were saved for this test.

Run 3: Without skill (Rubric met 91.7% / 75%)

A flags the pagination off-by-one and the clicksToday timezone bug; B's visible output has neither.

Without skill91.7%

No outputs were saved for this test.

With skill75%

No outputs were saved for this test.