agentleFS
AbdurRafay2004AbdurRafay2004/handoff/skills/tdd/SKILL.md

tdd

Skill4 starsChanged 5 months agoMITView on GitHub

Use when building any T3 feature or bugfix, recommended for T2 on the affected path — write the failing test before the implementation, one behavior at a time, through public interfaces.

193 other projects use a version of this, 36 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use make-bot-ui, Poteto Mode and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • eryzerzSkill

    make-bot-ui

    Use when building a custom UI (page, dashboard, buttons) that should wake a Grok Bot over a webhook, when the user must provide a webhook sender key, or when exposing that UI on Tailscale.

    Also in 8 projects that use this

  • jtarorehSkill

    Poteto Mode

    poteto's agent style for concise, detailed responses, deliberate subagents, unslopped prose, simple code, and verified work. Use for poteto, /poteto-mode, or requests to work in this style.

    Also in 5 projects that use this

  • risadamsSkill

    which-skill

    Router over this pack's skills and flows. Ask it "which skill fits X" when you don't remember what's available.

    Also in 7 projects that use this

  • TheOnlyFusionCubeSkill

    principle-attack-the-premise

    Inventory who actually owns or exhibits the imbalance, then challenge the shared premise before writing another patch. Use when two or more fixes that share one premise have failed the same gate.

    Also in 11 projects that use this

  • TheOnlyFusionCubeSkill

    principle-test-behavior-not-implementation

    Call the system the way its consumer does and assert meaningful observable output; avoid mocks or assertions that only mirror internal calls. Use when when writing or evaluating tests.

    Also in 11 projects that use this

  • shreyT19Skill

    principle-laziness-protocol

    Apply when refactoring, evaluating diff size, or tempted to add abstractions, layers, or signal threading. Bias toward deletion and the smallest change that solves the problem.

    Also in 22 projects that use this

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 177 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Core proof: if you didn't watch the test fail, you don't know it tests the right thing.

    line 31
  2. Very specific:

    Read the nearest CONTEXT.md / .handoff/context/ so test names match the project's domain language.

    line 53
  3. Very specific:

    Look for deep-module opportunities — small interface, deep implementation (see design).

    line 60
  4. Distinctive:

    Write ONE test confirming ONE thing about the system.

    line 66
  5. Distinctive:

    Don't anticipate future tests.

    line 75
  6. Distinctive:

    Verify RED is mandatory: If the new test passes immediately, it's testing existing behavior — fix the test.

    line 76

“Common” is measured: kept by at least 6 in 10 of the 177 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

TDD

Part of the Build phase — see the workflow skill for tiers and sequencing.

Tier rule: mandatory for T3 (money, auth, user data, migrations); recommended for T2 on the affected path; skipped for T1 (copy/styling). Within its tier, the discipline is absolute: no production code without a failing test first. Bug fixes always get a failing test reproducing the bug, at any tier — a fix without a test doesn't stick.

Philosophy

Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.

Good tests are integration-style: they exercise real code paths through public APIs and read like a specification — "user can checkout with valid cart" tells you exactly what capability exists. They survive refactors because they don't care about internal structure.

Bad tests are coupled to implementation: they mock internal collaborators, test private methods, or verify through side channels (querying the database directly instead of using the interface). The warning sign: the test breaks when you refactor but behavior hasn't changed.

Core proof: if you didn't watch the test fail, you don't know it tests the right thing. A test written after the code passes immediately — and passing immediately proves nothing.

Anti-pattern: horizontal slices

Do not write all tests first, then all implementation. Bulk-written tests test imagined behavior — the shape of data structures rather than user-facing behavior — and become insensitive to real changes.

WRONG (horizontal):  RED: test1..test5  →  GREEN: impl1..impl5
RIGHT (vertical):    test1→impl1, test2→impl2, test3→impl3 ...

Vertical slices via tracer bullets: one test → one implementation → repeat. Each test responds to what the previous cycle taught you.

Workflow

1. Plan the behaviors

Read the nearest CONTEXT.md / .handoff/context/ so test names match the project's domain language. Then, before any code:

  • Confirm with the user what interface changes are needed.
  • Confirm which behaviors to test — you can't test everything; focus on critical paths and complex logic, not every edge case. (This is the PM decision: which failures are expensive?)
  • Look for deep-module opportunities — small interface, deep implementation (see design).
  • List behaviors, not implementation steps.

2. Tracer bullet

Write ONE test confirming ONE thing about the system. Watch it fail. Write minimal code to pass. This proves the path works end-to-end.

3. Incremental loop

For each remaining behavior: RED → verify it fails for the right reason → GREEN → verify it passes → next.

  • One test at a time; only enough code to pass the current test.
  • Don't anticipate future tests; no speculative features.
  • Verify RED is mandatory. If the new test passes immediately, it's testing existing behavior — fix the test. If it errors (rather than fails), fix the error until it fails correctly.
  • Verify GREEN completely: the new test passes, all other tests still pass, output pristine. Test fails → fix the code, not the test.

4. Refactor (only on green)

Extract duplication, improve names, deepen modules (move complexity behind simple interfaces). Run tests after each refactor step. Never refactor while RED. Don't add behavior.

Good vs bad tests

// ✅ Clear name, real behavior, one thing
test('retries failed operations 3 times', async () => {
  let attempts = 0;
  const operation = () => {
    attempts++;
    if (attempts < 3) throw new Error('fail');
    return 'success';
  };
  const result = await retryOperation(operation);
  expect(result).toBe('success');
  expect(attempts).toBe(3);
});

// ❌ Vague name, tests the mock, not the code
test('retry works', async () => {
  const mock = jest.fn()
    .mockRejectedValueOnce(new Error())
    .mockResolvedValueOnce('success');
  await retryOperation(mock);
  expect(mock).toHaveBeenCalledTimes(2);
});
  • One behavior per test; "and" in the name means split it.
  • Real code over mocks — mock only what's unavoidable (network, clock, true externals). If you must mock everything, the code is too coupled: inject dependencies instead. Boundary rules and mock-friendly interface design: references/mocking.md.
  • Testing mock behavior instead of real behavior is the classic false positive: the suite goes green while the product is broken.

Per-cycle checklist

[ ] Test describes behavior, not implementation
[ ] Test uses the public interface only
[ ] Test would survive an internal refactor
[ ] Watched it fail, for the expected reason
[ ] Minimal code to pass; nothing speculative
[ ] All tests green, output pristine

Common rationalizations

ExcuseReality
"Too simple to test"Simple code breaks. The test takes 30 seconds.
"I'll test after"Tests passing immediately prove nothing.
"Already manually tested"Ad-hoc ≠ systematic. No record, can't re-run.
"Deleting X hours is wasteful"Sunk cost. Keeping unverified code is debt.
"Test is hard to write"Listen to it: hard to test = hard to use. Simplify the interface.
"TDD will slow me down"Test-first is faster than debugging after.

When stuck

ProblemSolution
Don't know how to test itWrite the wished-for API; write the assertion first.
Test too complicatedThe design is too complicated. Simplify the interface.
Must mock everythingCode too coupled — inject dependencies.
Test setup hugeExtract helpers; still complex → simplify the design.

Adapted from mattpocock-skills (MIT, © 2026 Matt Pocock) and superpowers (MIT, © 2025 Jesse Vincent); see ATTRIBUTION.md.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.