Skip to main content
subagent CX Codex

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

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/agents/fastapi-expert.md
Open on GitHub

What 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 pytest and fastapi.testclient for successful and failing requests.

How to install fastapi-expert

Manually: put the files in place

.claude/agents/fastapi-expert.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

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

Similar subagents

All subagents for Backend and APIs →

From the same set137

The whole set →
javascript-expert javascript-expert refactors modern JavaScript using ES6+ standards, async patterns, and strict equality. Helps optimize DOM queries and find race conditions. CX Codex ★ 1,029repo stars keycloak-expert keycloak-expert — a Keycloak subagent for realms, clients, roles, user federation, and OIDC or SAML security work. Use it when an IAM task needs a structured setup. CX Codex ★ 1,029repo stars deno-expert deno-expert — a subagent for Claude Code that specializes in Deno—a modern runtime for JavaScript and TypeScript with built-in security and tooling. Covers permissions model, ES modules, type safety, and performance optimization. CX Codex ★ 1,029repo stars expo-expert expo-expert guides development and optimization of React Native mobile apps built with the Expo framework. CX Codex ★ 1,029repo stars ios-expert ios-expert is a Claude Code subagent for building iOS apps with Swift and SwiftUI. It handles app architecture and Swift optimization tasks. CX Codex ★ 1,029repo stars perl-expert perl-expert is a Claude Code subagent for Perl scripting, regular expressions, data parsing, and CPAN modules. CX Codex ★ 1,029repo stars nestjs-expert nestjs-expert is a Claude Code subagent for structuring NestJS applications and REST APIs. It handles architecture, validation, route protection, and tests. CX Codex ★ 1,029repo stars php-expert php-expert — a subagent for PHP work: PHP 8+ syntax, sessions, Composer and PDO, checked against a PSR and security checklist. CX Codex ★ 1,029repo stars

Project sponsors

Companies that keep this analytics open