agentleFS
kambleakash0kambleakash0/agent-skills/skills/incremental-tdd/SKILL.md

incremental-tdd

Skill10 starsChanged 7 months agoMITView on GitHub

Test-driven development with a strict red-green-refactor loop, vertical slices, and deep modules. Use to build features or fix bugs using TDD.

We split this skill into the rules it gives an agent

19 rules. About 0 are common, 18 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈18

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When you need guidance on design or refactoring, open and read these files instead of guessing.

    line 24
  2. Distinctive:

    Use this skill when the user:

    line 28
  3. Very specific:

    If the requirements are unclear, suggest using /grill-me and /spec-writer first, then come back here for execution.

    line 35
  4. Distinctive:

    Prefer deep modules: fewer, larger modules with thin, stable interfaces on top.

    line 45
  5. Distinctive:

    If needed, open deep-modules.md and adjust your interface design to match that philosophy.

    line 46
  6. Distinctive:

    Avoid purely horizontal slices like “set up the DB table” or “write all the UI” in isolation.

    line 51
  7. Distinctive:

    Write one test that expresses the desired behavior of the slice using the chosen interface.

    line 56
  8. Distinctive:

    Keep the test as close as possible to “how a real caller would use this”, even when testing at module level.

    line 57
  9. Distinctive:

    Prefer real collaborators or thin fakes over heavy mocking.

    line 58
  10. Distinctive:

    Run the test and confirm it fails for the expected reason.

    line 59
  11. Distinctive:

    Do not over‑generalize, add unused parameters, or implement future behavior that isn’t tested yet.

    line 64
  12. Distinctive:

    Use deep-modules.md and refactoring.md as guides for better boundaries and deeper modules.

    line 71
  13. Distinctive:

    Stop once the design is “good enough” for now.

    line 72
  14. Distinctive:

    Always respect the loop: Never write large chunks of production code without a failing test first.

    line 82
  15. Distinctive:

    One test at a time: Do not generate dozens of tests at once.

    line 83
  16. Distinctive:

    Guard against dishonest tests: Avoid tests that would pass even if the real behavior were broken.

    line 85
  17. Distinctive:

    Be willing to change your own code: Treat previously written code as disposable if a better design emerges.

    line 86
  18. Distinctive:

    Use the attached docs: When you’re unsure about module shape, refactoring, or mocking, open the linked markdown files instead of …

    line 87
  19. Distinctive:

    Write a single failing test for “given last week’s events, compute the summary object for team X”.

    line 98

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “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 (Red-Green-Refactor)

This skill forces you to work in tight TDD loops: one failing test, one implementation, then refactor. It prefers vertical slices and deep modules so tests stay honest, stable, and focused on real behavior instead of implementation details.

This skill comes with extra documents you can reference for philosophy and examples:

  • deep-modules.md – why deep modules make AI‑driven TDD easier and safer.
  • refactoring.md – patterns for safe refactors.
  • interface-design.md – how to design interfaces for TDD.
  • mocking.md – how and when to mock without lying to yourself.
  • tests.md – how and when to mock without lying to yourself.

When you need guidance on design or refactoring, open and read these files instead of guessing.

When to Use

Use this skill when the user:

  • Wants to build a feature or fix a bug using TDD.
  • Mentions “red‑green‑refactor”, “test‑first”, or “write the tests first”.
  • Wants honest integration or module‑level tests that drive design rather than brittle unit tests.
  • Is running longer “Ralph” loops or autonomous agents and wants higher‑quality changes.

If the requirements are unclear, suggest using /grill-me and /spec-writer first, then come back here for execution.

Overall Workflow

You can compress steps when context is obvious, but keep the red → green → refactor discipline.

  1. Clarify behavior and interfaces

    • Confirm what behavior should exist from the outside: which inputs, outputs, and observable effects matter.
    • Identify or design the interfaces you’ll use to expose that behavior (public functions, handlers, endpoints, etc.).
    • Prefer deep modules: fewer, larger modules with thin, stable interfaces on top.
    • If needed, open deep-modules.md and adjust your interface design to match that philosophy.
  2. Choose the next vertical slice

    • From the PRD or problem description, pick a thin vertical slice: a single behavior that exercises a real path through the system.
    • Avoid purely horizontal slices like “set up the DB table” or “write all the UI” in isolation.
    • Confirm with the user (or with comments) what this slice should prove when finished.
  3. Red: write one failing test

    • Write one test that expresses the desired behavior of the slice using the chosen interface.
    • Keep the test as close as possible to “how a real caller would use this”, even when testing at module level.
    • Prefer real collaborators or thin fakes over heavy mocking. When in doubt, consult mocking.md.
    • Run the test and confirm it fails for the expected reason.
  4. Green: write the minimal implementation

    • Open the relevant production files and write the simplest implementation that makes the test pass.
    • Do not over‑generalize, add unused parameters, or implement future behavior that isn’t tested yet.
    • Re‑run the tests and make sure the new test passes and the suite remains green.
  5. Refactor: improve design safely

    • With tests green, look for duplication, awkward interfaces, or leaky abstractions.
    • Apply small refactors while running tests frequently to ensure behavior stays the same.
    • Use deep-modules.md and refactoring.md as guides for better boundaries and deeper modules.
    • Stop once the design is “good enough” for now; you can refactor again after future slices.
  6. Repeat the loop

    • Pick the next slice or behavior, then repeat Red → Green → Refactor.
    • Each cycle should be small enough that you can understand and reverse it if it goes wrong.
    • As you go, keep tests focused on behavior and avoid coupling them to incidental implementation details.

Behavior and Rules

  1. Always respect the loop. Never write large chunks of production code without a failing test first.
  2. One test at a time. Do not generate dozens of tests at once. Add tests incrementally as behavior demands.
  3. Prefer higher‑level tests. Where reasonable, prefer integration or module‑level tests that exercise real flows.
  4. Guard against dishonest tests. Avoid tests that would pass even if the real behavior were broken; check for obvious false positives.
  5. Be willing to change your own code. Treat previously written code as disposable if a better design emerges; rely on tests for safety.
  6. Use the attached docs. When you’re unsure about module shape, refactoring, or mocking, open the linked markdown files instead of hallucinating patterns.

Example Flow

User: “Implement weekly admin summary emails using TDD. I already have the PRD and issues.”

You (high level):

  1. Skim the PRD and issues, identify the first vertical slice (e.g., “compute weekly metrics for a single team”).
  2. Design or confirm the module interface responsible for computing metrics; check deep-modules.md for guidance.
  3. Write a single failing test for “given last week’s events, compute the summary object for team X”.
  4. Implement the minimal code to make that test pass, then refactor the module while keeping tests green.
  5. Repeat for additional behaviors (multiple teams, filters, performance constraints, error handling), always via red‑green‑refactor.

Download now (ZIP)

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. zgagnon/skills★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository12 other files it gives its agents.

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.