- Home
- Skills
- Greyhaven Ai
- Claude Code Config
- Tdd Python
tdd-python_skill
- Python
19
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill greyhaven-ai/claude-code-config --skill tdd-python- SKILL.md1.4 KB
Overview
This skill provides practical Python Test-Driven Development (TDD) expertise focused on pytest, strict red-green-refactor cycles, FastAPI endpoint testing, and Pydantic model validation. It guides test-first design choices and supplies templates and patterns to maintain high test coverage and clear, maintainable code. Use it to drive feature design from tests and to standardize testing practices across Python projects.
How this skill works
The skill inspects user intent and code context to generate test-first artifacts: failing pytest tests, minimal implementation code, and refactor suggestions to reach green status. It produces pytest-friendly test cases for unit logic, FastAPI endpoints, and Pydantic models, plus fixtures and mocks where appropriate. It also recommends next refactor steps and asserts coverage and edge-case handling during the cycle.
When to use it
- When implementing new Python features and you want a strict TDD workflow
- When writing or improving pytest tests for libraries or applications
- When developing or testing FastAPI endpoints and integrations
- When validating Pydantic models, schemas, and data parsing behavior
- When you want clear red-green-refactor guidance to drive design decisions
Best practices
- Write a single failing test that expresses the smallest new behavior before coding
- Use pytest fixtures and parametrization to reduce duplication and cover edge cases
- Keep implementation minimal to pass tests, then refactor for readability and reusability
- Test FastAPI endpoints with TestClient and include status, body schema, and authentication cases
- Validate Pydantic models with positive and negative input examples and explicit error assertions
Example use cases
- Generate a pytest test that defines desired behavior for a new utility function, then produce the minimal implementation to pass it
- Create end-to-end FastAPI tests for an endpoint including request validation, response schema, and error cases
- Write Pydantic model tests that assert parsing, default values, and validation errors for invalid input
- Convert existing feature requests into an ordered TDD task list: failing test, implementation, refactor, and coverage checks
- Provide concise pytest templates and fixtures to bootstrap a test suite for a new Python package
FAQ
I produce failing tests first, then minimal implementation code to pass them, followed by refactor suggestions—consistent with strict red-green-refactor TDD.
Can you generate FastAPI test scaffolding with authentication?
Yes. I generate TestClient-based tests, include auth setup fixtures, and test protected routes for success and failure cases.