agentleFS
Sequela02Sequela02/canasta/skills/workflow/tdd/SKILL.md

tdd

Skill0 starsChanged yesterdayMITView on GitHub

Change behavior test-first in small vertical slices, design trustworthy test oracles, or diagnose flaky, slow, redundant, or weak tests. Not for restructuring that keeps behavior (refactor).

194 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use capture-learning-tools, design-frontend-dev 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.
  • The-Vibe-CompanySkill

    capture-learning-tools

    Turn technical conversations, bugs, CI failures, review comments,

    Also in 5 projects that use this

  • The-Vibe-CompanySkill

    design-frontend-dev

    Clean Impeccable frontend design skill. Use when the user wants to

    Also in 5 projects that use this

  • tristanphvnSkill

    ketchup-video

    Catch the user up like /keel:ketchup, with a short silent video of slides for what happened and the waiting calls as text under it. Use for /keel:ketchup-video.

    Also in 14 projects that use this

  • jaydubya818Skill

    figure-it-out

    Use when novel or multi-phase work needs an auditable workflow and no narrower playbook fits.

    Also in 54 projects that use this

  • jaydubya818Skill

    principle-laziness-protocol

    Apply when a refactor is adding wrappers or abstractions instead of simplifying.

    Also in 45 projects that use this

  • +2 more from The-Vibe-Company
  • +5 more from jaydubya818

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. 0 are common, 14 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 186 edited versions we read keep these.

  • 14

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never edit, delete, skip, or weaken a test to make it pass.

    line 16
  2. Distinctive:

    Do not special-case test inputs or detect the test environment in production code.

    line 18
  3. Distinctive:

    Do not mock code you own. Mock only at real system boundaries (network, clock, third-party services), and keep the semantics the claim …

    line 20
  4. Distinctive:

    Do not write all tests up front.

    line 25
  5. Distinctive:

    Write one test for the smallest behavior that can fail and pass on its own.

    line 46
  6. Distinctive:

    Run it and confirm it fails because the behavior is absent, not because of syntax, environment, fixtures, or an unrelated baseline failure.

    line 47
  7. Distinctive:

    Use the narrowest layer that faithfully observes the behavior:

    line 60
  8. Distinctive:

    Follow risks and oracles, not fixed pyramid ratios.

    line 70
  9. Distinctive:

    Before adding a test, search the owning layer for one that covers the same behavior and strengthen it instead.

    line 84
  10. Distinctive:

    Remove obsolete or implementation-coupled tests only with evidence that the behavior stays protected elsewhere.

    line 90
  11. Distinctive:

    Use synthetic, portable values.

    line 95
  12. Distinctive:

    Use isolated temporary resources, and restore clocks, environment, globals, working directory, mocks, files, and handles.

    line 97
  13. Distinctive:

    Every test file added, changed, or deleted, with the reason for each.

    line 107
  14. Distinctive:

    Do not claim that red-green-refactor itself proves correctness.

    line 111

“Common” is measured: kept by at least 6 in 10 of the 186 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

Work in small behavior increments, each proven by a test that failed for the right reason first. Test-first order is a feedback discipline, not a quality guarantee; the evidence is in references/evidence.md.

Agent failure modes

Coding agents fail at TDD in known ways. These rules override convenience:

  • Never edit, delete, skip, or weaken a test to make it pass. If a test looks wrong, stop and report why; changing it is the operator's decision.
  • Do not special-case test inputs or detect the test environment in production code.
  • Do not mock code you own. Mock only at real system boundaries (network, clock, third-party services), and keep the semantics the claim depends on.
  • Give each assertion an independent oracle: a requirement, a known example, or a domain rule. A test that duplicates the implementation's calculation can preserve its mistakes instead of detecting them.
  • Do not write all tests up front. Tests written before any implementation describe imagined behavior.

Before the first test

  1. Identify the observable behavior, its owning boundary, affected consumers, and the closest existing test owner.
  2. Choose the seam: the public interface where the behavior is observed without reaching inside. Test only through agreed seams; when the seam is unclear, ask before writing tests.
  3. Choose the oracle. A specification or regression oracle comes from a requirement, contract, issue reproduction, or domain invariant, never only from the current implementation. A characterization oracle records current behavior and counts as preservation evidence only.
  4. In unclear legacy code, add narrow characterization tests first, then the intended failing test.

Vertical slices

Repeat for each increment, one test at a time:

  1. Write one test for the smallest behavior that can fail and pass on its own.
  2. Run it and confirm it fails because the behavior is absent, not because of syntax, environment, fixtures, or an unrelated baseline failure.
  3. Implement only enough to pass it, preserving repository invariants.
  4. Rerun it and read the result, not just the exit code.
  5. Refactor only while behavior stays the same, rerunning the tests that cover the affected code and its callers.

Then run the owning suite and affected downstream suites; widen to the full gate when risk, integration, or repository rules require it. If a failing test is impractical, say why and use the closest independent executable check.

Choose the layer by risk

Use the narrowest layer that faithfully observes the behavior:

  • Pure or domain tests for calculations, decisions, state transitions, invariants.
  • Integration tests for real wiring, persistence, protocols, configuration, and dependency behavior invisible below the boundary.
  • Contract tests for agreed consumer and provider shape and semantics.
  • End-to-end tests for a few critical journeys lower layers cannot prove.
  • Runtime-specific probes when the runtime, browser, OS, or packaging changes behavior.

Follow risks and oracles, not fixed pyramid ratios. To prove a change in the running product, follow references/end-to-end-verification.md.

Hard bugs

For a reported failure, reproduce it before fixing it. When the cause is not obvious, follow references/diagnosing-bugs.md: build a command that goes red on this exact symptom, minimise it, test falsifiable hypotheses, and turn the minimal repro into the regression test. Set a budget for the investigation and report what was tried when it runs out; a trivial bug needs no ranked hypothesis list.

Keep tests valuable

  • Before adding a test, search the owning layer for one that covers the same behavior and strengthen it instead.
  • A new test must protect a distinct behavior, regression, boundary, or failure mode, and fail with an actionable message.
  • Coverage finds unexercised code; targeted mutation on changed, high-risk code checks assertion sensitivity. Neither percentage is a goal or proof.
  • Remove obsolete or implementation-coupled tests only with evidence that the behavior stays protected elsewhere.

Determinism and fixtures

  • Use synthetic, portable values. Never put operator paths, credentials, tokens, or raw incident payloads in tests.
  • Use isolated temporary resources, and restore clocks, environment, globals, working directory, mocks, files, and handles.
  • Replace sleeps with a deterministic clock or event.
  • A retry that passes is evidence of nondeterminism, not verification. Fix the cause, or quarantine with an owner, reason, and removal condition.

Completion report

  • Behavior covered, oracle source, layers, and the focused and broader gates run with their results.
  • Every test file added, changed, or deleted, with the reason for each. A change to an existing assertion must name the requirement that justifies it.
  • Residual untested risk.

Do not claim that red-green-refactor itself proves correctness.

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.