python-best-practices · c0x12c — Claude Code skill: what it does, install
Defines architectural and coding standards for FastAPI and Pydantic v2. Keeps async endpoints free from blocking calls and aligns layer boundaries.
npx skills add c0x12c/ai-toolkit --skill python-best-practices -a claude-codeWhat python-best-practices does
The skill enforces a strict downward flow where routers call services, and services query repositories. Each layer talks only to the one directly beneath it. Outbound network requests go through httpx.AsyncClient. Application startup and teardown move to the lifespan context manager instead of the legacy on_event handler.
Using the outdated orm_mode silently breaks serialization without explicit errors, so the guide mandates from_attributes=True for Pydantic v2. Complex nested defaults require Field(default_factory=list). Database definitions swap out legacy Column declarations for Mapped annotations with mapped_column() to retain editor autocomplete.
Async execution gets strict boundaries. Calling blocking code inside async def stalls the entire event loop. Because of that, CPU-heavy tasks must use plain def functions so FastAPI can run them inside a threadpool.
What it helps with
- Enforce strict Router-Service-Repository layer boundaries
- Migrate legacy schemas to Pydantic v2 with from_attributes=True
- Prevent event loop freezes from blocking calls in async routes
- Standardize model definitions using SQLAlchemy 2.0 mapped_column
- Add soft delete filtering through a reusable SoftDeleteMixin
Example prompts for the agent
- Check the routes in
app/api/v1for blocking operations inside async def - Convert the models in
app/models/user.pyto SQLAlchemy 2.0 Mapped syntax - Implement generic pagination for the customer list endpoint using PaginatedResponse
How to install python-best-practices
1Skills CLI (Vercel)
npx skills add c0x12c/ai-toolkit --skill python-best-practices -a claude-code2Manually: put the files in place
~/.claude/skills/python-best-practices/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/python-best-practices/
1Skills CLI (Vercel)
npx skills add c0x12c/ai-toolkit --skill python-best-practices -a codex2Manually: put the files in place
.agents/skills/python-best-practices/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add c0x12c/ai-toolkit --skill python-best-practices -a cursor2Manually: put the files in place
.cursor/skills/python-best-practices/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install c0x12c/ai-toolkit python-best-practices2Manually: put the files in place
.github/skills/python-best-practices/SKILL.md1Skills CLI (Vercel)
npx skills add c0x12c/ai-toolkit --skill python-best-practices -a gemini-cli2Platform CLI
gemini skills install https://github.com/c0x12c/ai-toolkit --path toolkit/skills/python-best-practicesManually: put the files in place
.devin/skills/python-best-practices/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add c0x12c/ai-toolkit --skill python-best-practices -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-best-practices
How do you install python-best-practices in Claude Code?
Run npx skills add c0x12c/ai-toolkit --skill python-best-practices -a claude-code in your terminal.
What does python-best-practices do?
It instructs your AI assistant to follow layered architecture and modern conventions for FastAPI and Pydantic v2. It also enforces correct async patterns.
Why does the skill recommend plain def for some FastAPI routes?
Synchronous or blocking operations inside an async def function block the server event loop. FastAPI runs plain def functions inside an external threadpool, keeping the server responsive.
Similar skills
All skills for Backend and APIs →python-best-practices by other authors comes first.