本文へ移動
cccskills

test-driven-development の検証ログ

課題ごとに、依頼文と採点項目、項目ごとの点数、実行ごとの時間・トークン、Claude Code の全ログ、作られたファイルを載せています。配点を変えても計算し直せるよう、生データも置いています。

2026年11月24日 に実行(実行: claude-sonnet-5-5/採点: claude-opus-5-5)。数値は中央値です。課題は SKILL.md をもとに AI が作ったもので、スキルに有利な場面に偏ることがあります。

生データ(JSON)課題・実行ごとの測定値・採点・集計をそのまま置いています。

実行ごとの測定値

実行結果時間トークン費用ターンスキル使用ログ
課題 1 1 回目 スキルなし完了12秒68,086$0.0497-全ログ
課題 1 1 回目 スキルあり完了18秒136,394$0.08110使った全ログ
課題 1 1 回目 スキルあり(名指しなし)完了18秒112,625$0.07910使った全ログ
課題 1 2 回目 スキルあり完了19秒112,290$0.06310使った全ログ
課題 1 2 回目 スキルなし完了13秒67,745$0.0274-全ログ
課題 1 2 回目 スキルあり(名指しなし)完了15秒111,054$0.0577使った全ログ
課題 2 1 回目 スキルなし完了15秒51,080$0.0424-全ログ
課題 2 1 回目 スキルあり完了27秒139,131$0.0919使った全ログ
課題 2 1 回目 スキルあり(名指しなし)完了19秒107,487$0.0588使わず全ログ
課題 2 2 回目 スキルあり完了21秒139,662$0.0769使った全ログ
課題 2 2 回目 スキルなし完了14秒69,091$0.0315-全ログ
課題 2 2 回目 スキルあり(名指しなし)完了22秒107,573$0.0458使わず全ログ

「スキルあり(名指しなし)」は呼ばれやすさを測るための実行で、採点はしていません。

課題 1: まとめ買い割引の境界値バグを修正する(Python)

依頼文

We got a bug report from support: "A customer ordered exactly 10 units of SKU A-100 at $4.99 each and was charged the full $49.90 — they should have gotten the bulk discount." Can you fix this in pricing.py? Please make sure it doesn't happen again.

採点基準

  1. pricing.py is fixed so that exactly 10 units gets 10% off (line_total(499, 10) == 4491) and exactly 50 units gets 20% off; quantities of 9 and 49 still get the lower tier
  2. Test(s) were added under tests/ that cover the reported case (exactly 10 units) and the boundary values around both tiers (e.g. 9/10 and 49/50)
  3. All pre-existing tests still pass unchanged, and the full suite passes with `python3 -m unittest discover -s tests`
  4. The final message explains the root cause (strict > comparisons instead of >=), notes the 50-unit boundary had the same bug, and reports the actual test run result

項目ごとの点数(1 = 満たした・0.5 = 一部・0 = 満たさない)

#1 回目
スキルなし / スキルあり
2 回目
スキルなし / スキルあり
11 / 11 / 1
21 / 11 / 1
31 / 11 / 1
41 / 11 / 1
初期ファイル(3)

README.md

# pricing

Small pricing helpers used by the checkout service.

## Bulk discount policy

- 10 or more units of a line item: 10% off that line
- 50 or more units of a line item: 20% off that line
- Discounted line totals are rounded to the nearest cent (half up).

## Running tests

```
python3 -m unittest discover -s tests -v
```

pricing.py

"""Pricing helpers. All money values are integer cents."""


def bulk_discount_rate(qty):
    """Return the discount rate for a line with `qty` units.

    Policy: 10 or more units -> 10%, 50 or more units -> 20%.
    """
    if qty < 0:
        raise ValueError("qty must be non-negative")
    if qty > 50:
        return 0.20
    if qty > 10:
        return 0.10
    return 0.0


def line_total(unit_price_cents, qty):
    """Total for a line in cents, after bulk discount, rounded half up."""
    if unit_price_cents < 0:
        raise ValueError("unit price must be non-negative")
    gross = unit_price_cents * qty
    rate = bulk_discount_rate(qty)
    # integer math to avoid float rounding surprises: percent as integer
    percent_off = int(round(rate * 100))
    discounted_times_100 = gross * (100 - percent_off)
    return (discounted_times_100 + 50) // 100


def order_total(lines):
    """lines: iterable of (unit_price_cents, qty)."""
    return sum(line_total(p, q) for p, q in lines)

tests/test_pricing.py

import os
import sys
import unittest

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

from pricing import bulk_discount_rate, line_total, order_total  # noqa: E402


class BulkDiscountRateTest(unittest.TestCase):
    def test_small_order_has_no_discount(self):
        self.assertEqual(bulk_discount_rate(3), 0.0)

    def test_mid_size_order_gets_ten_percent(self):
        self.assertEqual(bulk_discount_rate(25), 0.10)

    def test_large_order_gets_twenty_percent(self):
        self.assertEqual(bulk_discount_rate(100), 0.20)

    def test_negative_qty_rejected(self):
        with self.assertRaises(ValueError):
            bulk_discount_rate(-1)


class LineTotalTest(unittest.TestCase):
    def test_no_discount_line(self):
        self.assertEqual(line_total(499, 2), 998)

    def test_discounted_line_rounds_half_up(self):
        # 15 * 333 = 4995; 10% off = 4495.5 -> 4496
        self.assertEqual(line_total(333, 15), 4496)


class OrderTotalTest(unittest.TestCase):
    def test_sums_lines(self):
        self.assertEqual(order_total([(499, 2), (100, 1)]), 1098)


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

1 回目: 引き分け (達成率 100% / 100%)

両者とも>=への同一修正、境界テスト追加、原因と50単位の同種バグ、テスト結果を報告しており実質差なし

スキルなし100%

最終メッセージ

I fixed the bug in pricing.py. All 10 tests pass, including the new ones.

Cause: bulk_discount_rate used qty > 10 and qty > 50. The documented policy, in the docstring and the README, says "10 or more" and "50 or more". An order of exactly 10 got no discount, and so did an order of exactly 50, which also missed the 20% tier. I changed both comparisons to >=.

Result: 10 units at $4.99 now come to $44.91 (10% off) instead of $49.90. 50 units now get 20% off.

Regression tests in tests/test_pricing.py:

  • Rate boundaries at 9, 10, 49 and 50.
  • line_total(499, 10) == 4491, which is the exact case from the support report.
  • line_total(499, 50) == 19960.

The existing tests used quantities of 3, 25 and 100, which never touched a boundary. That's why the bug wasn't caught.

I haven't looked for customers who were already overcharged on orders of exactly 10 or 50 units. Support may want to check for refunds.

作った・変えたファイル

スキルあり100%

最終メッセージ

Fixed. An order of exactly 10 units now gets the bulk discount, and all 13 tests pass.

Cause: bulk_discount_rate in pricing.py used qty > 10 and qty > 50. The documented policy is "10 or more" and "50 or more", so both thresholds were off by one. Orders of exactly 50 units were also getting 10% instead of 20%. That second bug wasn't in the report.

Fix: I changed both comparisons to >=.

Tests: I added tests before the fix and confirmed 4 of them failed against the old code.

  • Boundaries: the rate at 9, 10, 49 and 50 units.
  • Reported case: 10 × $4.99 now totals $44.91 (4491¢) instead of $49.90.
  • 50-unit case: 50 × $4.99 now totals $199.60 (19960¢).

These pin the boundaries, so a future change to the comparisons will fail the suite.

The customer in the report was overcharged $4.99. Any other orders of exactly 10 or 50 units were overcharged too. You may want to look for those and refund them, but that's outside this code.

作った・変えたファイル

2 回目: 引き分け (達成率 100% / 100%)

両者とも>=への同一修正、9/10/49/50の境界テスト、原因と50件境界の説明、テスト結果報告を満たし実質差なし。

スキルなし100%

最終メッセージ

Fixed. The tier checks in bulk_discount_rate used > instead of >=, so the discount only started at 11 units and 51 units. That didn't match the policy in the README and docstring ("10 or more", "50 or more"). I changed both checks to >= in pricing.py.

An order of 10 units at $4.99 now comes to $44.91 (10% off) instead of $49.90. The same bug hit exactly 50 units, which now get 20% off.

To keep it from coming back, I added three tests to tests/test_pricing.py:

  • Tier boundaries: checks 9, 10, 49 and 50 units.
  • Reported case: 10 × 499¢ = 4491¢.
  • 50 units: 50 units at 100¢ = 4000¢.

All 10 tests pass.

Any customers who already bought exactly 10 or exactly 50 units were overcharged. Support may want to find those orders and refund the difference. The code can't tell me which orders those are.

作った・変えたファイル

スキルあり100%

最終メッセージ

I fixed the bug in pricing.py. The customer's 10 units at $4.99 now come to $44.91 (10% off) instead of $49.90. All 12 tests pass.

Cause: bulk_discount_rate used qty > 10 and qty > 50. The policy in the docstring and README says "10 or more" and "50 or more". The same off-by-one meant orders of exactly 50 units got 10% off instead of 20%. I fixed both thresholds to >=.

Tests added to tests/test_pricing.py:

  • Customer's case: line_total(499, 10) should equal 4491. This test failed before the fix with 4990.
  • Boundary cases: the rate at 9, 10, 49 and 50 units. The tests at 10 and 50 failed before the fix.

The existing tests used 3, 25 and 100 units, so they never hit a threshold. That's why the bug got through.

Orders of exactly 10 or 50 units were undercharged for the discount before this fix. You may want to tell support so they can look at past orders for refunds.

作った・変えたファイル

課題 2: slugify にアクセント除去と最大長オプションを追加(Node.js)

依頼文

Our slugify in src/slugify.js produces ugly URLs for some blog titles. Please change it so that:
1. Accented letters are transliterated instead of dropped: "Café Déjà Vu" should become "cafe-deja-vu" (right now it's "caf-dj-vu").
2. Runs of dashes collapse to one and there are never leading/trailing dashes: "a -- b" -> "a-b", "-Hello-" -> "hello".
3. It accepts an optional second argument `{ maxLength }`. When the slug is longer, cut it at the last dash boundary that fits so words aren't split, with no trailing dash. If the first word alone is longer than maxLength, just hard-cut it to maxLength.
Existing behavior that callers rely on must keep working.

採点基準

  1. slugify('Café Déjà Vu') returns 'cafe-deja-vu'
  2. slugify('a -- b') returns 'a-b' and slugify('-Hello-') returns 'hello' (no repeated, leading, or trailing dashes)
  3. maxLength works as specified: e.g. slugify('The quick brown fox', { maxLength: 12 }) returns 'the-quick' (word boundary, no trailing dash), a single over-long word is hard-cut to exactly maxLength, and slugs already within the limit are unchanged
  4. All original tests in test/slugify.test.js still pass, and new tests were added covering each of the three requested behaviors
  5. The suite was run with the project's command (`npm test` / `node --test test/`) and the final message reports the actual result

項目ごとの点数(1 = 満たした・0.5 = 一部・0 = 満たさない)

#1 回目
スキルなし / スキルあり
2 回目
スキルなし / スキルあり
11 / 11 / 1
21 / 11 / 1
31 / 11 / 1
40 / 10.5 / 1
50 / 10.5 / 1
初期ファイル(3)

package.json

{
  "name": "blog-utils",
  "version": "1.0.0",
  "private": true,
  "type": "commonjs",
  "scripts": {
    "test": "node --test test/"
  }
}

src/slugify.js

'use strict';

/**
 * Turn a post title into a URL slug.
 * @param {string} input
 * @returns {string}
 */
function slugify(input) {
  return String(input)
    .toLowerCase()
    .trim()
    .replace(/[^a-z0-9\s-]/g, '')
    .replace(/\s+/g, '-');
}

module.exports = { slugify };

test/slugify.test.js

'use strict';

const test = require('node:test');
const assert = require('node:assert/strict');
const { slugify } = require('../src/slugify');

test('lowercases and joins words with dashes', () => {
  assert.equal(slugify('Hello World'), 'hello-world');
});

test('drops punctuation', () => {
  assert.equal(slugify('Rock & Roll!'), 'rock-roll');
});

test('trims surrounding whitespace', () => {
  assert.equal(slugify('  Trim me  '), 'trim-me');
});

test('keeps existing dashes', () => {
  assert.equal(slugify('Already-slugged'), 'already-slugged');
});

test('keeps digits', () => {
  assert.equal(slugify('Top 10 Tips'), 'top-10-tips');
});

1 回目: スキルあり (達成率 60% / 100%)

両者とも実装は正しいが、Bは新テストを追加せずテスト実行結果も確認できない。

スキルなし60%

最終メッセージ

I updated slugify in src/slugify.js, and the 5 existing tests pass. I didn't add new test cases to the test file. I checked the new behavior by running a few examples by hand:

  • Accents: "Café Déjà Vu" now gives cafe-deja-vu. I also mapped ß, æ, œ, ø, đ, ð, þ and ł to ASCII equivalents, because accent-stripping alone doesn't handle them.
  • Dashes: "a -- b" gives a-b and "-Hello-" gives hello. Runs of spaces and dashes collapse to one dash, and leading and trailing dashes are removed.
  • { maxLength }:
    • slugify('hello world foo', { maxLength: 11 }) gives hello-world.
    • slugify('hello world foo', { maxLength: 12 }) also gives hello-world, since the full slug wouldn't fit.
    • slugify('abcdefghij kl', { maxLength: 5 }) gives abcde, because the first word alone is too long, so it's hard-cut.

The second argument is optional, so existing one-argument calls behave as before. For example, "Rock & Roll!" still gives rock-roll.

作った・変えたファイル

スキルあり100%

最終メッセージ

slugify in src/slugify.js now handles all three changes. All 12 tests pass: the 5 existing ones plus 7 new ones in test/slugify.test.js.

  • Accents: "Café Déjà Vu" becomes cafe-deja-vu.
  • Dashes: runs collapse to one dash and there are no leading or trailing dashes, so "a -- b" becomes a-b and "-Hello-" becomes hello.
  • { maxLength }:
    • When the slug is longer, it cuts at the last dash that fits, with no trailing dash.
    • If the first word alone is longer than maxLength, it hard-cuts it.
    • Without the option, or with a non-numeric one, behavior is unchanged.

To confirm the new tests were real, I temporarily restored the old implementation. 6 of the 7 new tests failed, and the existing 5 still passed. The seventh, "leaves slug alone when within maxLength", passes on the old code too. The old code ignores the second argument, so it returns the short slug unchanged.

npm test is broken in this environment, and I didn't change it. Node 22 reads node --test test/ as a module path and fails with "Cannot find module '/work/test'". I ran node --test test/slugify.test.js instead. Changing the script to node --test would fix it if you want that.

作った・変えたファイル

2 回目: スキルあり (達成率 80% / 100%)

実装はどちらも正しいが、Bは3つの新機能すべてにテストを追加し、実行コマンドと結果を明記している

スキルなし80%

最終メッセージ

I updated slugify in src/slugify.js, and all 5 existing tests in test/slugify.test.js pass. I didn't add tests for the new behavior. I checked it with a quick script instead.

  • Accents: accented letters are now transliterated, so "Café Déjà Vu" gives cafe-deja-vu. I also mapped ß, æ, œ, ø, đ, ð, þ and ł, which don't decompose into a base letter plus an accent.
  • Dashes: runs of dashes and spaces collapse to one dash, and leading and trailing dashes are stripped. "a -- b" gives a-b and "-Hello-" gives hello.
  • { maxLength }: a slug that is too long is cut at the last dash that fits, with no trailing dash. If the first word alone is too long, it's hard-cut to maxLength.
  • Invalid maxLength: a missing, zero, negative or non-numeric maxLength is ignored.

In my check, hello world foo with maxLength: 11 gave hello-world, and abcdefghij k with maxLength: 5 gave abcde.

作った・変えたファイル

スキルあり100%

最終メッセージ

I changed slugify in src/slugify.js to do all three things, and the tests pass: 13 of 13 with node --test test/slugify.test.js.

  • Accents: letters are transliterated, so "Café Déjà Vu" gives cafe-deja-vu.
  • Dashes: runs collapse to one, and there are no leading or trailing dashes. "a -- b" gives a-b and "-Hello-" gives hello.
  • { maxLength }: an over-long slug is cut at the last dash that fits, with no trailing dash. If the first word alone is longer than maxLength, it's hard-cut to maxLength. A missing or non-positive maxLength is ignored.

I added 8 tests to test/slugify.test.js before changing the code. Run against the original implementation, 7 of the 13 tests failed. The 5 existing tests still pass, so the old behavior callers rely on is unchanged.

npm test is broken in this environment: node --test test/ passes the directory as a module path and fails with "Cannot find module '/work/test'". I didn't change the script. Passing the file directly works, or node --test with no argument should find the tests.

作った・変えたファイル