# Test Driven Development

> Drive implementation with tests. Use when fixing bugs, changing behavior, adding logic, modifying contracts, or proving that agent-written code works and remains safe across regressions.

- **Type:** Skill
- **Install:** `agentstack add skill-hsienw-ai-agent-engineering-playbook-test-driven-development`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [HsienW](https://agentstack.voostack.com/s/hsienw)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [HsienW](https://github.com/HsienW)
- **Source:** https://github.com/HsienW/ai-agent-engineering-playbook/tree/master/skills-delivery-practices/test-driven-development

## Install

```sh
agentstack add skill-hsienw-ai-agent-engineering-playbook-test-driven-development
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Test-Driven Development

## Skill Interface

- Name: test-driven-development.
- Description: Drive implementation with tests when fixing bugs, changing behavior, adding logic, modifying contracts, or proving that agent-written code works and remains safe across regressions.
- Parameters: Desired behavior, bug reproduction, affected logic or contract, existing tests, suitable test layer, fixtures or inputs, and available test commands.
- Instructions: Use this skill before or during behavior changes. Start with a failing or relevant test, make the smallest implementation change, refactor while tests stay green, and run adjacent regression checks.

Use tests to prove behavior, not to document implementation trivia.

## Cycle

1. Red: write or identify a failing test that captures the required behavior or
   bug.
2. Green: make the smallest implementation change that passes.
3. Refactor: simplify while keeping tests green.
4. Regression: run adjacent existing tests that could be affected.

## Bug Fix Pattern

1. Reproduce the bug with a failing test, fixture, command, trace, or fixed
   input/output pair.
2. Confirm the failure matches the reported issue.
3. Fix the root cause.
4. Re-run the same reproduction and relevant regression tests.
5. Keep the regression test unless it is too expensive and a documented manual
   check is more appropriate.

## Test Selection

- Unit tests for deterministic logic.
- Integration tests for boundaries, adapters, persistence, and schemas.
- Contract tests for APIs, events, messages, and error envelopes.
- End-to-end tests for critical user workflows.
- Smoke tests for live providers only when environment and cost are acceptable.

## Rules

- Do not delete failing tests to get a green run.
- Do not loosen assertions unless the old assertion was wrong.
- Do not mock the core behavior being tested.
- Do not hide races with fixed sleeps.
- Do not claim unexecuted tests passed.

## Coverage Checklist

Consider:

- Normal success.
- Invalid input.
- Unknown fields or variants.
- Upstream failure.
- Permission denied.
- Timeout and cancellation.
- Retry or duplicate event.
- Partial result or degraded behavior.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [HsienW](https://github.com/HsienW)
- **Source:** [HsienW/ai-agent-engineering-playbook](https://github.com/HsienW/ai-agent-engineering-playbook)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-hsienw-ai-agent-engineering-playbook-test-driven-development
- Seller: https://agentstack.voostack.com/s/hsienw
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
