Skip to content
Back to skills

Tdd Guide

ASecurity

Test-driven development skill for writing unit tests, generating test fixtures and mocks, analyzing coverage gaps, and guiding red-green-refactor workflows across Jest, Pytest, JUnit, Vitest, and Mocha.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 14, 2026
testingjavascripttypescriptpythongojavabashtestingapisecurity

Works with

  • api

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned November 14, 2026

npx -y skills add SebastianLuser/claude-code-arcane --skill tdd-guide --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tdd Guide?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Tdd Guide
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/sebastianluser-tdd-guide/badge)](https://www.skillsdirectory.com/skills/sebastianluser-tdd-guide)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: tdd-guide
description: "Test-driven development skill for writing unit tests, generating test fixtures and mocks, analyzing coverage gaps, and guiding red-green-refactor workflows across Jest, Pytest, JUnit, Vitest, and Mocha."
argument-hint: ""
category: "testing"
user-invocable: true
allowed-tools: Read, Glob, Grep, Bash, Write, Edit
---

# TDD Guide

Test-driven development skill for generating tests, analyzing coverage, and guiding red-green-refactor workflows across Jest, Pytest, JUnit, and Vitest.

> **Note:** This skill may create or modify files in your project. It will ask before writing.

## Workflows

### Generate Tests from Code

1. Provide source code (TypeScript, JavaScript, Python, Java)
2. Specify target framework (Jest, Pytest, JUnit, Vitest)
3. Run `test_generator.py` with requirements
4. Review generated test stubs
5. **Validation:** Tests compile and cover happy path, error cases, edge cases

### Analyze Coverage Gaps

1. Generate coverage report from test runner (`npm test -- --coverage`)
2. Run `coverage_analyzer.py` on LCOV/JSON/XML report
3. Review prioritized gaps (P0/P1/P2)
4. Generate missing tests for uncovered paths
5. **Validation:** Coverage meets target threshold (typically 80%+)

### TDD New Feature

1. Write failing test first (RED)
2. Run `tdd_workflow.py --phase red` to validate
3. Implement minimal code to pass (GREEN)
4. Run `tdd_workflow.py --phase green` to validate
5. Refactor while keeping tests green (REFACTOR)
6. **Validation:** All tests pass after each cycle

## Key Tools

| Tool | Purpose | Usage |
|------|---------|-------|
| `test_generator.py` | Generate test stubs from requirements | `python scripts/test_generator.py --input requirements.json --framework pytest --module discount` (input shape: `assets/sample_input_python.json`, `assets/sample_input_typescript.json`) |
| `coverage_analyzer.py` | Parse and analyze coverage reports | `python scripts/coverage_analyzer.py --report lcov.info --threshold 80` (try it on `assets/sample_coverage_report.lcov`) |
| `tdd_workflow.py` | Check a red-green-refactor step | `python scripts/tdd_workflow.py --phase red --test test_auth.py --status failed`; `--phase green --code auth.py --status passed`; `--phase refactor --original old.py --code auth.py --status passed` |
| `fixture_generator.py` | Generate test data and mocks | `python scripts/fixture_generator.py --schema user.json --count 5` (schema: `{"email": {"type": "email"}, "age": {"type": "int", "min": 18}}`) |

## Spec-First Workflow

TDD is most effective when driven by a written spec. The flow:

1. **Write or receive a spec** -- stored in `specs/<feature>.md`
2. **Extract acceptance criteria** -- each criterion becomes one or more test cases
3. **Write failing tests (RED)** -- one test per acceptance criterion
4. **Implement minimal code (GREEN)** -- satisfy each test in order
5. **Refactor** -- clean up while all tests stay green

### Extracting Tests from Specs

Each acceptance criterion in a spec maps to at least one test:

| Spec Criterion | Test Case |
|---------------|-----------|
| "User can log in with valid credentials" | `test_login_valid_credentials_returns_token` |
| "Invalid password returns 401" | `test_login_invalid_password_returns_401` |
| "Account locks after 5 failed attempts" | `test_login_locks_after_five_failures` |

**Tip:** Number your acceptance criteria in the spec. Reference the number in the test docstring for traceability (`# AC-3: Account locks after 5 failed attempts`).

## Bounded Autonomy Rules

### Stop and Ask When

- **Ambiguous requirements** -- the spec has conflicting or unclear acceptance criteria
- **Missing edge cases** -- you cannot determine boundary values without domain knowledge
- **Test count exceeds 50** -- large test suites need human review before committing
- **External dependencies unclear** -- third-party APIs with undocumented behavior
- **Security-sensitive logic** -- auth, encryption, or payment flows require human sign-off

### Continue Autonomously When

- **Clear spec with numbered acceptance criteria** -- each criterion maps directly to tests
- **Straightforward CRUD operations** -- well-defined models
- **Well-defined API contracts** -- OpenAPI spec or typed interfaces available
- **Pure functions** -- deterministic input/output with no side effects
- **Existing test patterns** -- the codebase already has similar tests to follow

## Code Examples and Advanced Patterns

> See references/tdd-best-practices.md for the red-green-refactor discipline and test naming, references/framework-guide.md for Jest, Pytest, JUnit and Vitest specifics, and references/ci-integration.md to run coverage gates in CI.

> See references/tdd-code-examples.md for complete examples covering Pytest, Jest, Go table-driven tests, property-based testing (Hypothesis, fast-check), mutation testing, and coverage analysis output.

## Cross-References

| Skill | Relationship |
|-------|-------------|
| `engineering/spec-driven-workflow` | Spec --> acceptance criteria --> test extraction pipeline |
| `engineering-team/focused-fix` | Phase 5 (Verify) uses TDD to confirm the fix with a regression test |
| `engineering-team/senior-qa` | Broader QA strategy; TDD is one layer in the test pyramid |

## Limitations

| Scope | Details |
|-------|---------|
| Unit test focus | Integration and E2E tests require different patterns |
| Static analysis | Cannot execute tests or measure runtime behavior |
| Language support | Best for TypeScript, JavaScript, Python, Java |
| Report formats | LCOV, JSON, XML only; other formats need conversion |
| Generated tests | Provide scaffolding; require human review for complex logic |

Files in this skill

  • SKILL.md5.6 KB
  • assets/sample_coverage_report.lcov615 B
  • assets/sample_input_python.json1.4 KB
  • assets/sample_input_typescript.json1.4 KB
  • references/ci-integration.md3.9 KB
  • references/framework-guide.md4.2 KB
  • references/tdd-best-practices.md3.4 KB
  • references/tdd-code-examples.md6.5 KB
  • scripts/coverage_analyzer.py15.9 KB
  • scripts/fixture_generator.py14.6 KB
  • scripts/tdd_workflow.py17.8 KB
  • scripts/test_generator.py15.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.