python-tdd

python-tdd is a skill for Claude Code from acaprino/daodan. It costs 81 tokens per session (2,530 once invoked), scanned A, original, MIT.

A Python testing guide for writing pytest tests that check observable behavior rather than internal code structure. It also describes the red-green-refactor process, where you write a failing test, make it pass, then improve the code.

In plain words
What is it for?
Use it to write, review, or expand Python test suites with pytest, and to assess whether tests cover real user-facing behavior.
Why use it?
It helps prevent tests that break whenever implementation details change or that pass without checking useful behavior. It also gives guidance on edge cases, errors, side effects, and when to use mocks.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the python-development plugin — 9 skills, 3 commands, 3 agents shipped together

Good fit Use it to write, review, or expand Python test suites with pytest, and to assess whether tests cover real user-facing behavior.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/acaprino/daodan/python-tdd
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add acaprino/daodan --skill python-tdd
Clone the repo
git clone --depth 1 https://github.com/acaprino/daodan

Made for: Claude Code.

Or install python-development, the plugin that ships this one along with the rest of its 9 skills, 3 commands, 3 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for python-tdd

README.md
[![agentmods](https://agentmods.dev/badge/skills/acaprino/daodan/python-tdd.svg)](https://agentmods.dev/skills/acaprino/daodan/python-tdd)
Your own site
<a href="https://agentmods.dev/skills/acaprino/daodan/python-tdd"><img src="https://agentmods.dev/badge/skills/acaprino/daodan/python-tdd.svg" alt="Measured on agentmods" height="20"></a>
Per session 81 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,530 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00081 $0.02530
Opus 5 $0.00041 $0.01265
Sonnet 5 $0.00016 $0.00506
Haiku 4.5 $0.00008 $0.00253

Measured 2d ago against content hash a4273d2d4ac6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

python-tdd scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

@patch("myapp.services.requests.get") # patch where USED (top-level import)
exports/claude/plugins/python-development/skills/python-tdd/SKILL.md · 285 lines

How it starts

The opening of the file, as written. The whole thing — 285 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Testing Patterns

Generate focused, behavior-driven tests with pytest. Prioritize observable behavior over implementation details. For framework configuration (pyproject.toml, plugins, CI), see references/framework-config.md. For deep conftest patterns and heavy-dep mocking, see references/pytest-infrastructure.md. For full TDD discipline, see references/tdd-best-practices.md.

1. Test Philosophy

What to test

  • Observable behavior and return values
  • User-facing workflows and API contracts
  • Edge cases and error handling at system boundaries
  • State transitions and side effects
  • Data validation and transformation rules

What NOT to test

  • Framework internals (pytest, SQLAlchemy, FastAPI mechanics)
  • Implementation details (private methods, internal variable names)
  • Third-party library behavior
  • Simple utility functions with no branching logic
  • That objects are truthy -- this asserts nothing useful

Mocking strategy

DO mock: External API calls / HTTP requests, database queries in unit tests, file system operations, time-dependent behavior (datetime.now, time.time), environment variables.

DON'T mock: Your own models and dataclasses, simple utility functions, the function under test itself, framework features you rely on.

Test count discipline

  • Max 10 tests per file for simple modules.
  • Max 15 tests per file for complex modules.
  • More than that = the module is too complex; suggest splitting it.

2. TDD Workflow

Red-Green-Refactor

  1. RED -- write a failing test. Must fail for the right reason (NOT import error, NOT syntax error).
  2. GREEN -- write the minimal code to make it pass. No more.
  3. REFACTOR -- improve code while all tests stay green. No new behavior.

Coverage targets

Priority What Target
P0 Critical paths (auth, payments, data integrity) 100% line + branch
P1 Core business logic + public API 90%+ line
P2 Utilities, helpers, config 80%+ line

Read the full file on GitHub · 285 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 285 lines · 81 tokens per session scan A a4273d2d4ac6

Subscribe to this mod's changes

python-tdd is a skill published in the GitHub repository acaprino/daodan (8 stars, last pushed yesterday), licensed MIT. It adds 81 tokens to every session and 2,530 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.