python-tdd-with-uv
Test-driven development in Python using uv as the package manager. Covers the red-green-refactor cycle, vertical slicing, and uv project setup.
How do I install this agent skill?
npx skills add https://github.com/spencerpauly/awesome-cursor-skills --skill python-tdd-with-uvIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill provides a standard workflow for Python Test-Driven Development (TDD) using the uv package manager. It includes instructions for project setup, dependency management using pytest, and test execution cycles. No security issues were detected.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
- ZeroLeakswarn
1 finding · Score: 78/100
What does this agent skill do?
Python TDD with uv
Write Python code test-first using uv for fast dependency and environment management.
Setting Up the Project
- Check if
uvis installed:uv --version - If the project doesn't have a
pyproject.toml, initialize:uv init - Add pytest as a dev dependency:
uv add --dev pytest pytest-cov - Confirm the test runner works:
uv run pytest --co
TDD Workflow — Vertical Slicing
Work in small cycles. Never write more than one failing test at a time.
Planning Phase
Before writing code, answer:
- What interface changes are needed? (functions, classes, APIs)
- Which behaviors matter most? (prioritize critical paths)
- Can we design for testability? (inject dependencies, avoid global state)
The Cycle
RED → Write ONE failing test for the next behavior
GREEN → Write the MINIMUM code to make it pass
REFACTOR → Clean up without changing behavior
REPEAT
Rules:
- Never write implementation before a failing test exists
- Never write more than one failing test at a time
- Run
uv run pytestafter every change - Tests must assert observable behavior, not implementation details
- Mocks should only be used at system boundaries (I/O, network, clock)
Test File Structure
# tests/test_<module>.py
class TestFeatureName:
"""Group related behaviors."""
def test_does_expected_thing_when_given_input(self):
result = function_under_test(input_value)
assert result == expected
def test_raises_when_given_invalid_input(self):
with pytest.raises(ValueError):
function_under_test(bad_input)
Running Tests
uv run pytest # all tests
uv run pytest tests/test_foo.py # single file
uv run pytest -k "test_name" # by name pattern
uv run pytest --cov=src # with coverage
uv run pytest -x # stop on first failure
uv Essentials
uv add <package> # add dependency
uv add --dev <package> # add dev dependency
uv remove <package> # remove dependency
uv sync # sync environment from lockfile
uv run <command> # run in managed environment
uv lock # regenerate lockfile
- Always use
uv runto execute commands — never activate venvs manually - Commit both
pyproject.tomlanduv.lock
References
- mattpocock/skills — TDD skill — vertical-slice TDD philosophy
- nizos/tdd-guard — automated TDD enforcement via hooks
- s2005/uv-skill — uv workflow patterns
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/spencerpauly/awesome-cursor-skills/python-tdd-with-uv">View python-tdd-with-uv on skillZs</a>