/a-team:test-driven-developmentfrom a-team
Enforces RED-GREEN-REFACTOR discipline for all implementation tasks. Guides writing tests first, minimal code to pass, and refactoring with coverage.
Ships in a-team. 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.
None: SKILL.md is the whole skill.
IF YOU DIDN'T WATCH THE TEST FAIL, YOU DON'T KNOW IF IT TESTS THE RIGHT THING.
A green test you've never seen red is not a test — it's a decoration.
Write the test FIRST. Not after. Not "I'll add it later." First.
The test must:
// RED: Write this BEFORE writing the function
test('returns empty array when no users match the filter', () => {
const result = filterActiveUsers([])
expect(result).toEqual([])
})
Run it. Watch it fail.
npm test -- --testPathPattern="user-filter"
# Expected: FAIL (function doesn't exist yet)
If the test passes before you write the implementation: the test is wrong. Rewrite it.
Write the smallest possible code that makes the test pass. Nothing more.
// GREEN: Minimal implementation that passes the test
function filterActiveUsers(users: User[]): User[] {
return users.filter(u => u.active)
}
Run it. Watch it pass.
npm test -- --testPathPattern="user-filter"
# Expected: PASS
If it still fails: read the error message carefully. Fix only what the message tells you.
Now clean up. Rename, extract, simplify — while keeping tests green.
# Run tests continuously during refactor
npm test -- --watch --testPathPattern="user-filter"
Rules during refactor:
After GREEN for the first case, expand coverage:
RED → watch new test fail
GREEN → minimal code to pass
RED → add next edge case test
GREEN → handle the edge case
...
REFACTOR → clean up all at once when coverage is complete
Cover in order:
Test:
Do NOT test:
External dependencies (database, APIs, file system) must be mocked in unit tests:
// Mock the DB before testing the service
jest.mock('../db/users')
const mockFindUser = db.findUser as jest.MockedFunction<typeof db.findUser>
mockFindUser.mockResolvedValue({ id: '1', name: 'Alice', active: true })
Integration tests should hit real dependencies — but unit tests must be fast and isolated.
After each feature or bug fix, verify coverage meets the project minimum:
npm run test:coverage
# Required: ≥ 80% branches, functions, lines, statements
If coverage drops below threshold: add tests before moving on.
If you catch yourself rationalizing any of these: stop, revert to the last green state, and start the RED phase properly.
TDD fits into the full workflow:
brainstorming → spec approvedwriting-plans → plan with test strategy includedtest-driven-development ← you are here, per tasksubagent-driven-development → each subagent runs TDD internallyverification-before-completion → final proof before claiming donefinishing-a-development-branch → branch wrap-upWhat SKILL.md sets; muted values are Claude Code's defaults
20 skills in this plugin
/api-contract-firstHard gate before implementing any API endpoint or service interface. Requires a written, reviewed contract (OpenAPI 3.x, protobuf, or GraphQL schema) before any implementation code is written. Prevents breaking changes, misaligned clients, and undocumented behaviour./architecture-auditSystematic architecture review workflow. Use before major feature work on an unfamiliar or inherited codebase, before scaling milestones, or as a periodic health check. Maps the system as-built (not as-documented), dispatches parallel specialist reviews, and produces an evidence-backed findings report with severity verdicts./brainstormingUse BEFORE any creative work — creating features, building components, adding functionality. Explores user intent, requirements, and design before implementation. Hard-gated: no code until user approves the spec./data-migrationHard gate before any database schema change or data transformation in production. Requires a written migration plan with rollback strategy, dry run, and verification steps before execution. Prevents data loss, downtime, and irreversible schema changes./dispatching-parallel-agentsUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies. Dispatches one focused agent per problem domain, runs them concurrently, then integrates./executing-plansUse when you have a written implementation plan to execute in the current session. Loads the plan, reviews critically, executes all tasks, and reports when complete.npx claudepluginhub rbraga01/a-team --plugin a-teamOther plugins' skills for the same job