agentleFS
seven-hills-softwareseven-hills-software/skillwright-skills/tdd-workflow/SKILL.md

tdd-workflow

Skill0 starsChanged 5 months agoMITView on GitHub

RED → GREEN → REFACTOR enforcement for new features and bug fixes. Tests precede implementation.

128 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use brand-discovery, configure-ecc 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.
  • ysyecustSkill

    brand-discovery

    Use when a brand needs to discover or articulate its identity through structured multi-session interviews. Covers purpose, positioning, audience, personality, voice, narrative, and founder-brand tension across 8 modules using laddering, 5 Whys, and projective techniques. Produces a resumable session with disk-persisted state and a master brandbook (90_SYNTHESIS.md).

    Also in 6 projects that use this

  • royaluniondesign-sysSkill

    configure-ecc

    Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.

    Also in 12 projects that use this

  • junimnjwSkill

    ralphinho-rfc-pipeline

    RFC-driven multi-agent DAG execution pattern with quality gates, merge queues, and work unit orchestration.

    Also in 12 projects that use this

  • loulanyueSkill

    nuxt4-patterns

    Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.

    Also in 10 projects that use this

  • royaluniondesign-sysSkill

    content-hash-cache-pattern

    Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.

    Also in 16 projects that use this

  • RojiosSkill

    dart-flutter-patterns

    Production-ready Dart and Flutter patterns covering null safety, immutable state, async composition, widget architecture, popular state management frameworks (BLoC, Riverpod, Provider), GoRouter navigation, Dio networking, Freezed code generation, and clean architecture.

    Also in 7 projects that use this

The file

We split this skill into the rules it gives an agent

12 rules. 0 are common, 11 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 117 edited versions we read keep these.

  • 11

    Distinctive

    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. Distinctive:

    Test-Driven Development is non-negotiable for new features and bug fixes.

    line 14
  2. Distinctive:

    Write the smallest possible test that captures the next slice of behaviour.

    line 29
  3. Distinctive:

    Run it. It must fail, and fail for the right reason (the assertion, not a syntax error).

    line 30
  4. Distinctive:

    Write the minimum code that makes the test pass.

    line 40
  5. Distinctive:

    Don't generalize ahead of the tests.

    line 42
  6. Distinctive:

    Run all tests, not just the new one.

    line 43
  7. Distinctive:

    Run all tests after every change.

    line 53
  8. Distinctive:

    Stop when the code reads cleanly.

    line 54
  9. Distinctive:

    One reason to fail per test: If a test could fail for two unrelated reasons, split it.

    line 59
  10. Very specific:

    Test that does nothing if a precondition fails: Use a precondition assertion or skip, not a silent early return.

    line 79
  11. Distinctive:

    Sleeping in tests: Use fake timers or polling with timeout.

    line 80
  12. Distinctive:

    Write a failing test that reproduces the bug.

    line 86

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

Test-Driven Development is non-negotiable for new features and bug fixes. Tests come first. The workflow has three phases. Do not skip phases.

The cycle

┌──────────────┐    ┌──────────────┐    ┌──────────────┐
│ 1. RED       │───▶│ 2. GREEN     │───▶│ 3. REFACTOR  │
│ Failing test │    │ Min code     │    │ Clean both   │
└──────────────┘    └──────────────┘    └──────────────┘
        ▲                                        │
        └────────────────────────────────────────┘

Phase 1 — RED

  1. Write the smallest possible test that captures the next slice of behaviour.
  2. Run it. It must fail, and fail for the right reason (the assertion, not a syntax error).
  3. The failure message must point at the missing behaviour. If it says "ReferenceError: foo is not defined", you wrote the test before the function signature exists — that's fine, as long as that's the point of this test.

What "smallest" means:

  • One assertion (or a small handful asserting the same fact).
  • One scenario.
  • One named test like returns_zero_for_empty_input or rejects_emails_without_domain.

Phase 2 — GREEN

  1. Write the minimum code that makes the test pass.
  2. Hardcoded values are allowed at this phase. return 0; is a valid GREEN if the only test asserts zero.
  3. Don't generalize ahead of the tests. Triangulation comes from adding more tests, not from speculative branches.
  4. Run all tests, not just the new one. Old tests still pass = no regression.

Phase 3 — REFACTOR

  1. With every test green, restructure for clarity and remove duplication.
  2. Acceptable refactors at this stage:
    • Extract method / parameter / variable.
    • Replace conditional with polymorphism.
    • Inline a too-thin abstraction.
    • Rename for accuracy.
  3. Run all tests after every change. Green stays green.
  4. Stop when the code reads cleanly. Don't over-design.

Rules

  • No production code without a failing test that demands it. Period.
  • One reason to fail per test. If a test could fail for two unrelated reasons, split it.
  • Tests describe behaviour, not implementation. processes_payment_when_card_is_valid, not calls_StripeClient_charge_method.
  • Fast tests first. Unit < integration < end-to-end. Run unit on every save; the slower tiers in CI.
  • Coverage target is a floor, not a ceiling. 80% line coverage is the minimum, but coverage measures what code ran, not whether the behaviour is right.

What good test names look like

✓ calculates total including tax for domestic orders
✓ throws InvalidEmailError when domain is missing
✓ returns empty array when search has no matches
✓ rolls back transaction when downstream service times out

A reader who has never seen the code should be able to understand the spec from the test names alone.

Anti-patterns to flag

  • Test written after the code ("but it passes!"). The test never failed, so it doesn't prove anything.
  • Mocks of internals. Mock the boundary (database, HTTP), not your own classes.
  • Test that does nothing if a precondition fails. Use a precondition assertion or skip, not a silent early return.
  • Sleeping in tests. Use fake timers or polling with timeout.
  • Snapshot tests for logic. Snapshots are for output that's expected to be stable and visually compared — not behavioural correctness.
  • describe blocks deeper than 2 levels. That's a code smell — split the class under test.

When you find a bug

  1. Write a failing test that reproduces the bug. Do not fix the code yet.
  2. Confirm the test fails with the same symptom users see.
  3. Fix the bug. The test goes green.
  4. Now refactor if needed.

The test you write becomes a regression net forever.

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.