agent-instructions
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what does not, structure, and…
Use when practicing TDD. Covers the red-green-refactor loop, choosing the next test, designing through tests, and when TDD is and is not the right approach.
$ npx -y skills add nimadorostkar/Claude-Skills-collection --skill test-driven-development --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/test-driven-developmentContext preview
The summary Claude sees to decide when to auto-load this skill.
Use when practicing TDD. Covers the red-green-refactor loop, choosing the next test, designing through tests, and when TDD is and is not the right approach.
name: test-driven-development description: Use when practicing TDD. Covers the red-green-refactor loop, choosing the next test, designing through tests, and when TDD is and is not the right approach. metadata: category: testing version: 1.0.0 tags: [tdd, testing, design, red-green-refactor]
Use tests to drive design. TDD's value is not primarily the tests it produces — it is the pressure it puts on the design, because code that is hard to test is hard to use.
1. **Red** — Write the smallest test that fails for the right reason. Run it. Watch it fail. A test you have not seen fail is a test that may not be testing anything. 2. **Green** — Write the least code that makes it pass. Hardcoding the answer is legitimate at this stage; the next test will force generalization. 3. **Refactor** — With the test green, improve the structure. The test is your safety net, and this is the only step where you may change design without changing behavior. 4. **Choose the next test deliberately** — The next test should either force a generalization or cover a new case. A test that already passes teaches nothing. 5. **Repeat in small cycles** — Minutes, not hours. If you have been red for twenty minutes, the step was too big — revert and take a smaller one.
**The cycle, in full, on a small requirement:**
# RED — the simplest failing test. Run it; watch it fail with a NameError.
def test_no_items_is_free():
assert price(items=[]) == 0
# GREEN — the least code that passes. Yes, this is a hardcoded return.
def price(items): return 0
# RED — this test forces the hardcoding out.
def test_single_item_costs_its_price():
assert price(items=[Item("widget", cents=250)]) == 250
# GREEN
def price(items): return sum(i.cents for i in items)
# RED — the requirement that actually has business logic in it.
def test_bulk_discount_applies_over_ten_units():
items = [Item("widget", cents=250)] * 12
assert price(items) == int(250 * 12 * 0.9)
# GREEN
def price(items):
total = sum(i.cents for i in items)
return int(total * 0.9) if len(items) > 10 else total
# REFACTOR — now that it is green, make it express the domain.
BULK_THRESHOLD = 10
BULK_MULTIPLIER = 0.9
def price(items: list[Item]) -> int:
subtotal = sum(i.cents for i in items)
return _apply_bulk_discount(subtotal, len(items))
def _apply_bulk_discount(subtotal: int, count: int) -> int:
return int(subtotal * BULK_MULTIPLIER) if count > BULK_THRESHOLD else subtotalEach test failed before it passed. Each piece of production code exists because a test demanded it. The design emerged from the pressure of writing the tests, not from a diagram.
A curated library of 137 production-grade skills for Claude and other AI coding agents. Every skill follows one structure, speaks with one voice, and earns its place by changing what the agent does.
Repo: nimadorostkar/Claude-Skills-collection
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what does not, structure, and…
Use when an agent needs state that survives a session or a context compaction. Covers what to persist, file-based memory, structuring notes for retrieval, and…
Use when automating agent behavior with lifecycle hooks. Covers hook events, deterministic enforcement of rules the model should not be trusted to remember,…
Use when packaging skills, commands, hooks, and MCP servers into a distributable plugin. Covers manifest structure, bundling, versioning, testing, and…
Use when writing a new skill for an AI agent. Covers scoping, description writing for reliable triggering, progressive disclosure, and the difference between a…
Use when reviewing or improving an existing agent skill. Covers triggering accuracy, content quality, redundancy with the base model, and measuring whether the…