Skip to main content
skill CX Codex

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.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add c0x12c/ai-toolkit --skill python-best-practices -a claude-code
Open on GitHub

What 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/v1 for blocking operations inside async def
  • Convert the models in app/models/user.py to 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-code

2Manually: put the files in place

~/.claude/skills/python-best-practices/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/python-best-practices/

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.

From the same set33

startup-pipeline Moves a startup idea through four stages: brainstorm, validation, market research and pitch materials. Gates between stages stop weak ideas early. CX Codex +1 ★ 109repo stars service-debugging A structured backend troubleshooting runbook that guides the agent from symptom gathering and log analysis to root-cause isolation. CX Codex +1 ★ 109repo stars security-checklist Audits Micronaut/Kotlin backends for access control, input checks, injection risks, and data exposure. Use it during implementation or review. CX Codex +1 ★ 109repo stars python-testing-strategies A skill that tells your coding agent how to test FastAPI apps: pytest-asyncio, httpx AsyncClient, data factories and the checks every endpoint needs. CX Codex +1 ★ 109repo stars python-api-endpoint-creator Builds FastAPI endpoints and CRUD modules with separate router, service, and repository layers. Use it when adding a domain module and its tests. CX Codex +1 ★ 109repo stars ops-oncall-log Pulls alerts from your monitoring platform and writes a structured on-call log to the team wiki. Useful at the end of a shift or during a review. CX Codex +1 ★ 109repo stars ops-investigate-alert Investigates production alerts end-to-end by collecting telemetry, error logs, and recent code diffs. Gives on-call engineers an evidence-based incident root cause. CX Codex +1 ★ 109repo stars market-research Research markets, competitors, funds, or technology with a structured workflow. Use the skill to gather evidence before testing a business idea or contacting an investor. CX Codex +1 ★ 109repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor