agentleFS
imMamdouhaboammarimMamdouhaboammar/matts-skills-into-chatgpt/skills/tdd/SKILL.md

tdd

Skill8 starsChanged 2 months agoMITView on GitHub

Implement features and bug fixes test-first using red-green-refactor cycles. Use when writing new functionality, adding regression tests, fixing bugs with test coverage, or designing behavior through test assertions — even if the user says \"write tests for this\". Do NOT use for throwaway exploratory prototypes.

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 186 edited versions we read keep these.

  • 6

    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:

    Strict Red-First Execution: Never write production implementation code before seeing an automated test fail against a pre-agreed seam.

    line 18
  2. Distinctive:

    Key Point: Verify the test fails specifically because the new behavior is absent, not due to syntax or setup errors.

    line 50
  3. Distinctive:

    Action: Write the simplest, most direct code that makes the failing test pass.

    line 58
  4. Distinctive:

    Key Point: Do not anticipate speculative requirements or write unexercised branches.

    line 59
  5. Distinctive:

    Action: Run the full test suite to guarantee zero regressions.

    line 63
  6. Distinctive:

    Key Point: All tests must be green before proceeding to the next vertical tracer slice.

    line 64

“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

Test-Driven Development (TDD)

Implement robust, maintainable functionality through disciplined red → green → verify cycles. Verify behavior through public seams rather than private implementation details.

Core Principle

Write the failing test first, witness it fail for the right reason, and write only the minimal code needed to make it green.


Core Invariants

  1. Strict Red-First Execution: Never write production implementation code before seeing an automated test fail against a pre-agreed seam.
  2. Behavioral Testing Over Implementation Inspection: Tests must assert observable input/output behavior and public contracts, never private variables or internal call chains.
  3. Independent Expected Values: Assertions must compare against independent ground truth (fixtures, domain specs, known literals), never recomputed mirror logic.
  4. Vertical Tracer Slicing: Deliver one vertical slice at a time (one test → minimal code → green) rather than batching horizontal test suites upfront.
  5. Deterministic & Isolated Fixtures: Tests must execute in milliseconds without cross-test state leakage, unseeded random seeds, or unpinned clocks.

Architecture & Map of Content (MOC)

[ Agree Public Seam ] ──► [ Red: Write Failing Test ] ──► [ Green: Minimal Code ] ──► [ Refactor & Verify ]
ComponentResponsibilityReference
Public SeamsIdentify module boundaries and observable behaviorscodebase-design
Test ExamplesConcrete patterns for unit and integration assertionstests.md
Mocking GuidelinesSafe boundary isolation rules without over-mockingmocking.md
Review & RefactorClean code review after reaching greencode-review

Step-by-Step Procedure (TWI)

Step 1: Identify & Confirm the Public Seam

  • Action: State the public interface and observable contract you intend to test, and confirm alignment with domain conventions.
  • Key Point: Anchor assertions at public boundaries; do not reach into internal private state.
  • Why: Testing through private internals creates brittle tests that break during harmless refactoring.

Step 2: Write the Failing Test (RED)

  • Action: Author a single focused test specifying the expected behavior and run the test runner to observe failure.
  • Key Point: Verify the test fails specifically because the new behavior is absent, not due to syntax or setup errors.
  • Inline Checklist:
    • Test names the exact business capability (e.g. returns_discounted_total_for_premium_member)
    • Test fails with expected assertion error
    • Expected values derived from independent domain constants
  • Why: A test that doesn't fail properly cannot be trusted to protect against regressions.

Step 3: Implement Minimal Code (GREEN)

  • Action: Write the simplest, most direct code that makes the failing test pass.
  • Key Point: Do not anticipate speculative requirements or write unexercised branches.
  • Why: Minimal code keeps the change set tight and prevents unverified dead logic.

Step 4: Verify Suite & Cycle

  • Action: Run the full test suite to guarantee zero regressions.
  • Key Point: All tests must be green before proceeding to the next vertical tracer slice.
  • Why: Catching regressions immediately keeps debugging costs near zero.

Anti-Rationalization Guardrails

Tempting RationalizationBinding RuleEngineering Rationale
"I'll write the implementation first, then add tests."Forbidden: test must be written and observed failing first.Tests written after code tend to mirror implementation bias and miss edge-case failures.
"I can mock this internal helper to test the private method."Test only through public seams.Mocks on private internals cement architectural rigidity and hide real integration bugs.
"I will write all 15 test cases before writing any code."Vertical tracer slicing: one test at a time.Bulk tests lock in premature interface assumptions before real implementation learnings.
"The test passed on the first run without changes."Investigate immediately: tautological or wrong test.A test that passes without implementation changes is asserting something already true.

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.