agentleFS
michael-muirmichael-muir/agentic-dev-kit/skills/test-driven-slices/SKILL.md

test-driven-slices

Skill1 starsChanged 13 days agoMITView on GitHub

Use whenever writing tests or making tests pass, for red-green-refactor one behaviour at a time through agreed public seams, with rules that separate tests that prove behaviour from tests that only look busy.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    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:

    Refactor: only on green. Improve names and structure, and re-run after each change.

    line 13

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “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

Test-driven slices

The loop

  1. Red: one test, for one behaviour, at an agreed seam. Run it and watch it fail for the right reason: the behaviour is missing, not a typo or a fixture error.
  2. Green: the least code that makes it pass. No options, branches or abstractions that no test asks for yet.
  3. Refactor: only on green. Improve names and structure, and re-run after each change.
  4. Repeat for the next behaviour. One slice at a time: each test teaches you something that shapes the next one.

In this kit the work is split across two roles. The test-designer writes the acceptance tests for a task slice (one per AC) before implementation, and locks them. The implementer then runs the inner loop above, adding their own small unit tests as needed. Writing every test for the whole spec up front is avoided: tests written far ahead of the code tend to pin imagined behaviour.

Seams

Agree the seam (the public interface a test calls) before writing the test, and record what it catches and misses. Prefer the highest seam that still runs fast and deterministically.

A good test

  • Calls only the public interface, and asserts observable behaviour: return values, emitted events, persisted state read back through the public interface, and errors.
  • Reads like a line of the spec, with the AC id and the behaviour in the name.
  • Takes its expected values from an independent source: the spec, a worked example by hand, or a known-good literal.
  • Survives a refactor that keeps the behaviour.
  • Is deterministic: it controls the clock, randomness, ordering and I/O.

Smells to reject

SmellSignInstead
TautologicalThe expected value is computed with the same logic as the codeHard-code the value from the spec or a worked example
Implementation-coupledMocks internal collaborators, calls private functions, or checks a side channelGo through the seam, and assert the outcome
Over-mockedMore mock setup than assertions; mocks of your own modulesFake only at process edges: network, clock, randomness, external services
Assertion-freeIt "passes" because nothing threwAssert the specific outcome
Snapshot dumpA large snapshot accepted without reading itAssert the few fields that matter
FlakyIt passes on re-runHand it to the debugger. It is a bug in the test or the code

Done when

  • The test was seen failing first, and the failure reason is recorded.
  • The test passes with the smallest implementation.
  • Nobody can delete the behaviour and keep the test green. Mutation testing checks this in CI.

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.