agentleFS
Gusen1453Gusen1453/creed/skills/tdd/SKILL.md

tdd

Skill3 starsChanged 2 months agoMITView on GitHub

Use when implementing any feature, bug fix, refactor, or behavior change, before writing production code.

193 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use make-bot-ui, Poteto Mode 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.
  • eryzerzSkill

    make-bot-ui

    Use when building a custom UI (page, dashboard, buttons) that should wake a Grok Bot over a webhook, when the user must provide a webhook sender key, or when exposing that UI on Tailscale.

    Also in 8 projects that use this

  • jtarorehSkill

    Poteto Mode

    poteto's agent style for concise, detailed responses, deliberate subagents, unslopped prose, simple code, and verified work. Use for poteto, /poteto-mode, or requests to work in this style.

    Also in 5 projects that use this

  • risadamsSkill

    which-skill

    Router over this pack's skills and flows. Ask it "which skill fits X" when you don't remember what's available.

    Also in 7 projects that use this

  • TheOnlyFusionCubeSkill

    principle-attack-the-premise

    Inventory who actually owns or exhibits the imbalance, then challenge the shared premise before writing another patch. Use when two or more fixes that share one premise have failed the same gate.

    Also in 11 projects that use this

  • TheOnlyFusionCubeSkill

    principle-test-behavior-not-implementation

    Call the system the way its consumer does and assert meaningful observable output; avoid mocks or assertions that only mirror internal calls. Use when when writing or evaluating tests.

    Also in 11 projects that use this

  • shreyT19Skill

    principle-laziness-protocol

    Apply when refactoring, evaluating diff size, or tempted to add abstractions, layers, or signal threading. Bias toward deletion and the smallest change that solves the problem.

    Also in 22 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 177 edited versions we read keep these.

  • 12

    Distinctive

    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:

    REQUIRED COMPANION: use test-design for *what* to feed, assert, and mock.

    line 16
  2. Distinctive:

    Don't keep it as "reference"

    line 36
  3. Distinctive:

    Don't "adapt" it while writing tests

    line 37
  4. Distinctive:

    Don't look at it

    line 38
  5. Distinctive:

    Run the targeted test. Confirm:

    line 79
  6. Distinctive:

    If it passes immediately → you're testing existing behavior or asserting nothing real — fix the test

    line 83
  7. Distinctive:

    If it errors → fix the harness, re-run until it fails correctly

    line 84
  8. Distinctive:

    Run again. All related tests pass.

    line 92
  9. Distinctive:

    Only after green: names, duplication, helpers.

    line 96
  10. Distinctive:

    Test written after implementation

    line 126
  11. Distinctive:

    Test passes on first run

    line 127
  12. Distinctive:

    Test-only methods on production types

    line 138

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

Output language: answer and write artifacts in the user's own language (match their messages, not the repo's history).

Overview

Write the test first. Watch it fail. Write the minimal code to pass. Refactor.

Core principle: if you didn't watch the test fail, you don't know it tests the right thing.

REQUIRED COMPANION: use test-design for what to feed, assert, and mock. This skill is only the rhythm. Formalistic RED tests are still forbidden — a failing theater test proves nothing.

When to Use

Always: new features, bug fixes, refactoring, behavior changes.

Exceptions (ask the human first): throwaway prototypes, generated code, pure config with no behavior.

Thinking "skip TDD just this once"? Stop — that's rationalization.

The Iron Law (non-negotiable)

NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST

Wrote code before the test? Delete it. Start over.

No exceptions:

  • Don't keep it as "reference"
  • Don't "adapt" it while writing tests
  • Don't look at it
  • Delete means delete

Violating the letter is violating the spirit.

Workflow (when invoked)

Announce "Using tdd to …", then one todo per cycle step:

  1. RED — one failing behavior test (apply test-design: contract, narrow asserts, hand-written expected)
  2. Verify RED — run it; confirm fail for the right reason (missing feature, not typo/error)
  3. GREEN — minimal production code to pass
  4. Verify GREEN — run it; all relevant tests pass; output pristine
  5. REFACTOR — clean up; stay green; no new behavior
  6. Repeat — next behavior → next RED

Bug found later? Write a failing reproduction test first, then the same cycle.

Red → Green → Refactor

RED — write one failing test

One behavior. Clear name (role + scenario + expectation). Real collaborators unless IO forces a Fake/Recording (see test-design).

test("retries failed operations 3 times", async () => {
  let attempts = 0
  const operation = () => {
    attempts++
    if (attempts < 3) throw new Error("fail")
    return "success"
  }
  expect(await retryOperation(operation)).toBe("success")
  expect(attempts).toBe(3)
})

Bad: vague name, asserts only on mock call counts, or expected computed with production logic.

Verify RED — mandatory

Run the targeted test. Confirm:

  • Fails (not errors out from typos/imports)
  • Failure message matches the missing behavior
  • If it passes immediately → you're testing existing behavior or asserting nothing real — fix the test
  • If it errors → fix the harness, re-run until it fails correctly

GREEN — minimal code

Simplest code that passes. No extra features, no drive-by refactors, no YAGNI options objects.

Verify GREEN — mandatory

Run again. All related tests pass. No new warnings/errors ignored.

REFACTOR

Only after green: names, duplication, helpers. Keep tests green. Don't add behavior (new behavior → new RED).

Good vs bad tests (rhythm lens)

GoodBad
SizeOne behavior; "and" in the name → splitKitchen-sink test
NameDescribes observable behaviortest1 / works
ProofYou saw RED for the right reasonPassed on first run
DepthAsserts contract (test-design)Only toHaveBeenCalled / coverage lighting

Rationalization Table

ExcuseReality
"I'll test after to verify"Passes immediately prove nothing. You never saw it catch the bug.
"Tests after achieve the same goals"After = "what does this do?" First = "what should this do?"
"Already manually tested"Ad-hoc, no record, can't re-run.
"Too simple to test"Simple code breaks. A focused test is cheap.
"Deleting X hours is wasteful"Sunk cost. Unverified code is debt. Delete and restart.
"Keep as reference / adapt while testing"That's testing after. Delete means delete.
"Need to explore first"Explore, then throw away exploration; start TDD clean.
"TDD slows me down"Debugging in prod is slower. Pragmatic = test-first.
"Hard to test"Design smell. Simplify the interface (test-design § hard-to-test).
"Existing code has no tests"You're changing it — add the failing test for the behavior you touch.
"Just this once / spirit not ritual"Letter = spirit. No exceptions without the human.

Red Flags — delete code and restart

  • Production code before a failing test
  • Test written after implementation
  • Test passes on first run
  • Can't explain why RED failed
  • --no-verify / skipping the test run "to save time"
  • Keeping pre-test code as "reference"
  • "Pragmatic shortcut" / "this is different because…"

Any hit → delete the production code. Start over at RED.

Anti-patterns (quick)

  • Testing mock behavior instead of the unit
  • Test-only methods on production types
  • Mocking a pile of neighbors (usually glue → prefer integration, or redesign — test-design §1/§5)

Checklist (per behavior)

  • Worth a real test? (test-design ROI) — else don't fake TDD on glue
  • RED written from contract; watched fail for the right reason
  • GREEN is minimal; verify pass
  • REFACTOR stays green; no new behavior smuggled in
  • Mocks only for external world; asserts are narrow and hard

Hand-off

Transition gate — when a feature slice is done (or before leaving tdd), ask the user (one AskUserQuestion; never auto-advance):

A) Recommended: Proceed → review (then commit-and-push)
B) Review first — run **review** on the code slice (`references/code.md`; upstream = plan tasks / spec), then return to this gate
C) Adjust — back into a tdd RED→GREEN cycle for the issue, then return to this gate
D) Something else (I will type it)
  • Case quality unclear → test-design
  • Boundaries / mock piles → solid
  • Feature shape unclear → grill → write-spec first, then TDD
  • To ship → review then commit-and-push

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.