agentleFS
Cor-IncorporatedCor-Incorporated/claude-code-skills/skills/tdd-workflow/SKILL.md

tdd-workflow

Skill5 starsChanged 2 months agoMITView on GitHub

Enforces test-driven development with 80%+ coverage across unit, integration, and E2E tests. Use when the user says: 'write tests first', 'TDD', 'add test coverage', 'test this feature', 'write unit tests', 'create integration test', 'add E2E test', 'fix with TDD', 'red green refactor', 'increase coverage'. Guides the RED-GREEN-REFACTOR cycle for new features, bug fixes, and refactoring. Do NOT use for running existing tests without changes, CI/CD pipeline setup, or code review without test focus.

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

9 rules. 0 are common, 6 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 117 edited versions we read keep these.

  • 6

    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:

    Run tests -- they MUST fail:

    line 38
  2. Distinctive:

    Write just enough code to make all tests pass.

    line 45
  3. Distinctive:

    Run tests after each change to confirm nothing broke.

    line 60
  4. Distinctive:

    Check branches, functions, lines, and statements individually.

    line 84
  5. Distinctive:

    If tests pass immediately (no RED phase): the test is not testing anything meaningful.

    line 128
  6. Very specific:

    If coverage is below 80%: run npm run test:coverage and check the uncovered lines report.

    line 129
  7. Very specific:

    If E2E tests are flaky: replace waitForTimeout with waitForSelector or expect().toBeVisible().

    line 130
  8. Very specific:

    If mocks leak between tests: add vi.restoreAllMocks() in afterEach or use vi.mock at module level.

    line 131
  9. Distinctive:

    If tests are slow (unit > 50ms): check for unmocked network calls or missing test isolation.

    line 132

“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

Enforce test-driven development: write tests first, implement to pass, then refactor.

<important if="writing new tests or implementing a new feature with TDD"> ## The Cycle: RED -> GREEN -> REFACTOR

RED: Write Failing Tests

Define expected behavior before writing any implementation:

describe('searchMarkets', () => {
  it('returns relevant markets for query', async () => {
    const results = await searchMarkets('election')
    expect(results).toHaveLength(5)
    expect(results[0].relevanceScore).toBeGreaterThan(0.8)
  })

  it('returns empty array for no matches', async () => {
    const results = await searchMarkets('zzz_nonexistent')
    expect(results).toEqual([])
  })

  it('handles empty query gracefully', async () => {
    const results = await searchMarkets('')
    expect(results).toEqual([])
  })
})

Run tests -- they MUST fail:

npm test -- --run [test-file]

GREEN: Write Minimal Implementation

Write just enough code to make all tests pass. No more.

npm test -- --run [test-file]
# All tests should now pass

REFACTOR: Improve While Green

Improve code quality with tests as safety net:

  • Remove duplication
  • Improve naming
  • Optimize performance
  • Extract helpers

Run tests after each change to confirm nothing broke. </important>

<important if="choosing which test type to write or classifying existing tests"> ## Test Types and When to Use
TypeWhat to TestToolSpeed Target
UnitSingle function/class, pure logicVitest/Jest< 50ms each
IntegrationAPI endpoints, DB operations, service interactionsVitest + mocks< 500ms each
E2ECritical user flows through browserPlaywright< 30s each

IMPORTANT: curl tests are integration tests, NOT E2E. E2E requires browser verification. </important>

<important if="measuring coverage or checking if coverage targets are met"> ## Coverage Requirement

Target 80%+ across all metrics:

npm run test:coverage

Check branches, functions, lines, and statements individually. </important>

<important if="writing new tests or refactoring existing tests"> ## Testing Rules
  1. Test behavior, not implementation
    • WRONG: expect(component.state.count).toBe(5)
    • RIGHT: expect(screen.getByText('Count: 5')).toBeInTheDocument()
  2. Each test is independent -- set up own data, no shared mutable state
  3. Use semantic selectors
    • WRONG: page.click('.css-xyz')
    • RIGHT: page.click('[data-testid="submit"]') or page.click('button:has-text("Submit")')
  4. Mock external dependencies -- isolate the unit under test
  5. Test edge cases -- null, undefined, empty, boundary values, error paths
  6. Arrange-Act-Assert structure in every test</important>
<important if="writing tests that need to mock databases or external APIs"> ## Mocking Patterns

Database/ORM

vi.mock('@/lib/prisma', () => ({
  prisma: { user: { findUnique: vi.fn() } }
}))

External APIs

vi.mock('@/lib/external-api', () => ({
  fetchData: vi.fn(() => Promise.resolve({ data: 'mocked' }))
}))
</important><important if="debugging failing tests, flaky tests, or slow test suites"> ## Error Handling
  • If tests pass immediately (no RED phase): the test is not testing anything meaningful. Add assertions that verify specific behavior.
  • If coverage is below 80%: run npm run test:coverage and check the uncovered lines report. Add tests for missed branches.
  • If E2E tests are flaky: replace waitForTimeout with waitForSelector or expect().toBeVisible(). Never use fixed timeouts.
  • If mocks leak between tests: add vi.restoreAllMocks() in afterEach or use vi.mock at module level.
  • If tests are slow (unit > 50ms): check for unmocked network calls or missing test isolation.</important>

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.