{"slug":"python-tdd-with-uv","title":"python-tdd-with-uv","summary":"Test-driven development in Python using uv as the package manager. Covers the red-green-refactor cycle, vertical slicing, and uv project setup.","platform":"Cursor","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-08-12T22:23:33.389232Z","repo":{"url":"https://github.com/spencerpauly/awesome-cursor-skills","stars":813,"forks":149,"license":"CC0-1.0","updatedAt":"2026-08-02T02:41:53Z"},"bodyHtml":"<hr>\n<h2>name: python-tdd-with-uv\ndescription: Test-driven development in Python using uv as the package manager. Covers the red-green-refactor cycle, vertical slicing, and uv project setup.\nuser-invocable: true</h2>\n<h1>Python TDD with uv</h1>\n<p>Write Python code test-first using <code>uv</code> for fast dependency and environment management.</p>\n<h2>Setting Up the Project</h2>\n<ol>\n<li>Check if <code>uv</code> is installed: <code>uv --version</code></li>\n<li>If the project doesn't have a <code>pyproject.toml</code>, initialize:\n<pre><code>uv init\n</code></pre>\n</li>\n<li>Add pytest as a dev dependency:\n<pre><code>uv add --dev pytest pytest-cov\n</code></pre>\n</li>\n<li>Confirm the test runner works:\n<pre><code>uv run pytest --co\n</code></pre>\n</li>\n</ol>\n<h2>TDD Workflow — Vertical Slicing</h2>\n<p>Work in small cycles. Never write more than one failing test at a time.</p>\n<h3>Planning Phase</h3>\n<p>Before writing code, answer:</p>\n<ol>\n<li>What interface changes are needed? (functions, classes, APIs)</li>\n<li>Which behaviors matter most? (prioritize critical paths)</li>\n<li>Can we design for testability? (inject dependencies, avoid global state)</li>\n</ol>\n<h3>The Cycle</h3>\n<pre><code>RED   → Write ONE failing test for the next behavior\nGREEN → Write the MINIMUM code to make it pass\nREFACTOR → Clean up without changing behavior\nREPEAT\n</code></pre>\n<p><strong>Rules:</strong></p>\n<ul>\n<li>Never write implementation before a failing test exists</li>\n<li>Never write more than one failing test at a time</li>\n<li>Run <code>uv run pytest</code> after every change</li>\n<li>Tests must assert observable behavior, not implementation details</li>\n<li>Mocks should only be used at system boundaries (I/O, network, clock)</li>\n</ul>\n<h3>Test File Structure</h3>\n<pre><code># tests/test_&lt;module&gt;.py\n\nclass TestFeatureName:\n    \"\"\"Group related behaviors.\"\"\"\n\n    def test_does_expected_thing_when_given_input(self):\n        result = function_under_test(input_value)\n        assert result == expected\n\n    def test_raises_when_given_invalid_input(self):\n        with pytest.raises(ValueError):\n            function_under_test(bad_input)\n</code></pre>\n<h3>Running Tests</h3>\n<pre><code>uv run pytest                      # all tests\nuv run pytest tests/test_foo.py    # single file\nuv run pytest -k \"test_name\"       # by name pattern\nuv run pytest --cov=src            # with coverage\nuv run pytest -x                   # stop on first failure\n</code></pre>\n<h2>uv Essentials</h2>\n<pre><code>uv add &lt;package&gt;           # add dependency\nuv add --dev &lt;package&gt;     # add dev dependency\nuv remove &lt;package&gt;        # remove dependency\nuv sync                    # sync environment from lockfile\nuv run &lt;command&gt;           # run in managed environment\nuv lock                    # regenerate lockfile\n</code></pre>\n<ul>\n<li>Always use <code>uv run</code> to execute commands — never activate venvs manually</li>\n<li>Commit both <code>pyproject.toml</code> and <code>uv.lock</code></li>\n</ul>\n<h2>References</h2>\n<ul>\n<li><a href=\"https://github.com/mattpocock/skills\">mattpocock/skills — TDD skill</a> — vertical-slice TDD philosophy</li>\n<li><a href=\"https://github.com/nizos/tdd-guard\">nizos/tdd-guard</a> — automated TDD enforcement via hooks</li>\n<li><a href=\"https://github.com/s2005/uv-skill\">s2005/uv-skill</a> — uv workflow patterns</li>\n</ul>\n","files":[{"path":"SKILL.md","sizeBytes":2944,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-08-12T22:24:41.560039Z","sha256":"E9EDAB65B0DD4031B4B08638719B4E0F169011C08D719312C0A211554074C685","sizeBytes":1497},"review":null,"source":{"repositoryUrl":"https://github.com/spencerpauly/awesome-cursor-skills","path":"resources/python-tdd-with-uv","license":"CC0-1.0","commit":"99cd2655788456cc1c685944dcf8c2de82c1ded4","subtreeSha":"866EB715371BFE8C6CB640493910673CA49549EA5CB1635C292943496C8C15B3","lastSyncedAt":"2026-09-25T06:49:08.872487Z"},"reviewedAt":"2026-08-12T22:26:41.615237Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/spencerpauly/awesome-cursor-skills/tree/main/resources/python-tdd-with-uv"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install spencerpauly-awesome-cursor-skills@llmmart"},{"target":"git","command":"git clone https://github.com/spencerpauly/awesome-cursor-skills.git"}]}