Skip to content
Back to skills

Tdd

ASecurity

Change behaviour test-first, with a test that is red before the code change and green after, using the repository's own test commands. Use when the user says TDD, test first, red green refactor, write a failing test, add a unit or regression test, or when adding logic, a function or an edge case. Not for root-causing failures (diagnose) or live checks (prove-it-live).

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentsgogitapidatabase

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add Ilexpwh/istack --skill tdd --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tdd?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Tdd
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ilexpwh-tdd/badge)](https://www.skillsdirectory.com/skills/ilexpwh-tdd)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: tdd
description: Change behaviour test-first, with a test that is red before the code change and green after, using the repository's own test commands. Use when the user says TDD, test first, red green refactor, write a failing test, add a unit or regression test, or when adding logic, a function or an edge case. Not for root-causing failures (diagnose) or live checks (prove-it-live).
metadata:
  phase: build
---

# TDD

A behaviour change that lands with a test that failed before it and passes after it, run with the commands this repository actually uses.

## When to use
- Any behaviour change: new logic, a bug fix, an edge case, a changed contract.
- A worker brief (`../istack-mode/worker.md` asks for the failing test first).
- The user asks for a regression test, test first, or red-green-refactor.

**Not for:** finding why something fails (`diagnose` finds the cause, then hands the fix here), checking a running target (`prove-it-live`), or docs, config and copy changes with no behaviour to assert.

## Steps
1. **Find the real test commands.** Read how this repository tests: CI workflow files, `Makefile`, `package.json` scripts, `pyproject.toml`, `go.mod`, `Cargo.toml`, `build.gradle`, README and CONTRIBUTING. Prefer checked-in wrappers (`make test`, `./gradlew test`, a repo script) over global tools. Write down two commands: one that runs a single test, and the one CI gates on. Never assume `npm test`. If tests need a service or env var, look in the profile, `AGENTS.md`, CI service definitions and compose files before asking. *Done when:* both commands ran once on the unchanged code and the baseline is recorded (all pass, or the names of tests that already fail).
2. **Pick the narrowest level that can see the behaviour.** Prefer an existing unit test file for that code path, then component or integration, then end-to-end only if nothing lower can observe it. Follow the neighbours' layout, naming and fixtures. If no cheap test path exists, use the closest executable check (a script, or a harness from `build-harness`) and say so in the reply. *Done when:* you can name the file the test goes in and the existing test it sits next to.
3. **Red.** Write one test that states the intended behaviour through the public interface, not the implementation. For a bug, reproduce the reported symptom: the input and the wrong output from the report or from `diagnose`. Run it with the single-test command. *Done when:* it fails, and the failure is about the behaviour (wrong value, missing field, wrong status), not an import error, a typo or a missing fixture.
4. **Green.** Write the smallest production change that makes the test pass (`smallest-change`). Don't edit the test to get there. *Done when:* the new test passes and the command output is saved.
5. **Refactor.** With the test green, tidy only the code you touched: names, duplication, dead branches. Rerun the test after each edit. Add no behaviour in this step. *Done when:* the test is still green and the diff holds no unrelated cleanup.
6. **Run the suite.** Run the CI-gated command and compare it with the step 1 baseline. *Done when:* no test that passed at baseline fails now, and tests that already failed are listed by name, not hidden.
7. **Commit so history shows red then green.** For a bug fix, commit the failing test first and the fix on top when the branch convention allows; otherwise one commit holding both. The message says which behaviour changed and names the test. *Done when:* `git log` shows the commit(s) on your `<type>/<slug>` branch.
8. **Keep the evidence.** Save the red output and the green output: in run mode as a file under the ledger's `run/evidence/`, else in the handback's EVIDENCE line. *Done when:* someone else can rerun both commands and see the same results.

## Red flags
| If you're thinking | Do this instead |
|---|---|
| "The new test passed on the first run. Great." | Suspect it. Revert the fix or break the code on purpose; if the test still passes, it tests nothing. |
| "`npm test` is probably the command." | Read the CI config and build files. Run what CI runs. |
| "This old test fails now; I'll skip it, mark it flaky, or loosen the assert." | No skipped, disabled or weakened tests. Either the behaviour change is intended (update the test and say why) or you broke something. |
| "Tests pass, so it's done." | Tests cover the code path. The outcome still needs `prove-it-live` on the target (`seen-working`). |
| "I'll mock everything so it runs fast." | Mock only what crosses a boundary you don't own. A test of mocks proves the mocks. |
| "I'll write the fix first and add the test after." | Then you never saw it fail. Test, red, fix, green. |
| "I don't know how to start the test database; I'll ask." | Check the profile, `AGENTS.md`, CI service definitions and compose files first. Ask only if none of them say. |
| "The fixture needs a real API key." | Use a dummy value or a variable name. Never commit a real secret (`secrets-stay-out`). |

## Verify
- [ ] The test commands came from the repository's CI or build files, not a guess.
- [ ] The new test failed for the intended reason before the change, and that output is saved.
- [ ] The new test passes after the change, and the suite has no new failures against the baseline.
- [ ] No test was skipped, disabled, deleted or loosened, unless the reply names it and says why.
- [ ] The diff holds the test and the smallest fix, nothing else.

## Reply
```
Test: <file>::<name>, asserts <behaviour>.
Red: <single-test command> → <failure line>.
Green: <single-test command> → pass.
Suite: <CI command> → <passed>/<total>; already failing before: <names or none>.
Changed: <files>, commits <short shas>.
Next: <review-change, or prove-it-live for the running target>.
```

## Credits
"Discover the stack first" and the prove-it pattern for bugs come from Addy Osmani's `test-driven-development` in addyosmani/agent-skills. Failing-before evidence, the narrowest-check rule and landing the failing test before the fix come from pstack's `tdd` skill by Lauren Tan.

Files in this skill

  • SKILL.md5.9 KB
  • agents/openai.yaml163 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.