Skip to content
Back to skills

Test Driven

ASecurity

Write tests that pin behaviour, test-first: red/green/refactor in vertical slices, what is worth testing, mocking only at system boundaries, fixing flaky tests. Use when building test-first, adding or fixing tests, or chasing a flaky suite.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 29, 2026
ai-agentsgotestingdebuggingapidatabase

Works with

  • cli
  • api

Security analysis

A100/100

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

Scanned November 29, 2026

npx -y skills add k6w/baton --skill test-driven --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Test Driven?

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

Security grade badge for Test Driven
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/k6w-test-driven/badge)](https://www.skillsdirectory.com/skills/k6w-test-driven)

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: test-driven
description: "Write tests that pin behaviour, test-first: red/green/refactor in vertical slices, what is worth testing, mocking only at system boundaries, fixing flaky tests. Use when building test-first, adding or fixing tests, or chasing a flaky suite."
keywords: [test, tests, tdd, unit test, integration test, red green, coverage, mock, stub, fake, fixture, flaky, assertion, spec]
---
# Test-driven work

A good test states a behaviour in the project's own words ("an expired token is refused") and keeps
passing through any refactor that keeps that behaviour. A test that breaks when nothing a user could
notice has changed is a cost, not a safety net.

## Before the first test

- Find how the project tests: the test runner, file naming, fixtures, helpers, the command in
  `package.json` / `Makefile` / `pyproject`. Follow it exactly; do not bring in a second framework.
- Decide the **seams**: the public interfaces you will test through (an exported function, an HTTP
  route, a CLI command). Test there and nowhere deeper. If no clean seam exists, the design is the
  problem (see `lean-code`).
- List the behaviours to cover, most important first: the main path, the edge cases that bite
  (empty, zero, one, many, unicode, very large, duplicate, out of order), the error paths.

## The loop, one slice at a time

1. **Red.** Write one test for the next behaviour. Run it and see it fail *for the right reason* (an
   assertion about the behaviour, not a typo or a missing import).
2. **Green.** Write the least code that makes it pass. No code for tests you have not written yet.
3. **Refactor.** With everything green, tidy names and remove duplication in both the code and the
   test. Behaviour does not change in this step; run the tests after each edit.

Do not write all the tests first and all the code after: tests written ahead of understanding check
the shape you imagined, not the behaviour you built. One test, one piece of code, repeat.

## What makes a test worth keeping

- **Asserts outcomes through the interface**: return values, responses, files written, events
  emitted. Not private fields, call counts on your own functions, or internal state.
- **Expected values come from outside the code**: a literal you worked out by hand, an example from
  the spec. Never recompute the expectation the same way the code does; that test can't fail.
- **Readable as a spec**: the name says the behaviour; the body is arrange, act, assert with only the
  details that matter to this case.
- **Independent**: no ordering between tests, no shared mutable state, each cleans up what it made.
- **One reason to fail**: if it fails, the name tells you what broke.

## Mocking

Fake only what you don't own or can't control: the network, third-party APIs, the clock, randomness,
sometimes the filesystem or database (prefer a real temporary one when it is cheap). Never mock your
own modules to test another of your modules. Details and patterns:
`load_skill("test-driven", "references/mocking.md")`.

## Flaky tests

A test that sometimes fails is a bug in the test or the code, never noise to retry away. Diagnosis
and fixes: `load_skill("test-driven", "references/flaky-tests.md")`. Use `debugging` to find a real
race in the product code.

## Rules

- Never weaken, skip or delete a test to get green. If a test is wrong, say why in the report.
- Don't change production code beyond the task; report bugs you find to the lead instead.
- Finish by running the full relevant suite and the task's acceptance command; report the exact
  commands and results.

Files in this skill

  • SKILL.md3.5 KB
  • references/flaky-tests.md1.4 KB
  • references/mocking.md1.6 KB

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.