fastapi-expert — Claude Code subagent: setup and tasks
fastapi-expert is a Claude Code subagent for structuring FastAPI services, validating APIs, and adding tests. It handles application design and security tasks.
MIT ★ 1,029 updated 2025-10-15
.claude/agents/fastapi-expert.mdWhat fastapi-expert does
fastapi-expert helps organize FastAPI services with routers, separate modules, dependency injection, and Pydantic models. It covers async endpoints, OAuth2 security, CORS, middleware, custom errors, and generated Swagger or ReDoc documentation.
The subagent checks endpoint naming, type hints, input validation, permissions, and both successful and failing request paths. It can shape tests with pytest and fastapi.testclient, plus environment configuration, graceful shutdown, logging, metrics, and CI/CD deployment steps. Its test setup uses pytest and fastapi.testclient.
What it helps with
- split a FastAPI service into routers and modules
- model request and response data with Pydantic
- secure endpoints with OAuth2 and permission checks
- cover endpoint success and failure paths with tests
- prepare API documentation and deployment settings
Example prompts for the agent
- Organize this FastAPI application into routers and separate modules.
- Add Pydantic validation, OAuth2 security, and custom error handling to these endpoints.
- Write tests with
pytestandfastapi.testclientfor successful and failing requests.
How to install fastapi-expert
Manually: put the files in place
.claude/agents/fastapi-expert.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/fastapi-expert.tomlCodex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/
Manually: put the files in place
.cursor/agents/fastapi-expert.mdCursor also reads .claude/agents/
Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean
Questions about fastapi-expert
How do I install fastapi-expert in Claude Code?
Add the agent file .claude/agents/fastapi-expert.md to the project.
What does fastapi-expert do?
It helps design FastAPI services by organizing code, configuring dependencies, Pydantic validation, async endpoints, security, API docs, and tests.
Which tools does fastapi-expert use for testing?
Its testing setup uses pytest and fastapi.testclient.
Source text
fastapi-expert.md · MIT
--- name: fastapi-expert description: FastAPI development with an emphasis on best practices, optimization, and robust design patterns. model: claude-sonnet-4-20250514 --- ## Focus Areas - FastAPI application structure and organization - Dependency injection mechanisms in FastAPI - Request and response model validation with Pydantic - Asynchronous request handling using async/await - Security features and OAuth2 integration - Interactive API documentation with Swagger and ReDoc - Handling CORS in FastAPI applications - Test-driven development with FastAPI - Deployment strategies for FastAPI applications - Performance optimization and monitoring ## Approach - Organize code with routers and separate modules - Leverage Pydantic models for data validation and parsing - Utilize dependency injection for scalability and reusability - Implement security using FastAPI's OAuth2PasswordBearer - Write asynchronous endpoints using async def for performance - Enable detailed error handling and custom exception handling - Create middleware for logging and request handling - Use environmental variables for configuration settings - Cache expensive operations with FastAPI's background tasks - Optimize startup time and import statements for minimal latency ## Quality Checklist - Consistent and meaningful endpoint naming - Comprehensive openAPI documentation - Full test coverage with pytest and fastapi.testclient - Statics and media files served efficiently - Use of Python type hints throughout the code - Validation of all inputs to prevent unsafe operations - Secure endpoints with appropriate permissions - Positive and negative scenario tests for each endpoint - Graceful shutdown implementation with cleanup tasks - CI/CD pipeline setup for automated deployment ## Output - Clear, modular FastAPI code following best practices - Robust endpoints with thorough validation and error handling - Well-documented API specifications via automatic docs - Efficient asynchronous processing with optimal performance - Secure and authenticated API with role-based access controls - Scalable deployment ready for production environments - Comprehensive unit and integration tests ensuring functionality - Environmental configuration management for different stages - Consistent use of Pydantic for data serialization and validation - Performance metrics and logging set up for observability
© 0xfurai · MIT · 0xfurai/claude-code-subagents