agentleFS
mmNalakammNalaka/nm-skills/skills/tdd/SKILL.md

tdd

Skill1 starsChanged 6 months agoMITView on GitHub

Use when writing new features or fixing bugs — enforces Red-Green-Refactor with test approval gates before any implementation starts.

194 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use capture-learning-tools, design-frontend-dev 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.
  • The-Vibe-CompanySkill

    capture-learning-tools

    Turn technical conversations, bugs, CI failures, review comments,

    Also in 5 projects that use this

  • The-Vibe-CompanySkill

    design-frontend-dev

    Clean Impeccable frontend design skill. Use when the user wants to

    Also in 5 projects that use this

  • tristanphvnSkill

    ketchup-video

    Catch the user up like /keel:ketchup, with a short silent video of slides for what happened and the waiting calls as text under it. Use for /keel:ketchup-video.

    Also in 14 projects that use this

  • jaydubya818Skill

    figure-it-out

    Use when novel or multi-phase work needs an auditable workflow and no narrower playbook fits.

    Also in 54 projects that use this

  • jaydubya818Skill

    principle-laziness-protocol

    Apply when a refactor is adding wrappers or abstractions instead of simplifying.

    Also in 45 projects that use this

  • +2 more from The-Vibe-Company
  • +5 more from jaydubya818

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. 0 are common, 11 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 186 edited versions we read keep these.

  • 11

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before writing tests, ask:

    line 18
  2. Distinctive:

    Write the test file(s). No implementation code.

    line 32
  3. Very specific:

    TypeScript: use Vitest (preferred) or Jest.

    line 34
  4. Very specific:

    Wait for explicit y.

    line 61
  5. Distinctive:

    Write only enough code to make the tests pass:

    line 69
  6. Distinctive:

    No extra error handling for scenarios not covered by tests

    line 71
  7. Distinctive:

    No features beyond what the tests assert

    line 72
  8. Distinctive:

    Run the full test suite. Show pass output.

    line 76
  9. Distinctive:

    If any test fails: fix implementation (not tests) until all pass.

    line 78
  10. Very specific:

    If user skips: jump to commit phase.

    line 85
  11. Distinctive:

    If tests break: fix the refactor, not the tests.

    line 110
  12. Distinctive:

    Never write implementation before tests are RED and user-approved

    line 120
  13. Distinctive:

    Never skip the failure verification step — if you didn't watch the test fail, you don't know it tests the right thing

    line 121
  14. Distinctive:

    Never refactor before the user approves the refactor plan

    line 122

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

Red-Green-Refactor workflow with explicit approval gates. Tests are written, reviewed, and confirmed failing before any implementation. Refactoring only happens after explicit approval.

Recommended model: Sonnet


Phase 1 — RED (write failing tests)

Step 1: Identify test cases with presets

Before writing tests, ask:

What behaviors should these tests cover? Select all that apply:

  1. Happy path — valid input returns expected output
  2. Invalid input — validation errors caught at boundary
  3. Not found — missing resource returns 404/error
  4. Auth/permission — unauthorized access rejected
  5. Edge cases — empty list, zero values, max limits
  6. Other — describe below

Propose additional test cases based on the task. Wait for the user to confirm the list.

Step 2: Write tests only

Write the test file(s). No implementation code. No scaffolding beyond what the test imports need.

  • TypeScript: use Vitest (preferred) or Jest; files at *.test.ts
  • Go: _test.go files; use table-driven tests

Step 3: Show tests and get approval

Present the tests to the user:

Tests written. Do these cover the right cases? [y / add more / remove N / edit N]

Iterate until the user approves. Do not proceed until approved.

Step 4: Run tests — must FAIL

Run the tests:

  • TypeScript: npx vitest run <test-file> or npx jest <test-file>
  • Go: go test ./... -run TestFunctionName

Show the full failure output. If tests pass without implementation, stop:

Warning: Tests passed without implementation — they may not be testing the right thing. Investigate before proceeding.

Step 5: Hard stop

Tests are RED and approved. Proceed to implementation? [y / n]

Wait for explicit y.


Phase 2 — GREEN (minimal implementation)

Step 6: Write minimal implementation

Write only enough code to make the tests pass:

  • No premature abstractions
  • No extra error handling for scenarios not covered by tests
  • No features beyond what the tests assert

Step 7: Run tests — must PASS

Run the full test suite. Show pass output.

If any test fails: fix implementation (not tests) until all pass.

Step 8: Hard stop

Tests are GREEN. Refactor now? [y / skip refactor]

If user skips: jump to commit phase. If y: continue to Phase 3.


Phase 3 — REFACTOR (only after approval)

Step 9: Present refactor plan

Show what will change and why:

Refactor plan:
  - Extract shared validation logic to users.schema.ts (DRY — duplicated in 2 places)
  - Rename `processUser` → `mapUserToResponse` (clarity)
  - No behavior changes — all tests must still pass

Proceed with refactor? [y / n / modify]

Wait for approval.

Step 10: Apply refactor and re-verify

Apply changes. Run tests again — they must still pass.

If tests break: fix the refactor, not the tests.

Step 11: Commit

Suggest committing via /commit after the green or refactor phase.


Rules

  • Never write implementation before tests are RED and user-approved
  • Never skip the failure verification step — if you didn't watch the test fail, you don't know it tests the right thing
  • Never refactor before the user approves the refactor plan
  • Fix implementation to pass tests — never weaken tests to pass implementation
  • Mock at boundaries only (external APIs, DB) — never mock implementation internals

TypeScript Test Conventions

import { describe, it, expect, vi } from 'vitest'

describe('createUser', () => {
  it('returns created user on valid input', async () => { ... })
  it('throws ValidationError on invalid email', async () => { ... })
})

Go Test Conventions

func TestCreateUser(t *testing.T) {
    tests := []struct {
        name    string
        input   CreateUserInput
        want    *User
        wantErr error
    }{
        { name: "valid input", input: ..., want: ... },
        { name: "invalid email", input: ..., wantErr: &ValidationError{} },
    }
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) { ... })
    }
}

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.