Guide · Agent skill
How to use the FastAPI Patterns agent skill (fastapi-patterns)
Updated · written with AI from the project's own documentation and checked against our catalogue data
The fastapi-patterns skill is a set of FastAPI conventions that an AI agent follows when you ask it to build, refactor or review a Python web API. This guide explains what the skill changes in the agent's behaviour, how to install it from the ZIP, how to trigger it with ordinary requests, and what it needs before you rely on its output. You do not need prior experience with agent skills to follow it.
Quick start
- 1Download the ZIP. Download the fastapi-patterns skill ZIP from this page.
- 2Unzip into a skills folder. Unzip it into ~/.claude/skills/ for personal use, or into a project's .claude/skills/ folder for one project.
- 3Or upload it in the Claude apps. In the Claude apps, open Settings, then Capabilities, then Skills, and upload the skill there.
- 4Ask a FastAPI question. Describe your FastAPI task in plain language, naming FastAPI and the job, such as building a route or reviewing a PR.
- 5Check the output. Read the suggested code against your library versions and your security requirements before merging it.
What does the fastapi-patterns skill make the agent do?
Once installed, the skill gives the agent a specific way of structuring FastAPI code. It suggests separating routes, Pydantic request and response schemas, dependency injection, and database logic into different files, and it provides copy-ready examples for async endpoints, authentication dependencies, error handling and OpenAPI docs.
The skill also tells the agent to flag common production risks. The source's examples include leaking password hashes in responses and combining wildcard CORS origins with credentials.
- Thin route layer over explicit dependencies and service code
- Separate Pydantic models for create, update and response data
- Tests that override dependencies instead of opening production resources
- Guidance on security basics such as password hashing and JWT validation
How do you install the fastapi-patterns skill?
Download the skill ZIP from this page and unzip it. The skill is a single file, SKILL.md. Place the unzipped skill folder in one of two locations: your user skills folder at ~/.claude/skills/ so it is available in every project, or a project's .claude/skills/ folder so it applies only to that project.
You can also upload the skill in the Claude apps. Go to Settings, then Capabilities, then Skills, and add the skill there.
- Personal install: ~/.claude/skills/
- Project install: .claude/skills/ inside your project folder
- Claude apps: Settings → Capabilities → Skills
How do you trigger the skill with natural requests?
You do not need a special command. Describe the FastAPI task in plain language and mention FastAPI, so the agent knows which conventions apply. The skill's own description covers async APIs, dependency injection, Pydantic models, OpenAPI docs, tests, security and production readiness, so requests about those topics are the ones it is meant to handle.
Requests that work well name the job and the context, for example that you are building a new service, reviewing a pull request, or adding authentication to an existing app.
- Build a new FastAPI service with users, auth and a health check.
- Review this FastAPI pull request for security and structure problems.
- Split this main.py into routers, schemas and dependencies.
- Add pagination to my list endpoint and make sure the response model hides internal fields.
- Write pytest tests for this route that override the database dependency.
What does the recommended project layout look like?
The skill proposes a layout where main.py handles app construction, middleware, exception handlers and router registration. Schemas, dependencies, services and tests each have their own place. The layout below is the one given in the source; you can adapt it to your project.
- main.py: app construction, middleware, exception handlers, routers
- schemas/: Pydantic request and response models
- dependencies.py: database, auth and pagination dependencies
- services/ or crud/: business and persistence operations
- tests/: dependency overrides
app/
|-- main.py
|-- config.py
|-- dependencies.py
|-- exceptions.py
|-- api/
| `-- routes/
| |-- users.py
| `-- health.py
|-- core/
| |-- security.py
| `-- middleware.py
|-- db/
| |-- session.py
| `-- crud.py
|-- models/
|-- schemas/
`-- tests/What are the main safety rules the skill enforces?
The skill's guidance keeps raw ORM objects, secrets and framework globals out of response schemas. Response models must never include password hashes, access tokens, refresh tokens or internal authorization state. For CORS, do not use allow_origins=["*"] together with allow_credentials=True, because browsers reject that combination.
For authentication, the checklist asks you to hash passwords with argon2-cffi, bcrypt, or a current passlib-compatible hasher, and to validate JWT issuer, audience, expiry and signing algorithm. Check each suggestion against current library documentation before you ship it.
- Never return password hashes or tokens in response models
- Never combine wildcard CORS origins with credentials
- Validate JWT issuer, audience, expiry and signing algorithm
- Avoid creating sessions or clients inline inside route handlers
What does the skill need and what does it not do?
The skill needs Python and FastAPI. The examples also assume Pydantic, SQLAlchemy async and httpx. The skill does not run scripts and does not use the network. It provides patterns and snippets, not a finished, deployable project, so you still need to write configuration, models, and the rest of the application.
Treat the output as a starting point for review. Verify the code against the versions of the libraries you actually use.
- Requires: Python, FastAPI; examples assume Pydantic, SQLAlchemy async, httpx
- Runs scripts: no
- Uses network: no
- Licence: MIT
What people use it for
- Refactoring a single large main.py into routers, schemas and dependencies
- Reviewing a FastAPI pull request for leaked fields, CORS mistakes and missing response models
- Setting up consistent project layout across several Python services
- Writing pytest tests that override the get_db dependency
Frequently asked questions
How do I install the fastapi-patterns skill?
Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use, or into a project's .claude/skills/ folder. You can also upload it in the Claude apps under Settings, then Capabilities, then Skills.
What do I need to use the fastapi-patterns skill?
You need Python and FastAPI. The examples also assume Pydantic, SQLAlchemy async and httpx. The skill does not run scripts and does not use the network.
Is the fastapi-patterns skill free?
The skill is published under the MIT licence, as stated on this page. Check the licence file in the source repository for the full terms.
Can I use this skill with frameworks other than FastAPI?
No. The guidance is FastAPI-specific, so it is not useful for other Python frameworks or for non-Python projects.
Will the skill give me a complete app I can deploy?
No. It gives patterns and copy-ready snippets, not a finished project. Beginners should expect to write configuration, models and deployment setup themselves.
What should I check before trusting the skill's code?
Verify the examples against the current versions of FastAPI, Pydantic, SQLAlchemy and httpx. For security-critical code, do not rely on the skill alone for sign-off; have it reviewed by a person.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Use this skill if you build or review FastAPI backends in Python and want consistent structure, response models and a checklist of common production risks. Pick something else if you use a different framework or language, or if you need a complete, ready-to-deploy application or a security sign-off on its own.
Download the skill