# Test Driven Development

> Use when implementing any feature or bugfix in code — guides the strict RED-GREEN-REFACTOR cycle: write one failing test, confirm it fails for the right reason, write the minimal code to pass, refactor while the context is fresh.

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

## Install

```sh
agentstack add skill-infews-pxp-skill-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

A disciplined cycle for writing code one behavior at a time: red (failing test) → green (minimal code) → refactor.

## The Iron Law

**No production code without a failing test first.** Not even one line. Not even "I'll just sketch this out." Not even "the test is obvious — I'll add it after."

## The Cycle

### 1. Write the failing test

Write a single test for one behavior. The test should:

- Describe *what* you want, not *how* it's done.
- Fail in a meaningful way (assertion error — not syntax error, not missing import).
- Be small — favor one method's behavior over a whole class.

### 2. Confirm red

Run the test. Confirm it fails for the expected reason.

- Unexpected failure reason: diagnose first; don't paper over with implementation.
- Passes without any implementation: the behavior already exists, or the test isn't testing what you think. Investigate.

### 3. Write the minimal implementation

Write the simplest code that makes the test pass. Resist the urge to add more.

- No "while I'm here" additions.
- No defensive code for cases not yet tested.
- No abstractions for hypothetical future tests.

### 4. Confirm green

Run the test. Confirm it passes. Run the full suite to check for regressions.

### 5. Refactor

Look at the code you just wrote and the code around it:

- Is there duplication to extract?
- Are names clear and intention-revealing?
- Is the code as simple as it can be while remaining clear?
- Any code smells?

If you see an improvement, make it. Re-run tests. If nothing needs refactoring, say so out loud and move on.

## Common Rationalizations

| Excuse | Reality |
|---|---|
| "Test is trivial, I'll skip it" | Trivial tests catch real regressions later. Write it. |
| "I already manually tested it" | Manual tests don't run in CI. Write the automated test. |
| "I'll write the test after" | Tests-after asks "what does this do?" Tests-first asks "what should this do?" Different exercises. |
| "Refactor isn't needed here" | Say so explicitly. Don't silently skip Step 5. |
| "I'll batch the refactor at the end" | Refactor with context fresh, not after you've moved on. |

## Red Flags — STOP

- Code before test.
- "I'll just sketch this out and add the test later."
- Test added after the code already passed manually.
- Implementing more than one behavior per cycle.
- Skipping Step 5 without saying so.

All of these mean: stop, delete the unprotected code, start the cycle properly.

## Source & license

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

- **Author:** [infews](https://github.com/infews)
- **Source:** [infews/pxp_skill](https://github.com/infews/pxp_skill)
- **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-infews-pxp-skill-test-driven-development
- Seller: https://agentstack.voostack.com/s/infews
- 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%.
