Skip to main content
Agent skill

Python Tdd

Python development with TDD using pytest, type checking with mypy, and linting with ruff/black. Use when working on Python projects requiring test-driven development, quality gates, or Python code review. Do NOT use for other programming languages.

Get started

Get the complete skill folder, including its scripts and reference files.

When to use this skill

Use Python Tdd when an AI agent needs a reusable SKILL.md workflow for this job: Python development with TDD using pytest, type checking with mypy, and linting with ruff/black. Use when working on Python projects requiring test-driven development, quality gates, or Python code review. Do NOT use for other programming languages.

When not to use it

Skip Python Tdd when the task is outside the coding category, or when a more specific skill in this directory already covers the same workflow with clearer triggers.

How to install

Where will you use it?

Install scope
Claude Code folder setup
mkdir -p ~/.claude/skills/python-tdd
# Save SKILL.md to ~/.claude/skills/python-tdd/SKILL.md
  1. Claude Code personal install: place the skill and its bundled files at ~/.claude/skills/python-tdd/SKILL.md. For a shared project, commit the folder at .claude/skills/python-tdd/ instead.
  2. Current Claude Code detects SKILL.md changes in watched directories during the session. If you just created a top-level skills directory, run /reload-skills. Check that the skill is listed before testing its trigger.
  3. For Claude chat or Cowork in the Desktop app, manage uploaded skills in Customize > Skills; copying files into a local Claude Code folder is not a Desktop install. Other agents may use different install locations.

Full install guide for Claude, Cursor, and Codex →

Try a starter prompt

After installing the skill, paste this starter prompt into your agent to verify it triggers on a small task.

Starter prompt
Use the Python Tdd skill for this task: Understand requirements from GitHub issue. Confirm any required inputs or files before making changes.

What supports this recommendation?

81/100 provisional content score. This measures documentation, practical detail and source signals. It is not a measured task success rate or a security certification.

Documentation
92/100
Practical detail
92/100
Source evidence
53/100
Source signals
70/100
Model compatibility evidence
  • claudeuntested

    No model-specific signal or recorded compatibility test was found.

  • chatgptuntested

    No model-specific signal or recorded compatibility test was found.

  • geminiuntested

    No model-specific signal or recorded compatibility test was found.

  • copilotuntested

    No model-specific signal or recorded compatibility test was found.

  • llamauntested

    No model-specific signal or recorded compatibility test was found.

  • perplexityinferred

    The skill text mentions Perplexity or a closely associated term. This is keyword-derived compatibility; no hands-on model test is recorded.

  • mistraluntested

    No model-specific signal or recorded compatibility test was found.

  • grokuntested

    No model-specific signal or recorded compatibility test was found.

Inferred compatibility is based on content signals. Check the app, its available tools and setup requirements before running a skill.

What this skill does

# Python TDD Architect

You are an expert Python architect enforcing modern, scalable, maintainable code through rigorous TDD and quality gates.

## Core Principles

- **Test-Driven Development**: Write tests BEFORE implementation - **Coverage Requirements**: 80% minimum, 95%+ for critical paths (auth, payments, data integrity) - **Type Safety**: Type hints on all public APIs, strict mypy compliance - **PEP 8 Compliance**: Via ruff (replaces flake8, isort, black)

## Workflow

1. Understand requirements from GitHub issue 2. Write failing tests first (pytest) 3. Implement minimal code to pass tests 4. Refactor while maintaining green tests 5. Run full quality gate before completion

## Quality Gate Checklist

Before delegating to git operations: - [ ] `pytest tests/ --cov --cov-report=term-missing` shows 80%+ coverage - [ ] `mypy --strict src/` passes (or project's mypy config) - [ ] `ruff check .` passes - [ ] `ruff format --check .` passes - [ ] Zero test failures (see Zero Failures Rule below)

## Tool Preferences

| Category | Tool | Notes | |----------|------|-------| | Testing | pytest, pytest-cov, pytest-xdist | xdist for parallel execution | | Types | mypy (strict mode) | All public APIs typed | | Linting | ruff | Replaces flake8, isort, black | | Formatting | ruff format | Or black if project uses it | | Dependencies | uv or pip-tools | pip-compile for pinning |

## Project Structure

``` project/ ├── src/ │ └── package/ ├── tests/ │ ├── unit/ │ └── integration/ ├── pyproject.toml └── requirements.in # pip-compile → requirements.txt ```

## Zero Test Failures Rule

**ALL tests must pass - ZERO failures, NO exceptions.**

If ANY test fails: 1. STOP - Do not claim quality gates passed 2. REPORT: "X tests failing. Cannot proceed." 3. WAIT for decision on how to handle 4. NEVER rationalize failures

**Forbidden rationalizations:** - "Pre-existing issue, unrelated to this fix" - "External library problem" - "Integration test only" - "Known flaky test" - "Will be fixed in separate PR"

## Forbidden Practices (Zero Tolerance)

These constitute quality gate bypass attempts:

| Practice | Why Forbidden | Correct Action | |----------|---------------|----------------| | `# noqa` comments | Hides issues | Fix the code | | `# type: ignore` | Bypasses type safety | Fix type hints | | Modifying linter ignores | Config manipulation | Fix the code | | Skipping tests | Hides failures | Fix the tests | | Reducing coverage thresholds | Lowers standards | Write more tests |

**The ONLY acceptable response to linting errors is to FIX THE CODE.**

## Environment Setup

```bash # Create and activate venv python -m venv .venv source .venv/bin/activate # or .venv\Scripts\activate on Windows

# Install dependencies pip install -r requirements.txt pip install -e ".[dev]" # if using pyproject.toml extras ```

## CI Verification

Never declare victory without verification: - DON'T say "CI will pass now" - DO wait for actual CI results - Work is NOT complete until CI confirms green

## Research

Use Perplexity for Python-specific questions: - `perplexity-ask_reason` for best practices - `perplexity-ask_search` for specific technical issues

For detailed patterns, see: - references/pytest-patterns.md - references/linting-config.md

## Completion Report Format

When reporting to PM, include EXACT output: ``` QUALITY GATES PASSED: - pytest: X/X passing (0 failures) - coverage: X% (≥80% ✓) - mypy --strict: 0 errors - ruff check: 0 violations - ruff format: all formatted ```

❌ NEVER: "tests should pass" or "linting looks good" ✅ ALWAYS: exact counts from terminal output

## File Hygiene

- Docs → `docs/`, Tests → `tests/`, no throwaway files in project root - Litmus test: "Will this file be useful 200 PRs from now?" - FORBIDDEN: debug_*.py, temp scripts, root-level markdown summaries

Intended uses

  • Understand requirements from GitHub issue
  • Write failing tests first (pytest)
  • Implement minimal code to pass tests
  • Refactor while maintaining green tests
  • Run full quality gate before completion

Implementation notes

  • Review the source instructions and adapt inputs before running the workflow.

Try it, then tell us how it went

A copied prompt does not tell us whether the task worked. Report your result after checking the output. We collect your tool and outcome, never your files or prompt.