Tdd

From pixelastic/oroshi · View interactive version

Tdd is an AI agent skill from the GitHub repository pixelastic/oroshi. Used when user wants to build features or fix bugs using TDD or red-green-refactor loop.

How to use this skill

Skill file

Test-Driven Development

Overview

Build features and fix bugs using the red-green-refactor loop: write a failing

test first, write minimal code to pass it, then refactor.

Use Behavioral tests for behavioral testing, and Scaffolding tests for

structural architecture.

Apply the London School of TDD for mocking. Each unit is tested in isolation by

mocking its immediate collaborators.

Core Workflow

Step 1 — Plan

Goal: Agree on interface, behaviors to test, and test strategy before

writing any code.

Exit criterion: User has approved the plan and test strategy is declared

(scaffold/behavioral and what to mock).

When exploring the codebase, use the project's domain glossary so that test

names and interface vocabulary match the project's language.

Apply the pivot question for each test:

"If I rewrote the internals from scratch while keeping the same public API,

would this test still pass?"

Ask yourself "What should the public interface look like? Which behaviors are

most important to test?"

You can't test everything. Confirm with the user exactly which behaviors

matter most. Focus testing effort on critical paths and complex logic, not every

possible edge case.

rewrite)

ephemeral)

(small interface, deep implementation)

Step 2 — Tracer Bullet

Goal: Prove the test infrastructure works with one failing test and one

minimal implementation.

Exit criterion: One test is RED, then GREEN — the path works end-to-end.

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.

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:

signatures) rather than user-facing behavior

fail when behavior is fine

the implementation

Correct approach: Vertical slices via tracer bullets. One test → one

implementation → repeat.

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
  ...

Step 3 — Incremental Loop

Goal: Cover all planned behaviors one test at a time.

Exit criterion: All planned behaviors have a passing test, no speculative

features added.

For each remaining behavior:

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

Rules:

Step 4 — Refactor

Goal: Improve the design without changing behavior.

Exit criterion: No duplication, clean names, all tests still green.

After all tests pass, look for refactor candidates:

Never refactor while RED. Get to GREEN first.

Common Rationalizations

| Rationalization | Reality |

| ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |

| "Private methods shouldn't be tested directly" | private controls API visibility, not testability. Complex logic deserves a test regardless of exposure. |

| "Mocking internal collaborators couples tests to implementation" | Mocking _immediate_ collaborators is isolation, not coupling. Coupling is reaching _inside_ your collaborator. |

| "Testing at the public interface is always enough" | No. Complex private helpers should also be tested. |

| "I'll write the test after to go faster" | Tests-after prove nothing. Delete the code. Start with RED. |

| "I should write all tests first, then implement" | That's horizontal slicing. It produces tests of imagined behavior. Do vertical tracer bullets instead. |

Checklist

js-writer, etc)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.