/afb-tdd:afb-tddfrom afb-tdd
Strict red-green-refactor TDD loop with a called shot before every test and an adversarial sceptic review after Red and Green; reads the repo's committed .claude/afb-tdd/ practices when present. Use when the user wants a feature built or a bug fixed test-first, says TDD or red-green-refactor, asks for a failing regression test before the fix, or names the afb-tdd skill. Not for adding tests after the fact to code that already exists, or for general test cleanup.
Ships in afb-tdd. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This repo's resources: if .claude/afb-tdd/ exists here, read project.md (commands, layout, slice order) and practices.md (how this team tests) before the first cycle, and prefer them over the built-in conventions below wherever they disagree. They are the team's own, written by /afb-tdd-setup and committed. If the directory is absent that is normal, not a problem: fall back to the conventions below and don't raise it again. If you are about to cite an exemplar from practices.md and the file it names no longer exists, say so once — the practices were audited at manifest.json's auditedCommit and the repo has moved since.
Determine which layer to begin at (see test-patterns.md):
Then follow this strict red-green-refactor loop. Do not skip or combine steps.
Autonomous mode: when invoked as /afb-tdd --auto, or when running non-interactively (headless -p), do not pause for user confirmation at the end of Red/Green/Refactor. Still produce the same report at each pause point (called shot, failure output, results), then continue. At the end of each Refactor step, make a git commit with message tdd(cycle N): <behaviour>. Every other rule is unchanged.
When starting a new behaviour, work in this order:
Before writing the test, declare your called shot:
A mismatch between predicted and actual failure is a stop condition — delete the test and reconsider.
Write exactly one failing test — the smallest slice of behaviour that adds value.
Run the tests yourself. Check whether the test fails for the right reason (not due to a typo or syntax error).
Sceptic (on by default; skipped only when the user invoked /afb-tdd --no-sceptic or asked to skip it — sticky for the session): launch one read-only subagent following the RED checkpoint in sceptic.md. Address every finding: fix blockers and rerun the test; rebut anything you disagree with. If you fixed a blocker or concern, run the sceptic again on the updated diff, up to three rounds at this checkpoint (see Rounds in sceptic.md).
Report the failure output and confirm it's failing correctly, then wait for the user to confirm before continuing. The report must contain a Sceptic: section — every round's findings verbatim with your response to each, CLEAN, SKIPPED (--no-sceptic), or LAUNCHED, NO REPORT with your own pass in its place.
Sceptic: section — every round's findings verbatim with your response to each, CLEAN, or SKIPPED (--no-sceptic), or LAUNCHED, NO REPORT with your own pass in its place.When extracting a component out of an existing page or parent component, assert the contract, not the boundary. The parent's job is to pass a piece of data down and see it represented in the output — it should not care which child component renders it.
getByText / getByRole). Do not assert on the component's identity or structure.// ✅ Parent test — asserts the data it passes down is represented, agnostic to the child
it('shows the signed-in user', () => {
render(<Dashboard user={{ name: 'Ada' }} />);
expect(screen.getByText('Ada')).toBeInTheDocument();
});
// ✅ Component test — owns the content and structure assertions
it('renders all main navigation links', () => {
render(<Sidebar />);
expect(screen.getByRole('link', { name: /dashboard/i })).toBeVisible();
});
Fallback — data-testid: only when there is no user-visible data to key on (a purely presentational extraction like an icon or divider, or localized / non-accessible text). Then add data-testid="<component-name>" to the extracted component's root and assert getByTestId('<component-name>') is in the document — presence only, never internal content.
catch or error case without a failing test that drives it. Error handling is the code most often written speculatively and least often exercised, which is why the sceptic treats it as a blocker (G5).See sceptic.md for the adversarial review rubric (shared with the eval judge). See test-patterns.md for outside-in layer ordering, contract testing fakes, and when to use each type of test double. See conventions/go.md for Go-specific test conventions — testify, suites, fakes, transparent fakes, time control. See conventions/frontend.md for frontend test conventions — selectors, structure, factories, async patterns. See conventions/vitest.md for Vitest-specific conventions — globals, vi.fn, vi.hoisted, MSW setup. See conventions/java.md for Java-specific conventions — JUnit 5. See testing-anti-patterns.md for guidance on what not to do with mocks and test structure. See tdd-checklist.md for the completion checklist and a "when stuck" reference.
Do not attribute commits to yourself or list Claude as a co-author
references/conventions/frontend.md (opens in a new tab)references/conventions/go.md (opens in a new tab)references/conventions/java.md (opens in a new tab)references/conventions/vitest.md (opens in a new tab)references/sceptic.md (opens in a new tab)references/tdd-checklist.md (opens in a new tab)references/test-patterns.md (opens in a new tab)references/testing-anti-patterns.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
2 skills in this plugin
Other plugins' skills for the same job
npx claudepluginhub afbreilyn/afb-tdd --plugin afb-tdd