tdd

Guides test-driven development using the red-green-refactor loop with behavior-focused tests.

Updated May 31, 2026
One-click install
npx skills add https://github.com/AlexanderNarbaev/agi --skill tdd-alexandernarbaev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/AlexanderNarbaev/agi/tree/main/.opencode/skills/matt-pocock/tdd
Command: npx skills add https://github.com/AlexanderNarbaev/agi --skill tdd-alexandernarbaev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after implementation often produces brittle tests coupled to internal structure that break on every refactor. This Skill enforces the red-green-refactor discipline so tests verify observable behavior through public interfaces and survive code changes. ## Core Features & Use Cases - Red-Green Loop Rules: Write the failing test first, then only enough code to pass it, one vertical slice at a time. - Seam Identification: Define and confirm public test boundaries with the user before writing any test, keeping effort on critical paths. - Anti-Pattern Detection: Avoid implementation-coupled, tautological, and horizontally-sliced tests with concrete good/bad examples. - Mocking Guidelines: Mock only at system boundaries like external APIs, time, and randomness, never internal collaborators. - Use Case: When adding a checkout feature, ask the assistant to build it test-first; it will agree on seams with you, write a failing behavior test, implement the minimal code to pass, and repeat per slice. ## Quick Start Ask the assistant to implement a new feature or bug fix using test-driven development with the red-green-refactor loop.

Frequently Asked Questions about tdd

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I practice test-driven development with the red-green-refactor loop?

Write one failing test for a single behavior first (red), then write only enough code to make it pass (green), and repeat per vertical slice. Refactoring happens separately during code review, not inside the red-green cycle.

What makes a good unit test versus a bad test?

Good tests verify behavior through public interfaces, read like specifications, and survive refactors. Bad tests mock internal collaborators, test private methods, assert on call counts, or recompute expected values the same way the implementation does.

When should I use mocks in testing?

Mock only at system boundaries such as external APIs, databases, time, randomness, and the file system. Never mock your own classes or internal collaborators, and prefer dependency injection plus SDK-style interfaces to keep mocks simple.

What is a test seam in TDD?

A seam is the public boundary where you observe behavior without reaching inside the module. Tests should live only at pre-agreed seams confirmed with the user before any test is written, focusing effort on critical paths.

Why do my tests break every time I refactor code?

Tests break on refactoring when they are coupled to implementation details, such as mocking internal collaborators or asserting on private method calls. Rewrite them to verify observable behavior through the public interface instead.