Guides test-driven development for Python using a five-phase red-green-refactor cycle. Use when asked to write tests first, apply TDD, do test-first implementation, or follow red-green-refactor — designs typed interfaces and Protocol classes, writes failing pytest tests (RED), implements minimal passing code (GREEN), verifies with prek or ruff plus pytest-cov, and enforces a quality gate requiring all tests pass with no lint or type errors and coverage at or above 80 percent.
Scanned 9/12/2026
Install to Claude Code
npx -y skills add Jamie-BitFlight/claude_skills --skill python3-tdd --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Python3 Tdd?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/jamie-bitflight-python3-tdd)More formats (shields.io, HTML) on the badges page.
---
name: python3-tdd
description: Guides test-driven development for Python using a five-phase red-green-refactor cycle. Use when asked to write tests first, apply TDD, do test-first implementation, or follow red-green-refactor — designs typed interfaces and Protocol classes, writes failing pytest tests (RED), implements minimal passing code (GREEN), verifies with prek or ruff plus pytest-cov, and enforces a quality gate requiring all tests pass with no lint or type errors and coverage at or above 80 percent.
argument-hint: '<feature-description>'
user-invocable: true
---
# TDD Workflow
Consult `python3-core` for standing defaults. Load `python3-testing` for detailed test patterns.
## Input
Task: $ARGUMENTS
## Phases
### 1. Design Interface
- Define function signatures with full type annotations
- Create Protocol classes for dependencies
- Write docstrings before implementation
- Load `python3-typing` when boundary types or models are involved
### 2. Write Failing Tests
- Load `python3-testing` for fixture patterns and test structure
- Tests must fail initially (RED)
- AAA pattern; behavioral naming
- Run `uv run pytest -v` — confirm failures
### 3. Implement to Pass
- Minimal code to make tests pass (GREEN)
- Run `uv run pytest -v` after each change
- Refactor only while tests stay green
### 4. Verify
```bash
# Linting, formatting, and type checking
uv run prek run --files src/ tests/
# Fallback when no .pre-commit-config.yaml:
# uv run ruff check src/ tests/
# uv run ruff format --check src/ tests/
# Tests with coverage
uv run pytest --cov=src --cov-report=term-missing
```
### 5. Quality Gate
- [ ] All tests pass
- [ ] No lint errors
- [ ] No type errors
- [ ] Coverage ≥80%
- [ ] Shebang validated on scripts
Is this your skill, or is something wrong with this listing? . Author removals are honored within 72 hours.
No comments yet. Be the first to comment!