agentleFS
dekozadekoza/oh-my-slop/skills/practice/tdd/SKILL.md

tdd

Skill4 starsChanged 9 months agoUnlicenseView on GitHub

Use when writing or changing any implementation code — building features, fixing bugs, refactoring, or adding tests to existing code. Triggers on: "build X", "implement Y", "fix this bug", "write tests for", "refactor this", "add validation", "TDD".

193 other projects use a version of this, 34 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use make-bot-ui, Poteto Mode 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.
  • eryzerzSkill

    make-bot-ui

    Use when building a custom UI (page, dashboard, buttons) that should wake a Grok Bot over a webhook, when the user must provide a webhook sender key, or when exposing that UI on Tailscale.

    Also in 8 projects that use this

  • jtarorehSkill

    Poteto Mode

    poteto's agent style for concise, detailed responses, deliberate subagents, unslopped prose, simple code, and verified work. Use for poteto, /poteto-mode, or requests to work in this style.

    Also in 5 projects that use this

  • risadamsSkill

    which-skill

    Router over this pack's skills and flows. Ask it "which skill fits X" when you don't remember what's available.

    Also in 7 projects that use this

  • TheOnlyFusionCubeSkill

    principle-attack-the-premise

    Inventory who actually owns or exhibits the imbalance, then challenge the shared premise before writing another patch. Use when two or more fixes that share one premise have failed the same gate.

    Also in 11 projects that use this

  • TheOnlyFusionCubeSkill

    principle-test-behavior-not-implementation

    Call the system the way its consumer does and assert meaningful observable output; avoid mocks or assertions that only mirror internal calls. Use when when writing or evaluating tests.

    Also in 11 projects that use this

  • shreyT19Skill

    principle-laziness-protocol

    Apply when refactoring, evaluating diff size, or tempted to add abstractions, layers, or signal threading. Bias toward deletion and the smallest change that solves the problem.

    Also in 22 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 5 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 177 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When exploring the codebase, read the project's domain glossary — CONTEXT.md unless the domain doc config points elsewhere — so test names …

    line 12
  2. Distinctive:

    Write ONE test that confirms ONE thing about the system:

    line 90
  3. Distinctive:

    Reproduce: write a failing test that captures the user's exact symptom — red for the bug's reason, not incidentally.

    line 117
  4. Distinctive:

    Commit: test + fix together; the test is the permanent regression guard.

    line 119
  5. Very specific:

    If you can't build the reproducing test, that's a diagnosis problem — switch to the diagnosing-bugs skill and come back with its minimized …

    line 121
  6. Distinctive:

    Harvest shortcuts: When you took a shortcut to get a test green — skipped validation, stubbed a dependency, hardcoded a value — tag it …

    line 127
  7. Distinctive:

    When a task requests code, skill, or reference updates, make the requested targeted changes and validate them.

    line 155

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

When exploring the codebase, read the project's domain glossary — CONTEXT.md unless the domain doc config points elsewhere — so test names and interface vocabulary match the project's language, and respect the ADRs covering the area you're touching.

STOP — Read This Before Writing Any Code

This skill is mandatory for all implementation tasks. If you are about to write, modify, or fix code — stop here and follow this workflow. TDD is not optional. Writing implementation before tests is a bug.

Red flags — you are rationalizing if you think:

ExcuseReality
"I'll add tests after I get the implementation working"That's testing after, not TDD. You'll never go back. Write the test first.
"This is a simple change, I don't need TDD"Simple changes break things. The test takes 30 seconds. Write it first.
"I'll write all tests now as a specification"That's horizontal slicing. You'll test imagined behaviour. Use vertical slices instead.
"I need to understand the code first before writing tests"Writing tests IS how you understand the code. Start with one tracer bullet.
"Being pragmatic, not dogmatic"Following TDD IS pragmatic. Skipped tests cause bugs that cost hours.
"The test will be too hard to write without the implementation"That's the point — the test drives the design. If it's hard to test, the design needs work.

When TDD does not apply

Three narrow exceptions — everything else follows the workflow:

  • Spikes: throwaway code written purely to learn, explicitly labeled as a spike. Spike code never graduates into the codebase — reimplement it test-first.
  • Pure visual tweaks: CSS/styling changes with no behaviour to assert. The moment a tweak changes behaviour (visibility logic, conditional rendering), it's back in scope.
  • Generated or config-only changes: lockfiles, migrations generated by the framework, formatting.

Claiming an exception outside these three is the rationalization table above in disguise.

Philosophy

Tests verify behaviour through public interfaces, never implementation details — a good test survives a full rewrite of the internals, and an assertion's expected value comes from an independent source of truth (a known-good literal, a worked example, the spec), never recomputed the way the code computes it. See Tests for good/bad/tautological examples and Mocking for when mocking is legitimate.

Anti-Pattern: Horizontal Slices

DO NOT write all tests first, then all implementation. This is "horizontal slicing" — treating RED as "write all tests" and GREEN as "write all code."

This produces crap tests:

  • Tests written in bulk test imagined behaviour, not actual behaviour.
  • You end up testing the shape of things (data structures, function signatures) rather than user-facing behaviour.
  • Tests become insensitive to real changes — they pass when behaviour breaks, fail when behaviour is fine.
  • You outrun your headlights, committing to test structure before understanding the implementation.

Correct approach: Vertical slices via tracer bullets. One test → one implementation → repeat. Each test responds to what you learned from the previous cycle. Because you just wrote the code, you know exactly what behaviour matters and how to verify it.

WRONG (horizontal):
  RED:   test1, test2, test3, test4, test5
  GREEN: impl1, impl2, impl3, impl4, impl5

RIGHT (vertical):
  RED→GREEN: test1→impl1
  RED→GREEN: test2→impl2
  RED→GREEN: test3→impl3
  ...

Workflow

1. Planning

Three checks before the first test:

  • Confirm the public interface and which behaviours matter most — with the user when the task is ambiguous. You can't test everything; prioritize critical paths and complex logic over exhaustive edge cases.
  • Read the project's test rules (AGENTS.md / CLAUDE.md) and the testing-workflow skill for tiers, environment, and E2E policy.
  • Transform the request into verifiable goals — state what test proves each step:
Instead of...Transform to...
"Add validation""Write tests for invalid inputs, then make them pass"
"Fix the bug""Write a test that reproduces it, then make it pass"
"Refactor X""Ensure tests pass before and after"

Small, unambiguous task? Just start — write the first failing test; the plan is the test list you build as you go. Look for deep-module opportunities (small interface, deep implementation) as you shape interfaces — the codebase-design skill has the vocabulary.

See Goal-Driven Examples for concrete ❌/✅ code comparisons showing vague vs. verifiable approaches.

2. Tracer Bullet

Write ONE test that confirms ONE thing about the system:

RED:   Write test for first behavior → test fails
GREEN: Write minimal code to pass → test passes

This is your tracer bullet — proves the path works end-to-end.

3. Incremental Loop

For each remaining behaviour:

RED:   Write next test → fails
GREEN: Minimal code to pass → passes

After each red-green cycle:

  • Commit the passing test + implementation.
  • Use real dependencies where possible — not mocks. Prefer httpx.MockTransport for HTTP client tests over unittest.mock.patch gymnastics.

Bug-fix variant

Fixing a bug is TDD with a fixed first move:

  1. Reproduce: write a failing test that captures the user's exact symptom — red for the bug's reason, not incidentally.
  2. Fix: minimal change that turns it green without breaking the suite.
  3. Commit test + fix together; the test is the permanent regression guard.

If you can't build the reproducing test, that's a diagnosis problem — switch to the diagnosing-bugs skill and come back with its minimized repro as your test.

4. Refactor

Once all behaviours are covered, look for refactor candidates. See Refactoring.

Harvest shortcuts. When you took a shortcut to get a test green — skipped validation, stubbed a dependency, hardcoded a value — tag it before refactoring:

# SHORTCUT: <what's skipped>. Upgrade: <what to do when this matters>.

These markers are harvestable. Run grep -rnE '(#|//) ?SHORTCUT:' . across the repo to find accumulated shortcuts before they compound. A shortcut without an Upgrade: path is a ticking bomb — either add the path or fix it now.

Test execution

Where each tier runs (host vs Docker), output capture, timeouts, and when E2E runs during an implementation session are owned by the testing-workflow skill — follow its tier table and E2E policy.

Reference

FileUse When
TestsGood vs bad test examples, integration-style testing, tautological tests
MockingWhen to mock, designing for mockability
RefactoringRefactor candidates after TDD cycle
Goal-Driven ExamplesTransforming vague requests into verifiable goals; ❌/✅ code comparisons
<!-- SKILLOPT-SLEEP:LEARNED START -->

Learned preferences & procedures

This block is maintained by SkillOpt-Sleep. Edits here are proposed offline, validated against your past tasks, and adopted only after you approve them. Hand-edits outside this block are never touched.

  • For investigation tasks, inspect the available workspace, installed packages, source checkouts, and relevant history or logs before concluding evidence is unavailable; cite the paths and concrete evidence you find, and never replace investigation with a capability disclaimer or a request for missing paths.
  • For read-only reviews, preserve the read-only constraint: trace relevant execution paths and check each explicit behavioral invariant against code evidence, distinguishing verified findings from uncertainty without inventing defects.
  • When a task requests code, skill, or reference updates, make the requested targeted changes and validate them; report the changed paths and validation evidence rather than stopping at a diagnosis or proposed plan.
  • For package test-setup research, verify the installed package and specified source checkout independently; identify shipped tests, runnable examples, and practical test-harness guidance from the sources you inspect.
<!-- SKILLOPT-SLEEP:LEARNED END -->

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.