agentleFS
anivaranivar/agentic-sdlc/skills/test-first/SKILL.md

test-first

Skill0 starsChanged 37 days agoMITView on GitHub

Build and fix test-first at seams agreed in advance: write the failing test, write only enough code to pass it, take expected values from an independent source rather than from the code, mock only at system boundaries, gate every commit on exit codes, run suites one at a time against shared state, and enumerate the branches before repairing a failing test. Triggers on: "TDD", "test first", "red green", "write a failing test", "add tests", "integration test", "fix the test", "the test is flaky", "coverage", "what should we test".

26 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use security-sweep, refactor and 3 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.
  • n24q02mSkill

    security-sweep

    Graph-driven security sweep -- scan for dangerous sinks, then rank each finding by whether an entry point can actually reach it, and triage the rest into suppressions.

    Also in 3 projects that use this

  • GitHubSkill

    refactor

    Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.

    Also in 4 projects that use this

  • MicrosoftSkill

    api-design

    Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.

    Also in 3 projects that use this

  • GoogleSkill

    code-review

    Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.

    Also in 4 projects that use this

  • SentrySkill

    skill-creator

    Create new agent skills following the Agent Skills specification. Use when asked to "create a skill", "add a new skill", "write a skill", "make a skill", "build a skill", or scaffold a new skill with SKILL.md. Guides through requirements, writing, registration, and verification.

    Also in 3 projects that use this

The file

Files
SKILL.md

Test first

The loop is red then green. These rules make the loop produce tests worth keeping. Every section applies on every cycle. Read the glossary first so test names use the project's words.

The rules

IdRuleIn practice
TEST-1Seams agreed before testsWrite down the seams under test and confirm them with the decider. Each proposed seam gets one line on what it catches and what it misses. No test at an unconfirmed seam.
TEST-2Red before greenThe failing test first, then only enough code to pass it. One seam, one test, one minimal implementation per cycle. No speculative features. A refactor is its own slice after green (SLICE-3), not part of the loop.
TEST-3Expected values from an independent sourceA known-good literal, a worked example, the specification, with the derivation in the test. Never expect(add(a, b)).toBe(a + b). A test that asserts only a range or a sign is the class that let wrong figures through a passing suite.
TEST-4Mock only at system boundariesExternal services, time, randomness, the file system. Never the code under test, pure functions, value objects or internal collaborators. Inject boundaries; prefer one function per external operation over a generic fetcher.
TEST-5Gate on exit codescheck && test first; the commit follows on its own go-ahead, gated on the exit codes (just check && git commit once the yes is given). A check whose failure is printed and ignored gates nothing. After a pass on unchanged code, do not re-run for reassurance (SLICE-4).
TEST-6Suites one at a time against shared stateA number that moves between identical runs is a harness artefact (EVID-5). Run suites that share a database one at a time; compare named failures, not counts.
TEST-7Enumerate branches before repairingList the branches the code takes before touching a failing test. A better-shaped test often beats a patched one. Confirm with the mutation check (REVIEW-4).

What a good test is

It verifies behaviour through the public interface (DESIGN-2). It reads like a specification: "user can check out with a valid cart" says what capability exists, and survives refactors because it does not care about internal structure. Examples and anti-patterns are in references/good-and-bad-tests.md.

Anti-patterns

  • Implementation-coupled: mocks internal collaborators, tests private methods, verifies through a side channel. The tell: it breaks on a refactor that changed no behaviour.
  • Tautological: the assertion recomputes the expected value the way the code does.
  • Horizontal slicing: all tests first, then all implementation. Tests of imagined behaviour go insensitive to real changes. Work in vertical slices: one test, one implementation, repeat.

Companion skills

NeedSkill
Where the seam belongsinvoke deep-modules first when the interface is in question
The mutation check and the review of testsreview-change
Landing each cycle as a reviewable piecethin-slices

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.