Skip to content
Agentmart
Submit a tool

tdd

Use when building any T3 feature or bugfix, recommended for T2 on the affected path — write the failing test before the implementation, one behavior at a…

Skill by AbdurRafay2004

IndexedMIT★ 4
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/abdurrafay2004-tdd

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Use when building any T3 feature or bugfix, recommended for T2 on the affected path — write the failing test before the implementation, one behavior at a time, through public interfaces.

Use cases: testing, writing

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/tdd

What's inside

Skill name
tdd
Description
Use when building any T3 feature or bugfix, recommended for T2 on the affected path — write the failing test before the implementation, one behavior at a time, through public interfaces.
License
MIT
Instructions
150 lines in SKILL.md · view on GitHub

Files (2)

  • SKILL.md
  • mocking.md · references/

SKILL.md (first lines)

# TDD

Part of the **Build** phase — see the `workflow` skill for tiers and sequencing.

**Tier rule:** mandatory for T3 (money, auth, user data, migrations);
recommended for T2 on the affected path; skipped for T1 (copy/styling). Within
its tier, the discipline is absolute: **no production code without a failing
test first.** Bug fixes always get a failing test reproducing the bug, at any
tier — a fix without a test doesn't stick.

## Philosophy

Tests verify **behavior through public interfaces**, not implementation
details. Code can change entirely; tests shouldn't.

**Good tests** are integration-style: they exercise real code paths through
public APIs and read like a specification — "user can checkout with valid
cart" tells you exactly what capability exists. They survive refactors because
they don't care about internal structure.

**Bad tests** are coupled to implementation: they mock internal collaborators,
test private methods, or verify through side channels (querying the database
directly instead of using the interface). The warning sign: the test breaks
when you refactor but behavior hasn't changed.

**Core proof:** if you didn't watch the test fail, you don't know it tests the
right thing. A test written after the code passes immediately — and passing
immediately proves nothing.

## Anti-pattern: horizontal slices

**Do not write all tests first, then all implementation.** Bulk-written tests
test *imagined* behavior — the shape of data structures rather than
user-facing behavior — and become insensitive to real changes.

```
WRONG (horizontal):  RED: test1..test5  →  GREEN: impl1..impl5
RIGHT (vertical):    test1→impl1, test2→impl2, test3→impl3 ...
```

Vertical slices via **tracer bullets**: one test → one implementation →
repeat. Each test responds to what the previous cycle taught you.

## Workflow

### 1. Plan the behaviors

Read the nearest `CONTEXT.md` / `.handoff/context/` so test names match the
project's domain language. Then, before any code:

- Confirm with the user what interface changes are needed.
- Confirm which behaviors to test — **you can't test everything**; focus on
  critical paths and complex logic, not every edge case. (This is the PM
  decision: which failures are expensive?)
- Look for deep-module opportunities — small interface, deep implementation
  (see `design`).
- List behaviors, not implementation steps.

### 2. Tracer bullet

Write ONE test confirming ONE thing about the system. Watch it fail. Write
minimal code to pass. This proves the path works end-to-end.

### 3. Incremental loop

For each remaining behavior: RED → verify it fails for the right reason →
GREEN → verify it passes → next.

- One test at a time; only enough code to pass the current test.
- Don't anticipate future tests; no speculative features.
- **Verify RED is mandatory.** If the new test passes immediately, it's
  testing existing behavior — fix the test. If it errors (rather than fails),
  fix the error until it fails correctly.
- **Verify GREEN completely:** the new test passes, all other tests still
  pass, output pristine. Test fails → fix the code, not the test.

### 4. Refactor (only on green)

Extract duplication, improve names, deepen modules (move complexity behind
simple interfaces). Run tests after each refactor step. **Never refactor while
RED.** Don't add behavior.

## Good vs bad tests

```typescript
// ✅ Clear name, real behavior, one thing
test('retries failed operations 3 times', async () => {
  let attempts = 0;
  const operation = () => {
    attempts++;
    if (attempts < 3) throw new Error('fail');
    return 'success';
  };
  const result = await retryOperation(operation);
  expect(result).toBe('success');
  expect(attempts).toBe(3);
});

// ❌ Vague name, tests the mock, not the code
test('retry works', async () => {
  const mock = jest.fn()
    .mockRejectedValueOnce(new Error())
    .mockResolvedValueOnce('success');
  await retryOperation(mock);
  expect(mock).toHaveBeenCalledTimes(2);
});
```

- One behavior per test; "and" in the name means split it.
- Real code over mocks — mock only what's unavoidable (network, clock, true
  externals). If you must mock everything, the code is too coupled: inject
  dependencies instead. Boundary rules and mock-friendly interface design:
  `references/mocking.md`.
- Testing mock behavior instead of real behavior is the classic false
  positive: the suite goes green while the product is broken.

## Per-cycle checklist

```

From AbdurRafay2004/handoff, MIT.

More from AbdurRafay2004/handoff

Signals

Stars
4
Forks
0
Open issues
0
Last commit (this folder)
Jul 11, 2026 (3 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from AbdurRafay2004

Cite this page

tdd skill. Agent Mart. https://agentmart.dev/skills/abdurrafay2004-tdd (last updated 2026-10-24)