agentleFS
kapadiaskapadias/nonna/.claude/skills/tdd-workflow/SKILL.md

tdd-workflow

Skill0 starsChanged 46 days agoMITView on GitHub

Writing code test-first: RED->GREEN->REFACTOR, golden vs property tests, making untestable code testable, where to spend coverage. Used by /tdd and test-engineer.

135 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

3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 124 edited versions we read keep these.

  • 2

    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:

    Never write production logic that no failing test demanded.

    line 20
  2. Very specific:

    Inject the clock: Never call now() inside logic.

    line 60
  3. Distinctive:

    Isolate I/O at the edges: Keep the core pure (data in → data out).

    line 63

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

The test is the specification. You write it first because a test written after the code only proves the code does what it does — not what it should. The LLM proposes; the test decides.

The Cycle: RED → GREEN → REFACTOR

PhaseGoalRule
REDWrite one failing test that pins the next increment of behaviorRun it. Watch it fail. Confirm it fails for the stated reason, not a typo or import error.
GREENWrite the minimum code to passNo extra abstraction, no speculative cases. Fastest honest path to green.
REFACTORImprove structure with tests greenBehavior unchanged; tests unchanged. See refactoring.

One behavior per cycle. If a test needs three new code paths to pass, it is too big — split it. Never write production logic that no failing test demanded.

What makes a good failing test

  • Fails for the right reason. A test that errors on setup is not RED — it is broken. The assertion, not the scaffolding, must be what fails.
  • Pins behavior, not implementation. Assert on observable outputs and contracts. Tests coupled to private internals break on every refactor and rot.
  • Minimal and named for intent. One logical assertion. The test name states the rule: rejects_withdrawal_exceeding_balance, not test_withdraw_2.
  • Deterministic. Same inputs, same result, every run. Seed RNG, inject the clock, no network.

Golden vs property — use both on the critical surface

Golden tests assert against a hand-verifiable known answer, cross-checked against a trusted library where one exists. They catch wrong. Use for math, encoders, money, any pure transform with a knowable output. Pin the exact value (with a float tolerance) and state where the oracle came from — a golden test against a guessed oracle is worthless.

Property tests assert a rule that holds for all valid inputs and let the framework hunt counterexamples. They catch the case you didn't think of. The high-value invariant families:

  • Round-trip: decode(encode(x)) == x
  • Idempotence: f(f(x)) == f(x) (normalizers, retries, upserts)
  • Bounds / conservation: output stays within declared limits; nothing is lost or duplicated
  • Order-independence: result invariant to input ordering (sums, set operations)

Survival-critical code (money, auth, data integrity, persistence, anything irreversible) demands both, before merge.

Copy-ready skeletons — golden + property tests for three stacks live in templates/: python_pytest_hypothesis.py, typescript_vitest_fastcheck.test.ts, go_testing_quick_test.go. Longer worked examples with oracle provenance: references/worked-examples.md.

Make the untestable testable

Untestable code is a design smell, not a reason to skip the test.

  • Inject the clock. Never call now() inside logic; pass a time value or a clock. Then "expires after 30 days" is a pure assertion.
  • Inject the RNG/seed. Randomness in a decision path takes an explicit seed, never the global.
  • Isolate I/O at the edges. Keep the core pure (data in → data out); push network, disk, and clock to a thin shell. You test the core directly and mock only the shell.

Where to spend coverage

Coverage is a budget — aim it at the survival-critical surface: money, auth, data integrity, persistence, and anything irreversible. There, demand golden + property tests and high branch coverage. Glue and display code aim high but are not the gate. Coverage percent is a floor, never a goal — 100% over vacuous asserts proves nothing.

Anti-patterns

  • Test written after — it documents behavior instead of specifying it; you lose the RED signal.
  • Vacuous / self-referential asserts — assert result == result, asserting a mock was called with what you just told it. Reassert nothing.
  • Mock everything — a test where every collaborator is faked tests the mocks. Mock the edge; exercise the real core.
  • Flaky tests — time, ordering, or network leaking in. Quarantine and fix; a flaky test trains the team to ignore red. A red suite is a stop, not a footnote.

See .claude/rules/testing.md for the coverage gate and marker policy; route work through the test-engineer agent and /test.

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.