agentleFS
guangzanguangzan/monorail/skills/rail-tdd/SKILL.md

rail-tdd

Skill5 starsChanged 4 months agoMITView on GitHub

Test-driven development with red-green-refactor. Use when building a behaviour test-first, fixing a bug with a regression test, or when rail-build needs TDD at an agreed seam.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When exploring the codebase, read docs/monorail/CONTEXT.md (if it exists — check with the shell, not a search tool, which skips gitignored …

    line 10
  2. Distinctive:

    Test only at pre-agreed seams: Before writing any test, write down the seams under test.

    line 22
  3. Distinctive:

    Ask: "What's the public interface, and which seams should we test?"

    line 27
  4. Distinctive:

    Red before green: Write the failing test first, then only enough code to pass it.

    line 37
  5. Distinctive:

    Refactor after green: When the suite is green, look for refactor candidates.

    line 39

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

Rail TDD

TDD is the red → green loop. This skill is the reference that makes that loop produce tests worth keeping.

When exploring the codebase, read docs/monorail/CONTEXT.md (if it exists — check with the shell, not a search tool, which skips gitignored paths) so vocabulary matches the project's domain language, and respect ADRs under docs/monorail/adr/ in the area you're touching.

What a good test is

Tests verify behavior through public interfaces, not implementation details. A good test reads like a specification and survives refactors.

See tests.md for examples and mocking.md for mocking guidelines.

Seams — where tests go

A seam is the public boundary you test at. Tests live at seams, never against internals.

Test only at pre-agreed seams. Before writing any test, write down the seams under test.

  • Standalone /rail-tdd: confirm the seams with the user once before writing. No test is written at an unconfirmed seam.
  • Inside /rail-build: the task's Seams: line is already agreed — it was set at slice time from the spec's code-anchored ## Testing Decisions. Record it, do not re-confirm with the user; if opening the seam's anchor file shows the code contradicts a listed seam, stop and report per build §4 rather than re-deriving seams. No test is written at a seam not on the task's Seams: line.

Ask: "What's the public interface, and which seams should we test?"

Anti-patterns

  • Implementation-coupled — mocks internals, tests private methods, or verifies via side channels. Tell: breaks on refactor with unchanged behaviour.
  • Tautological — assertion recomputes the expected value the way the code does. Expected values need an independent source of truth.
  • Horizontal slicing — all tests first, then all implementation. Work in vertical slices instead — one test → one implementation → repeat.

Rules of the loop

  • Red before green. Write the failing test first, then only enough code to pass it.
  • One slice at a time. One seam, one test, one minimal implementation per cycle.
  • Refactor after green. When the suite is green, look for refactor candidates. Never refactor while red. Re-run tests after each refactor step.

Completion

A behaviour is done when its failing test went red, then green, any needed refactor kept the suite green, and the agreed seam still holds.

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.