agentleFS
sergeeeysergeeey/Claude-cod-top-2026/skills/core/tdd-workflow/SKILL.md

tdd-workflow

Skill9 starsChanged 6 months agoMITView on GitHub

NOT A SINGLE LINE OF PRODUCTION CODE WITHOUT A FAILING TEST. Order is always: RED → GREEN → REFACTOR. No exceptions. Critical: if tests pass before writing code — they are useless. That means: they test the wrong thing, or they test already existing behavior. If a test passed → delete it and write a correct test that checks NEW behavior. A separate commit creates clean history: contract (tests) first, then implementation. If something broke — fix the implementation, NOT…

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

Show its rules and text

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 117 edited versions we read keep these.

  • 18

    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:

    ALWAYS USE when writing new features, fixing bugs, or adding functionality.

    line 12
  2. Distinctive:

    MUST USE when user mentions: tests, test, TDD, coverage, red-green, write tests, cover with tests, add with tests, fix with tests.

    line 13
  3. Distinctive:

    Do NOT use for throwaway prototypes, generated code (migrations, protobuf stubs), or config files — tests are not needed there.

    line 16
  4. Distinctive:

    Write tests based on requirements, NOT on implementation.

    line 36
  5. Distinctive:

    Do not write implementation.

    line 40
  6. Distinctive:

    Run the tests. Confirm that EVERY new test FAILS.

    line 43
  7. Distinctive:

    Critical: if tests pass before writing code — they are useless.

    line 48
  8. Distinctive:

    If a test passed → delete it and write a correct test that checks NEW behavior.

    line 51
  9. Distinctive:

    Write MINIMAL code to make all tests green.

    line 62
  10. Distinctive:

    Do not add functionality beyond what the tests require

    line 63
  11. Distinctive:

    If a test seems wrong — stop, discuss with user

    line 65
  12. Distinctive:

    Run all tests (not just the new ones):

    line 68
  13. Distinctive:

    If something broke — fix the implementation, NOT the tests.

    line 73
  14. Distinctive:

    No workarounds instead of a real solution?

    line 78
  15. Distinctive:

    Run tests after EVERY change

    line 85
  16. Distinctive:

    Test passes BEFORE writing code → Test is useless.

    line 117
  17. Distinctive:

    Write tests BEFORE implementation — tests after code test implementation, not requirements

    line 128
  18. Distinctive:

    Never weaken a test to make it pass — fix the code, not the test

    line 129

“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
<!-- BSV — Brief Skill View | поиск: BSV Скил : tdd-workflow TL;DR : TDD цикл RED→GREEN→REFACTOR, тест до кода Вызов : `test:`, `TDD:`, 'напиши тесты' НЕ для : Написание кода без тестов -->

name: tdd-workflow description: > [STATUS: review] [CONFIDENCE: high] [REVIEWED: 2026-03-13] ALWAYS USE when writing new features, fixing bugs, or adding functionality. MUST USE when user mentions: tests, test, TDD, coverage, red-green, write tests, cover with tests, add with tests, fix with tests. ESPECIALLY when tempted to write code before tests. Do NOT use for throwaway prototypes, generated code (migrations, protobuf stubs), or config files — tests are not needed there.

TDD Workflow — Test-Driven Development

Existing Tests (auto-injected)

!`pytest --co -q 2>/dev/null | head -20`

Iron Law

NOT A SINGLE LINE OF PRODUCTION CODE WITHOUT A FAILING TEST.

Order is always: RED → GREEN → REFACTOR. No exceptions.

6-Step Process

Step 1: RED — Write Tests

Write tests based on requirements, NOT on implementation.

  • One test = one behavior
  • Clear names: test_user_login_returns_token_on_valid_credentials
  • Real data, mock only when unavoidable (DB, external API)
  • Do not write implementation. Tests only.

Step 2: RED — Confirm Tests Fail

Run the tests. Confirm that EVERY new test FAILS.

pytest tests/unit/module_name/ -x -q --tb=short

Critical: if tests pass before writing code — they are useless. That means: they test the wrong thing, or they test already existing behavior.

If a test passed → delete it and write a correct test that checks NEW behavior.

Step 3: RED — Commit Tests Separately

git add tests/...
git commit -m "test: add failing tests for <feature>"

A separate commit creates clean history: contract (tests) first, then implementation.

Step 4: GREEN — Write Minimal Implementation

Write MINIMAL code to make all tests green.

  • Do not add functionality beyond what the tests require
  • FORBIDDEN to modify tests in this step
  • If a test seems wrong — stop, discuss with user

Step 5: GREEN — Verification

Run all tests (not just the new ones):

pytest tests/ -x -q --tb=short

If something broke — fix the implementation, NOT the tests.

Dispatch reviewer subagent to check:

  • Implementation is not hardcoded to specific test values?
  • Edge cases covered?
  • No workarounds instead of a real solution?

Step 6: REFACTOR — Improve While Staying Green

Refactor ONLY with green tests:

  • Remove duplication
  • Improve naming
  • Simplify logic
  • Run tests after EVERY change

Commit:

git add src/... tests/...
git commit -m "feat: implement <feature>"

Rationalization Prevention

ExcuseReality
"Tests are too simple for this function"Write at least happy path + one edge case. Simple tests catch simple bugs. 30 seconds of work.
"I already know the implementation, let's do code first"No. RED → GREEN → REFACTOR. Tests first, always. Knowing the implementation does not cancel the process.
"This module is hard to test"Hard to test = signal of poor design. Refactor the module, then test.
"Just this once without tests, I'll add them later""Later" never comes. Tests written after code are fitted to implementation, not requirements.
"This is just config/utility, no tests needed"Config breaks production more often than business logic. One validation test = insurance.
"Tests slow down development"Tests slow down CODE WRITING by 20%. Debugging without tests — by 300%.
"I'll write integration tests later"Unit tests and integration tests are different things. Unit now, integration later.

Exceptions (require explicit user confirmation)

  • Throwaway prototype (user explicitly said "no tests, prototype")
  • Generated code (migrations, protobuf, OpenAPI stubs)
  • Configuration files (CI/CD, Docker, package.json)
  • Documentation

Red Flags — STOP if noticed

  • "I'll skip TDD just this once" → No. Follow the process.
  • "I'll write tests after" → No. RED first.
  • "Tests after code give the same result" → No. Tests after code test implementation, not requirements.
  • Test passes BEFORE writing code → Test is useless. Rewrite it.
  • Modifying test to make it pass → FORBIDDEN. Fix code, not tests.

Relationship with rules/testing.md

This skill extends the base rules from @~/.claude/rules/testing.md:

  • testing.md sets CONSTRAINTS (do not delete tests, coverage 80%+)
  • tdd-workflow sets PROCESS (RED → GREEN → REFACTOR)
  • They complement each other, not conflict

Gotchas

  • Write tests BEFORE implementation — tests after code test implementation, not requirements
  • Never weaken a test to make it pass — fix the code, not the 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.