python-testing-strategies — Claude Code skill for FastAPI tests
A skill that tells your coding agent how to test FastAPI apps: pytest-asyncio, httpx AsyncClient, data factories and the checks every endpoint needs.
npx skills add c0x12c/ai-toolkit --skill python-testing-strategies -a claude-codeWhat python-testing-strategies does
This skill hands the agent a working set of conventions for testing a FastAPI project. It covers the async client built on httpx.AsyncClient with ASGITransport, fixture layout, small factory functions for test data, and test names that say what broke — test_get_item_not_found, test_create_item_missing_name.
Each endpoint gets a checklist: the happy path through create, read, update and delete, a 404 case, a 422 validation error, a 401 when the route is protected, and soft delete where removed rows must not come back. A gotchas section lists the failures that waste the most time. Skip asyncio_mode = "auto" in pyproject.toml and async tests either collect nothing or hang. Reach for Starlette's synchronous TestClient instead of AsyncClient and async bugs stay hidden, because the sync client never touches the event loop. Database state also bleeds across tests unless an autouse=True fixture resets it, and then CI failures depend on run order.
The skill can read, write and edit files, search the project, and run shell commands. Install it with npx skills add for Claude, Codex, Cursor, Gemini CLI or OpenCode; GitHub Copilot uses gh skill install instead.
What it helps with
- write tests for async FastAPI routes
- set up
conftest.pyand a client fixture - cover each endpoint with 404, 422 and 401 cases
- replace copy-pasted dicts with test data factories
- fix async tests that never get collected
Example prompts for the agent
- Write tests for the
itemsendpoints following the skill's patterns - Set up
conftest.pywith anAsyncClientandASGITransport - Add an
autouse=Truefixture that resets the database between tests
How to install python-testing-strategies
1Skills CLI (Vercel)
npx skills add c0x12c/ai-toolkit --skill python-testing-strategies -a claude-code2Manually: put the files in place
~/.claude/skills/python-testing-strategies/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/python-testing-strategies/
1Skills CLI (Vercel)
npx skills add c0x12c/ai-toolkit --skill python-testing-strategies -a codex2Manually: put the files in place
.agents/skills/python-testing-strategies/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add c0x12c/ai-toolkit --skill python-testing-strategies -a cursor2Manually: put the files in place
.cursor/skills/python-testing-strategies/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install c0x12c/ai-toolkit python-testing-strategies2Manually: put the files in place
.github/skills/python-testing-strategies/SKILL.md1Skills CLI (Vercel)
npx skills add c0x12c/ai-toolkit --skill python-testing-strategies -a gemini-cli2Platform CLI
gemini skills install https://github.com/c0x12c/ai-toolkit --path toolkit/skills/python-testing-strategiesManually: put the files in place
.devin/skills/python-testing-strategies/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add c0x12c/ai-toolkit --skill python-testing-strategies -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about python-testing-strategies
How do I install python-testing-strategies in Claude Code?
Run npx skills add c0x12c/ai-toolkit --skill python-testing-strategies -a claude-code. The skill lands at ~/.claude/skills/python-testing-strategies/SKILL.md.
What does python-testing-strategies do?
It gives the agent FastAPI testing patterns: an async client, fixtures, data factories, and the per-endpoint checks to write.
Why are my async tests not running?
Most likely asyncio_mode = "auto" is missing from pyproject.toml. Without it async tests collect nothing or hang, so the skill says to set it before writing the first one.