Index of every page on this site: llms.txt
All skills
Run it yourself

Test-driven development: the agent writes the failing test, then the code, one behavior at a time. Use when building a feature or fixing a bug test-first, or when the user says tdd, red-green, or test-first.

  • 1 file
  • 2.4 KB
  • Updated 3 weeks ago
  • GitHub
Use this Skill: https://skilld.dev/gh/masihmoafi/skills/tdd

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈53 tokens for metadata: the name and description. ≈545 when used: this file.

Description uses 2.7% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈213 characters, or 2.7%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Test-driven development

Write the failing test, then the code that passes it, one slice at a time.

Before the first test

  1. Name the behavior in one line: input, expected outcome, non-goals.
  2. Pick the seam, the public boundary you test at (function, CLI, HTTP route, rendered UI).
  3. Find the repo's test command and run it once for the baseline.

The loop

  1. Red. One test for the next smallest behavior; run only it. It must fail because the behavior is missing; a typo, import or fixture failure is not red. If it passes at once, it is a characterization test: pick a behavior that is actually missing.
  2. Green. The smallest code that passes; rerun that test.
  3. Next slice. Let this slice shape the next test; never write them all up front.

Refactor once the behavior is complete and green, then rerun the relevant suite.

Code written before its test is deleted, not kept "as reference": a test written after passes at once and proves nothing. Exploring first is fine; throw the exploration away, then start at red. A test that is hard to write means an interface that is hard to use: simplify the interface.

A good test

  • Checks behavior through the seam and survives a refactor that keeps it.
  • Has one reason to fail; deterministic and fast.
  • Takes its expected value from an independent source. assert add(a, b) == a + b can never fail; assert add(2, 3) == 5 can.
  • Mocks only external boundaries (network, paid APIs, clock); makes no paid calls. A fake proves only the fake's boundary: say so.
  • For model and ML code, test the deterministic parts (transforms, parsing, shapes, prompt assembly, scoring math); model quality is an experiment.

Bugs

Write the regression test first and show it failing on the current code for the intended reason; a regression test that never failed proves nothing.

Done

Show the test command's red output before, the same command green after, and the wider suite green. Label the work honestly: TDD, regression test, characterization test or refactor.

Sources: mattpocock/skills (tdd); obra/superpowers (test-driven-development, MIT).

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at c0a5d13. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last week.

Activeupdated 3 weeks ago

README badge

README badge for masihmoafi/skills/tdd