Test driven development
Use when new logic requires implementation, or when a TDD red flag appears — a trivially passing test, code written before its test, or GREEN with no observed RED.From its SKILL.md
npx -y skills add j0hanz/squad-agents --skill test-driven-developmentAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
6.4 KB, as published. Nobody here has run it
test-driven-development
Autonomous TDD execution. HARD GATE: No implementation code WITHOUT a failing test — observe RED before every GREEN; a GREEN you never saw fail tests nothing.
When NOT to use TDD
Escape hatches from the HARD GATE. Never self-invoke one silently — confirm via AskUserQuestion first (the tool supplies a free-text "Other"). Pick from the three categories below:
- Recommended — Skip TDD: [matching category] because [specific reason].
- Alternative — Use full TDD anyway + reason the escape hatch doesn't apply.
- Exploratory Spikes: Implementation path unknown; throwaway code to "find the shape." Mandatory: once found, the spike MUST be discarded (
git stash drop/delete, not committed) and re-implemented through RED-GREEN-REFACTOR. A spike is a sketch, never the shipped diff. - Trivial One-Liners: Pure data mappings or standard boilerplate with zero logic.
- Pure UI/CSS: Visual styling needing manual "eye-balling," not logical assertions.
Process Flow
- Start: TDD Request
- Escape hatch applies (spike/trivial/CSS): AskUserQuestion confirms skip -> exit (handle outside this skill)
- No escape hatch: 0. Confirm with user -> Pre-TDD: Interface (signatures, errors, examples) -> TDD Cycle
- TDD Cycle:
- 1. RED (write failing test + minimal stub) -> run test, confirm failure
- failure confirmed: 2. GREEN (write minimal implementation) -> run test
- 2. GREEN (write minimal implementation)
- fail: Stuck? (3+ attempts)
- yes: request-plan (handoff)
- no: retry GREEN
- pass: 3. REFACTOR
- fail: Stuck? (3+ attempts)
- 3. REFACTOR (surgical cleanup) -> run test, stay passing
- All behaviors covered?
- no: back to TDD Cycle
- yes: verification-before-completion (handoff)
- All behaviors covered?
- 1. RED (write failing test + minimal stub) -> run test, confirm failure
Step 0: Confirm Scope
action: AskUserQuestion.
- Recommended: Start TDD for [feature].
- Alternative: Explore first, then start TDD — state why exploration is needed before code.
Done when: user response is captured via AskUserQuestion.
Pre-TDD: Define the Interface
action: AskUserQuestion to lock the shape before writing a test against it.
- Recommended:
name(inputs) -> output. - Alternative: Propose a different shape and justify it.
- Enumerate expected error conditions.
- Provide 2-3 call-site examples.
- State the target test file path.
- Start the behavior list: happy path + the enumerated errors; it grows by one edge case per RED cycle and is the coverage gauge for REFACTOR.
- Gate: run the relevant existing tests first — establish a clean baseline before adding new tests.
Done when: interface details, errors, and test path are locked and user confirms.
Step 1: RED (Failing Test)
If JavaScript/TypeScript, read references/js-ts-patterns.md fully.
- Write the smallest test for one behavior.
- Stub the implementation (e.g.
return null) — just enough to compile/run. - Run the test.
- Gate: confirm FAILURE. A test that passes immediately tests nothing — delete and rewrite it.
Done when: the test runs and fails for the targeted behavior (RED confirmed), not the environment.
Step 2: GREEN (Make It Pass)
If unsure how minimal is minimal, read references/minimal-impl-examples.md fully.
- Checkpoint the working tree before editing.
- Write the smallest implementation that satisfies the test — no speculative generality.
- No code added "just in case" — only what the current test requires.
- 3 failed attempts on the same test → restart with a smaller test.
- Still stuck → escalate to
request-plan.
N-1 Test (False-Green Elimination)
Before trusting a passing test:
- Revert the implementation.
- Run the test — confirm RED.
- Restore the implementation.
- Run the test — confirm GREEN.
Done when: the test passes on the minimal implementation and the N-1 check holds (revert → RED, restore → GREEN).
Step 3: REFACTOR (Clean Up)
- Gate: only proceed while GREEN.
- Improve structure (naming, deduplication) without changing behavior.
- Never interleave a behavior fix with a refactor — separate passes.
- Re-run tests after every refactor; must stay GREEN.
- Done when: no further structural improvement available AND the relevant tests GREEN; then evaluate coverage against the behavior list (gaps → back to RED; else hand off).
Strict Rules
- Mock only true externals (databases, APIs, network) — never mock the code under test.
- No second test until the first has completed its full RED-GREEN-REFACTOR cycle.
- If the test itself is wrong (not the implementation), return to RED, state why, then rewrite it — don't edit a test to force a pass (see Red Flags).
Red Flags — Stop Rationalizing, Delete and Restart
Any of these signals means you have left TDD. The fix is the same every time: delete the implementation (or the code-first diff), return to RED, and re-drive the cycle. Do not argue the case; do not "adapt" what you wrote.
- Implementation written before, or without, a failing test for the behavior it adds (a HARD GATE violation).
- The test trivially passes without exercising the logic under test (e.g. asserts a constant the stub already returns, mocks the unit itself, or never calls the code path).
- Tests retrofitted to match already-written code ("tests-after"), or a test edited to force a pass.
- Self-talk: "too simple to test", "I already manually tested it", "tests after achieve the same purpose", "it's the spirit that matters, not the ritual", "this is different because...".
- Skipping the N-1 check because "it obviously would fail" — a test you have not seen fail is testing nothing.
- A GREEN that arrives on the first run with no RED observed for that specific behavior.
- Keeping code-first output "as reference" or "to adapt" instead of deleting it.
All of these mean: delete the code-first implementation, re-enter the cycle at RED, and run the test to confirm it fails before re-implementing.
Next Steps
On full behavior-list coverage and a clean REFACTOR, hand off to verification-before-completion.