johnku2011/boilerplates-with-ai-skills/python-api-design

Claude Code and agent skill by johnku2011/boilerplates-with-ai-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when adding or changing FastAPI routes, dependencies, or tests in this Python service — keep endpoints typed, validated, and covered by pytest.

Install

npx vskill@latest install johnku2011/boilerplates-with-ai-skills/python-api-design

SKILL.md

The same SKILL.md was published earlier as johnku2011/boilerplates-with-ai-skills/python-api-design.

Python API Design (FastAPI)

Overview

Keep the FastAPI app small and testable. Build with create_app() so pytest can use TestClient without starting a real server on a fixed port.

Process

  1. Register routes on the app from create_app() in app/main.py.
  2. Use Pydantic models for request/response bodies when shapes matter.
  3. Return correct status codes; use HTTPException for client errors.
  4. Add a pytest case for each new route or behavior change.
  5. Run pytest before claiming completion.

Project Layout

  • app/main.py — create_app() factory and route definitions
  • tests/ — pytest tests using fastapi.testclient.TestClient
  • requirements.txt — pinned runtime + test dependencies

Testing

python
from fastapi.testclient import TestClient
from app.main import create_app
def test_health():
client = TestClient(create_app())
assert client.get("/api/health").json() == {"status": "ok"}

Guidelines

  • Type hints on route functions and shared helpers.
  • Secrets from environment variables (os.environ), never hardcoded.
  • Keep route handlers thin; extract logic to pure functions when non-trivial.
  • Prefer dependency injection for DB sessions and auth when the app grows.

Anti-patterns

  • Business logic embedded directly in route decorators without tests.
  • Returning raw exception strings to clients in production.
  • Skipping tests because "FastAPI validates for us" — test behavior, not just schemas.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
240
Repository forks
24
7-day trend score
27

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/johnku2011/boilerplates-with-ai-skills/python-api-design/badge)](https://verified-skill.com/skills/johnku2011/boilerplates-with-ai-skills/python-api-design)

Something wrong with this skill or its page? Tell us.