karpathy-guidelines 的测试记录
按任务列出请求、评分项及每项得分、每次运行的时间和 token、Claude Code 的完整日志以及生成的文件。另附原始数据,便于在调整配分后重新计算。
2026年11月1日 运行(运行:claude-sonnet-5-5/评分:claude-opus-5-5)。数值为中位数。任务由 AI 根据 SKILL.md 编写,可能偏向对该技能有利的场景。
原始数据(JSON)按原样提供任务、每次运行的测量值、评分和汇总。
每次运行的测量值
| 运行 | 结果 | 时间 | Token | 费用 | 轮次 | 使用技能 | 日志 |
|---|---|---|---|---|---|---|---|
| 任务 1 第 1 次 不使用技能 | 完成 | 20 秒 | 67,926 | $0.044 | 6 | - | 完整日志 |
| 任务 1 第 1 次 使用技能 | 完成 | 15 秒 | 71,120 | $0.043 | 8 | 使用 | 完整日志 |
| 任务 1 第 1 次 使用技能(未点名) | 完成 | 10 秒 | 68,177 | $0.037 | 6 | 未使用 | 完整日志 |
| 任务 1 第 2 次 使用技能 | 完成 | 15 秒 | 71,572 | $0.023 | 9 | 使用 | 完整日志 |
| 任务 1 第 2 次 不使用技能 | 完成 | 17 秒 | 50,551 | $0.018 | 6 | - | 完整日志 |
| 任务 1 第 2 次 使用技能(未点名) | 完成 | 18 秒 | 68,397 | $0.021 | 6 | 未使用 | 完整日志 |
| 任务 1 第 3 次 不使用技能 | 完成 | 16 秒 | 67,967 | $0.021 | 6 | - | 完整日志 |
| 任务 1 第 3 次 使用技能 | 完成 | 19 秒 | 71,213 | $0.021 | 8 | 使用 | 完整日志 |
| 任务 1 第 3 次 使用技能(未点名) | 完成 | 14 秒 | 68,181 | $0.020 | 6 | 未使用 | 完整日志 |
| 任务 2 第 1 次 不使用技能 | 完成 | 13 秒 | 51,233 | $0.043 | 5 | - | 完整日志 |
| 任务 2 第 1 次 使用技能 | 完成 | 11 秒 | 53,109 | $0.044 | 7 | 使用 | 完整日志 |
| 任务 2 第 1 次 使用技能(未点名) | 完成 | 18 秒 | 50,818 | $0.037 | 4 | 未使用 | 完整日志 |
| 任务 2 第 2 次 使用技能 | 完成 | 28 秒 | 52,833 | $0.030 | 6 | 使用 | 完整日志 |
| 任务 2 第 2 次 不使用技能 | 完成 | 18 秒 | 50,723 | $0.022 | 4 | - | 完整日志 |
| 任务 2 第 2 次 使用技能(未点名) | 完成 | 15 秒 | 51,227 | $0.023 | 5 | 未使用 | 完整日志 |
| 任务 2 第 3 次 不使用技能 | 完成 | 15 秒 | 68,137 | $0.024 | 5 | - | 完整日志 |
| 任务 2 第 3 次 使用技能 | 完成 | 15 秒 | 52,848 | $0.024 | 6 | 使用 | 完整日志 |
| 任务 2 第 3 次 使用技能(未点名) | 完成 | 13 秒 | 50,784 | $0.021 | 4 | 未使用 | 完整日志 |
“使用技能(未点名)”的运行只用于测量调用率,不参与评分。
任务 1: 以最小改动修复固定金额优惠券导致总额为负的问题
请求
We got a customer report: someone applied a $20 fixed-amount coupon to a $15 order and the checkout showed a negative total. That should never happen. Please fix this in cart.py and make sure it doesn't come back. The existing tests are in test_cart.py (run with `python3 -m unittest`). Please keep the change focused; this module is used in other places and I don't want surprises in the diff.评分标准
- A fixed coupon larger than the order subtotal (e.g. $20 on a $15 order) now yields a total of 0, not a negative number.
- All original tests in test_cart.py still pass, and percent/fixed coupon results for normal cases are unchanged.
- A new automated test reproducing the reported case (coupon exceeding subtotal) was added and passes.
- The diff is small and limited to the coupon/total logic: unrelated code such as _legacy_round, export, imports, comments and formatting is left as it was (mentioning the unused helper in the message is fine).
- The final message briefly explains the cause, the fix, and how it was verified (e.g. test run results).
每个评分项的得分(1 = 满足・0.5 = 部分・0 = 未满足)
| # | 第 1 次 不使用技能 / 使用技能 | 第 2 次 不使用技能 / 使用技能 | 第 3 次 不使用技能 / 使用技能 |
|---|---|---|---|
| 1 | 1 / 1 | 1 / 1 | 1 / 1 |
| 2 | 1 / 1 | 1 / 1 | 1 / 1 |
| 3 | 1 / 1 | 1 / 1 | 1 / 1 |
| 4 | 1 / 1 | 0.5 / 1 | 0.5 / 1 |
| 5 | 1 / 1 | 0.5 / 1 | 0.5 / 0.5 |
初始文件(2)
cart.py
# cart.py - shopping cart totals
import math
import json # used by export
TAX_RATE = 0.10
def _legacy_round(x):
# old rounding helper, no longer used
return math.floor(x*100+0.5)/100
def line_total(item):
return item['price'] * item['qty']
def subtotal(items):
total = 0
for i in items:
total += line_total(i)
return total
def apply_coupon(amount, coupon):
if coupon is None:
return amount
if coupon['type'] == 'percent':
return amount * (1 - coupon['value']/100)
if coupon['type'] == 'fixed':
return amount - coupon['value']
return amount
def total(items, coupon=None):
s = subtotal(items)
s = apply_coupon(s, coupon)
taxed = s * (1+TAX_RATE)
return round(taxed, 2)
def export(items):
return json.dumps(items)
test_cart.py
import unittest
from cart import total, subtotal, apply_coupon
ITEMS = [{'price': 10.0, 'qty': 2}, {'price': 5.0, 'qty': 1}]
class CartTests(unittest.TestCase):
def test_subtotal(self):
self.assertEqual(subtotal(ITEMS), 25.0)
def test_total_no_coupon(self):
self.assertEqual(total(ITEMS), 27.5)
def test_percent_coupon(self):
self.assertEqual(total(ITEMS, {'type': 'percent', 'value': 20}), 22.0)
def test_fixed_coupon(self):
self.assertEqual(total(ITEMS, {'type': 'fixed', 'value': 5}), 22.0)
if __name__ == '__main__':
unittest.main()
第 1 次: 平局 (达成率 100% / 100%)
两者都限制为0并添加复现测试,无关代码未改;B额外修正百分比仍属优惠逻辑,无实质差异
不使用技能100%
最终回复
I fixed the negative total in apply_coupon in cart.py. A coupon can no longer take the amount below zero, so a $20 fixed coupon on a $15 order now gives $0. All 6 tests pass.
- The change: the
fixedandpercentbranches now wrap their results inmax(0, ...). I clamped the percent branch too, because a percent value over 100 had the same bug. Nothing else in the module changed. - Tests: I added two to
test_cart.py. One checks a $20 fixed coupon on a $15 order, through bothtotalandapply_coupon. The other checks a 150% coupon.
One thing in the diff you might not expect: when the clamp applies, total returns 0 (an int) instead of 0.0. 0 == 0.0 in Python, so it only matters if some caller checks the type or formats the number as a string.
新建或修改的文件
使用技能100%
最终回复
I fixed it: a fixed coupon larger than the order now brings the total to $0.00 instead of going negative. All 5 tests pass. I didn't run the new test against the old code first, so it hasn't been shown to fail before the fix.
cart.py: the fixed-coupon branch ofapply_couponnow returnsmax(amount - coupon['value'], 0). That is the only line changed.test_cart.py: I addedtest_fixed_coupon_larger_than_order. It uses the reported case, a $20 coupon on a $15 order, and checks bothapply_couponandtotalreturn 0.
A percent coupon with a value over 100 would also give a negative total. I left it alone because it's outside this report and you asked for a narrow diff. The same clamp would fix it if you want it.
I also left _legacy_round in cart.py alone. It looks unused, but removing it isn't part of this fix.
新建或修改的文件
第 2 次: 使用技能 (达成率 80% / 100%)
B只修改了固定金额券分支,并说明测试在修复前失败;A还改动了未被要求的百分比券行为。
不使用技能80%
最终回复
I fixed it in apply_coupon in cart.py. A coupon can no longer take the discounted amount below 0, so a $20 fixed coupon on a $15 order now gives a total of $0. All 6 tests pass: the 4 existing ones and 2 new ones.
- Fix: both coupon branches now wrap the result in
max(0, ...). I clamped the percent branch too, because a percent coupon over 100 (say 150%) goes negative the same way. Totals that were already non-negative come out exactly as before. - Tests: I added two regression tests to
test_cart.py, one for the $20 coupon on a $15 order and one for a 150% percent coupon.
The diff touches only those two lines in cart.py. I left the unused _legacy_round helper alone to keep the change focused.
新建或修改的文件
使用技能100%
最终回复
A $20 fixed coupon on a $15 order now gives a $0 total instead of a negative one. All 5 tests pass, including the new one.
cart.py: inapply_coupon, the fixed-coupon branch is nowmax(amount - coupon['value'], 0). That's a one-line change.test_cart.py: I addedtest_fixed_coupon_larger_than_order, which checks bothapply_couponandtotalfor this case. It failed before the fix (-5.0 != 0).
I didn't touch anything else, so the other callers of this module behave the same, except that an oversized fixed coupon now bottoms out at 0.
Two things I noticed and left alone:
- A percent coupon over 100 (say
value: 150) would also produce a negative total. You only reported the fixed case, so I didn't change it. It's the same one-line fix if you want it. _legacy_roundincart.pyis unused.
新建或修改的文件
第 3 次: 使用技能 (达成率 80% / 90%)
两者都修复了问题,但A还改了未要求的percent分支,B保持聚焦并将其作为后续建议。
不使用技能80%
最终回复
I fixed the negative total in apply_coupon in cart.py. A $20 fixed coupon on a $15 order now gives a $0 total. All 6 tests pass, including the two new ones.
- The fix: the coupon result is now
max(0, …). I applied it to the percent branch as well as the fixed one, because a percent coupon over 100 would also go negative. It's a one-line change in each branch, and no other function in the module is touched. - Tests: I added two to
test_cart.py. One is your exact case, a $20 fixed coupon on a $15 order. The other is a 150% coupon. Both expect a total of 0.
Normal coupons behave as before. The existing tests pass unchanged.
I left alone the unused _legacy_round helper and the rest of the module.
新建或修改的文件
使用技能90%
最终回复
A $20 fixed coupon on a $15 order now gives a total of 0 instead of a negative number. All 5 tests pass, including the new one.
- Fix: in
cart.py, thefixedbranch ofapply_couponis nowreturn max(amount - coupon['value'], 0). That is the only line changed in the module. - Test: I added
test_fixed_coupon_larger_than_order_is_not_negativetotest_cart.py. It covers the $15 order with a $20 coupon, both throughtotal()and throughapply_coupon()directly.
Anything else that calls apply_coupon with a fixed coupon larger than the amount now gets 0 as well.
I left a related case alone because you asked for a focused change. A percent coupon with a value over 100 would still produce a negative amount. Clamping the percent branch the same way would be a one-line follow-up if you want it.
_legacy_round in cart.py is unused. I didn't touch it.
新建或修改的文件
任务 2: 为日志汇总命令行工具简洁地添加 --level 选项
请求
I have a little Node script, summarize.js, that counts log lines per level in a log file (try `node summarize.js app.log`). I'd like to add a `--level` option so that `node summarize.js app.log --level ERROR` prints only the count for that level, plus the most recent message logged at that level. Running it without `--level` should behave exactly as it does today. No new dependencies please.评分标准
- `node summarize.js app.log --level ERROR` prints the ERROR count (2) and the most recent ERROR message ("payment service timeout"); other levels work too (e.g. WARN gives 2 and "cache miss rate high").
- `node summarize.js app.log` without the flag produces exactly the same output as the original script (DEBUG 1, ERROR 2, INFO 3, WARN 2, tab-separated, sorted).
- No new dependencies or extra files beyond what is needed (no package.json/argument-parsing library added); the change stays focused on summarize.js.
- The implementation is proportionate: no unrequested features (e.g. multiple-level filters, JSON output, config files) and no unrelated rewriting of existing functions or formatting.
- The final message reports how the change was checked (e.g. commands run and their output) and notes any behaviour decisions made for unclear cases, such as a level with no matching lines or a missing value after --level.
每个评分项的得分(1 = 满足・0.5 = 部分・0 = 未满足)
| # | 第 1 次 不使用技能 / 使用技能 | 第 2 次 不使用技能 / 使用技能 | 第 3 次 不使用技能 / 使用技能 |
|---|---|---|---|
| 1 | 1 / 1 | 1 / 1 | 1 / 1 |
| 2 | 1 / 1 | 1 / 1 | 1 / 1 |
| 3 | 1 / 1 | 1 / 1 | 1 / 1 |
| 4 | 0.5 / 1 | 1 / 1 | 1 / 1 |
| 5 | 0.5 / 1 | 1 / 0.5 | 1 / 0.5 |
初始文件(2)
summarize.js
#!/usr/bin/env node
const fs = require('fs');
function parseLine(line) {
// format: 2026-10-01T12:00:00Z LEVEL message
const m = line.match(/^(\S+)\s+(DEBUG|INFO|WARN|ERROR)\s+(.*)$/);
if (!m) return null;
return { ts: m[1], level: m[2], msg: m[3] };
}
function summarize(lines) {
const counts = {};
for (const line of lines) {
const e = parseLine(line);
if (!e) continue;
counts[e.level] = (counts[e.level] || 0) + 1;
}
return counts;
}
function main() {
const file = process.argv[2];
if (!file) {
console.error('usage: summarize.js <logfile>');
process.exit(1);
}
const lines = fs.readFileSync(file, 'utf8').split('\n');
const counts = summarize(lines);
for (const level of Object.keys(counts).sort()) {
console.log(`${level}\t${counts[level]}`);
}
}
if (require.main === module) main();
module.exports = { parseLine, summarize };
app.log
2026-10-01T08:00:00Z INFO server started 2026-10-01T08:00:05Z DEBUG loading config 2026-10-01T08:01:10Z WARN slow query: 1200ms 2026-10-01T08:02:00Z ERROR db connection reset 2026-10-01T08:02:30Z INFO retrying db connection 2026-10-01T08:03:00Z ERROR payment service timeout this line is garbage 2026-10-01T08:04:00Z INFO request handled 2026-10-01T08:05:00Z WARN cache miss rate high
第 1 次: 使用技能 (达成率 80% / 100%)
B改动最小并说明了无匹配和缺值的行为;A加了多余功能且未说明缺值情况。
不使用技能80%
最终回复
I added --level to /work/summarize.js. I ran it against app.log and it works. I only ran the cases below, and I didn't check what happens when a level has no matching lines.
- Without
--level: the output is unchanged. It still prints oneLEVEL<tab>countline per level, sorted. - With
--level:node summarize.js app.log --level ERRORprints the count, then the latest message at that level. Forapp.logit printed:ERROR 2 2026-10-01T08:03:00Z payment service timeout - Option forms: the option can go before or after the filename.
--level=WARNalso works, and so does lowercase (--level warn). - Bad level: an unknown level such as
FATALprints the usage message and exits with code 1. - "Most recent": this means the last matching line in the file, not the one with the latest timestamp. That's the same thing as long as the log is in chronological order.
I added no dependencies, and the exports (parseLine, summarize) are untouched.
新建或修改的文件
使用技能100%
最终回复
I added --level to summarize.js. I ran it against app.log and the output looked right, but I didn't write any tests.
- Without
--level: the output is the same as before. I compared it with the earlier run. - With
--level ERROR: it printsERROR<tab>2, then the last ERROR message in the file (payment service timeout).
I made a few choices you didn't specify:
- "Most recent": this means the last matching line in the file, not the latest timestamp. The two are the same if the log is in time order.
- Option position:
--levelcan go before or after the filename, so--level WARN app.logworks too. - Level with no matches: it prints just
FATAL<tab>0and no message line. - Missing value:
--levelwith no value exits with an error. - Level names: the level isn't validated and is case-sensitive, so
errorwould report 0.
I also updated the usage text to mention --level.
新建或修改的文件
第 2 次: 不使用技能 (达成率 100% / 90%)
两者都能正常运行,但A在真实app.log上做了检查,B只用小样本日志测试,也没有与旧脚本输出对比
不使用技能100%
最终回复
I added --level to /work/summarize.js. I ran it on app.log and it behaves as you described.
- Without
--level: the output is the same as before:DEBUG 1,ERROR 2,INFO 3,WARN 2. node summarize.js app.log --level ERROR: prints the count, then the most recent message:ERROR 2 latest: 2026-10-01T08:03:00Z payment service timeout- Argument forms:
--level=ERRORworks too, and the option can come before the file name. The level is case-insensitive. - Level with no matches: it prints just the count, for example
NOPE 0. That includes a misspelled level likeNOPE, which isn't rejected. - Missing value:
--levelwith nothing after it prints the usage message and exits with code 1. - "Most recent": this means the last matching line in the file, not the latest timestamp. If your logs can be out of order, tell me and I'll compare timestamps instead.
I added no dependencies, and the exports (parseLine, summarize) are unchanged.
新建或修改的文件
使用技能90%
最终回复
node summarize.js app.log --level ERROR now prints the count for that level, then the most recent message at that level. I checked it on a small sample log. The no---level output matched the existing format, but I didn't compare it against the old script.
ERROR 2
Last: second
- Most recent: this is the last matching line in the file, not the one with the latest timestamp. Say so if you'd rather go by timestamp.
- Option position:
--levelworks before or after the filename. - No matches: a level with no lines (such as
WARNin my sample) printsWARN 0and noLast:line. - Missing value:
--levelwith nothing after it prints the usage message and exits with code 1. - Unchanged code: I didn't touch
summarizeorparseLine. The change is inmaininsummarize.js, and there are no new dependencies.
I didn't validate the level name, so --level error in lowercase just reports a count of 0.
新建或修改的文件
第 3 次: 不使用技能 (达成率 100% / 90%)
两者实现均正确,但B展示了app.log的实际输出,A的验证说明含糊。
不使用技能100%
最终回复
I added --level to /work/summarize.js. I ran it on app.log and it works.
- With
--level:node summarize.js app.log --level ERRORprints the count, then the timestamp and message of the most recent line at that level:ERROR 2 2026-10-01T08:03:00Z payment service timeout - Without
--level: the output is the same as before. I leftsummarize()and the exports unchanged. - Argument handling: the flag can go before or after the file name, and the level is case-insensitive, so
--level warnworks. An unknown level, a missing level value, or extra arguments print the usage message and exit with code 1. - No matches: if the level never appears, it prints just
LEVEL 0and no message line. - "Most recent": this means the last matching line in the file, not the latest timestamp. If your logs can be out of order, I can compare timestamps instead.
新建或修改的文件
使用技能90%
最终回复
I added --level to /work/summarize.js. I ran it against a small test log, and each case behaved as expected.
--level ERROR:node summarize.js app.log --level ERRORprintsERROR<tab>2, then the last matching line as<timestamp> <message>. "Most recent" means the last matching line in the file, not the latest timestamp.- Without
--level: the output is the same per-level counts as before. - Option position:
--levelcan come before or after the filename. - Zero matches: if the level never appears (or isn't a real level), it prints
WARN<tab>0and no message line. - Missing value:
--levelwith nothing after it prints the usage message and exits with an error. - Usage text: the usage message now mentions
[--level LEVEL].
The level name is case-sensitive, so error finds nothing. There are no new dependencies.