Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Tdd?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/alexander-tyagunov-tdd)
---
name: tdd
description: TDD enforcer; red/green/refactor, one behavior at a time. Use while implementing any feature or bugfix, or for a plan task.
effort: medium
allowed-tools: Read, Grep, Glob, Bash(ugrep *), Bash(rg *), Bash(grep *), Bash(evidence record *), Bash(ctx learn line)
argument-hint: "[behavior to implement | task <N>]"
---
# /tdd — TDD Engine
> **Bundled command:** if `ctx` is not found, run it as `${CLAUDE_PLUGIN_ROOT}/tools/ctx`, or skip it.
> **Bundled command:** if `evidence` is not found, run it as `${CLAUDE_PLUGIN_ROOT}/tools/evidence`, or skip the record.
Enforce strict red → green → refactor discipline for all implementation work. General TDD and per-task plan execution are one engine.
## Match the project's conventions (read before you write)
Before implementing, discover and read the repo's own standards — `CLAUDE.md`, any `code-review.md` / `CONTRIBUTING` / `STYLEGUIDE`, and the linter/formatter config — and mirror the patterns already in the files you touch. Conventions a formatter can't enforce (async/await over `.then`, error-wrapping, naming, locale-code format) are still binding — apply them **as you write**, not after a reviewer flags them. See [lore/code-standards.md](../../lore/code-standards.md).
## Effort
Scale `/effort` to task size: low for a one-line fix, medium for normal work, high for a complex multi-behavior task (`xhigh` for a hard multi-layer one; `max` is an opt-in). Across a run: `medium` for implementation turns, `high` for check/review/security turns; on Bedrock/Vertex/gateways hold one level (an effort change drops the cache there). See [lore/models.md](../../lore/models.md).
The failing test *is* the verification. Don't add a self-review step after green — re-reading your own diff to confirm it is redundant on current models. Let RED → GREEN → REFACTOR and [/check](../check/SKILL.md) carry the proof. See [lore/model-behavior.md](../../lore/model-behavior.md).
## Autonomy
Gates: none. Everything else runs without asking, except one plain question when the spec does not define the behavior (see "If you cannot write the test first").
This skill pre-approves reads, searches and `evidence record` only, because TDD edits arbitrary source: test runs, edits and the per-task commit go through Claude Code's normal permission prompt outside auto mode ([lore/autonomy.md](../../lore/autonomy.md)).
## Two modes
- **Freeform** (`/tdd <behavior>`): drive TDD for whatever you're implementing now.
- **Task mode** (`/tdd task <N>`): execute task N from the current plan in `.workspace/shared/plans/`. Take the plan from the request, else the plan this session approved, else the newest one in `.workspace/shared/plans/`, and say which. Do not ask. Read the task text from the plan first.
- **Plan folder** (`plan.json` next to `plan.md`): read `plan.json` with Read; task N is `steps[N-1]` — its `red` (test, code, run), `green` (sketch, run), `verify`, `files` and the top-level `constraints` are the task text. A step whose `review.status` is `deferred` is not executed this run: say so and stop. If the last line of `plan.md` (`<!-- magician.plan/1 v<n> … -->`) names a version other than `plan.json.version`, say the plan is stale and ask the user to re-run `plan-render all <dir>/plan.json` before continuing.
- **Single `plan.md`** (legacy): read the `### Task N` block as before.
## The Law
1. **RED** — Write a failing test describing exactly one behavior. Run it and read the output: it must fail **for the reason under test** — your assertion, with a meaningful message, not a compile error, missing import, or typo. A failure for the wrong reason is a false RED → back to RED (fix the test, re-run), never forward to GREEN. If implementation code for this behavior already exists (written before its test), delete it and re-derive it from the test — code the test never drove is unproven.
2. **GREEN** — Write the minimum code to pass. Ugly is fine. Add no untested logic. Re-run the same test; RED→GREEN is proven by the two runs you watched — the real RED output, then GREEN — not by "it should pass" ([lore/verification.md](../../lore/verification.md)).
3. **REFACTOR** — Clean up implementation and tests. No behavior change. All tests stay green.
4. Repeat for the next behavior.
## Vertical tracer bullets
Go end-to-end for one behavior before expanding: first test → first implementation → works → next behavior.
## What counts as one behavior
One function doing one thing · one API endpoint with one response case · one UI component in one state. NOT "the whole auth system".
## Test quality rules
- Test names describe behavior: `test_returns_404_when_user_not_found`
- Test observable behavior, not implementation internals
- No `assertTrue(true)` — always-pass tests are worse than none
- One assertion per concept
## If you cannot write the test first
The spec is incomplete. Do not guess. Ask: "I can't write this test yet — the spec doesn't define what [behavior] should do. Clarify the expected input and output?" **End your turn. Wait for clarification before writing code.** But if you are running as a dispatched subagent with no human present to answer, do not wait — return an Obstacles block (see below) and stop: NEEDS_CONTEXT when the spec or another named input is missing or unreadable, BLOCKED for a gap in a spec that exists. Name the exact gap.
## Per task (task mode only)
After the behavior(s) for the task are green and refactored:
1. Run the project's **formatter + linter** (the ones CI/review actually use) and type-check — **fix style/lint before committing.** A convention the reviewer or `code-review.md` would flag (e.g. async/await vs `.then`) is a failing gate, not a post-review fixup ([lore/code-standards.md](../../lore/code-standards.md)).
2. Run the full test suite — no regressions. Then `evidence record --kind tests --cmd "<suite command>" --exit <code>` (the full suite only, never one test), so `/check` does not run it again on this code. In a plan folder, the step's `verify` commands are the definition of done `/breakdown` wrote from the project's `verify` skill, `REVIEW.md` or the stack lore: run them exactly as written, every one, and treat a command you had to change as a plan defect to report, not a thing to paper over.
3. Commit with a conventional commit message.
4. Mark the task complete in the plan file (`- [ ]` → `- [x]`). In a plan folder, tick the boxes in `plan.md` only; `plan.json` carries no progress and its `version` is not bumped for this. The plan file is the checklist, and `.workspace/local/session-state.md` is the compaction-proof state: write it before you start a multi-task run and after each task lands.
## Obstacles
If this skill runs as a dispatched unit and hits something that blocks or degrades the work, do not wait for a human who is not there and do not silently ship a degraded result — return the Obstacles block from [lore/obstacles.md](../../lore/obstacles.md) (fields: STATUS, OBSTACLE, BLOCKER, SEVERITY, WORKAROUND, RECURRENCE, SCOPE, NEXT) to the caller alongside whatever you completed; interactively, say the same in prose.
## Completion Signal
- Freeform: "TDD complete: <n> behaviors, <n> tests green." Standalone, run the full suite once after the last behavior, record it the same way and add its result.
- Task mode: "Task N complete (<commit>). <done> of <total> tasks done."
The signal is the task state. Under a parent skill (`/build`, `/deliver`, `/critique`) the parent picks the next task or step. Print no next command.
In a top-level interactive run, run `ctx learn line` last and append the line it prints, unchanged. Print nothing under a parent skill or in a dispatched or headless run.