Agentic-skills fastapi-development-best-practices
Comprehensive FastAPI development framework with prioritized rules across async patterns, validation, security, testing, and deployment. Use when building FastAPI applications, designing APIs, implementing authentication, or optimizing async services.
git clone https://github.com/GNSubrahmanyam/agentic-skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/GNSubrahmanyam/agentic-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/fastapi" ~/.claude/skills/gnsubrahmanyam-agentic-skills-fastapi-development-best-practices && rm -rf "$T"
skills/fastapi/SKILL.mdFastAPI Development Best Practices
Comprehensive modern API development framework with 100+ individual rules across 40 rule categories covering the complete FastAPI ecosystem. Fully aligned with official FastAPI documentation from basic parameters to advanced security, covering async programming, validation, security, API design, web standards, application architecture, debugging, and production deployment. Designed for production-ready FastAPI applications with proper async/await handling, type safety, and scalable architecture.
When to Apply
Reference these guidelines when:
- Building new FastAPI applications or APIs
- Implementing async endpoints and background tasks
- Designing data models with Pydantic
- Implementing authentication and authorization
- Writing tests for async applications
- Deploying FastAPI applications to production
- Optimizing async performance and concurrency
Rule Categories by Priority
| Priority | Category | Impact | Files | Individual Rules | Prefix | | --- | --- | --- | --- | --- | --- | --- | | 1 | Async & Concurrency | CRITICAL | 4 | 12 |
async- |
| 2 | Security & Authentication | CRITICAL | 3 | 8 | security- |
| 3 | Validation & Models | HIGH | 1 | 5 | validation- |
| 4 | Core Parameters | HIGH | 4 | 12 | core- |
| 5 | API Design | HIGH | 6 | 15 | api- |
| 6 | Data Handling | MEDIUM-HIGH | 2 | 8 | data- |
| 7 | Application Structure | MEDIUM-HIGH | 1 | 5 | app- |
| 8 | Database & ORM | MEDIUM-HIGH | 1 | 4 | db- |
| 9 | Testing | MEDIUM-HIGH | 1 | 4 | testing- |
| 10 | Performance | MEDIUM | 2 | 4 | perf- |
| 11 | Deployment | MEDIUM | 1 | 3 | deploy- |
| 12 | Documentation | MEDIUM | 1 | 2 | docs- |
| 13 | Web & HTTP | MEDIUM | 4 | 10 | web- |
| 14 | Development & Debug | MEDIUM | 1 | 6 | dev- |
| 15 | Response Handling | MEDIUM | 3 | 8 | response- |
| 16 | Documentation & Examples | MEDIUM | 2 | 6 | docs- |
| 17 | Advanced Patterns | LOW | 4 | 9 | advanced- |
| Total | 17 Categories | | 40 Files | 100+ Rules | |
Quick Reference
1. Async & Concurrency (CRITICAL)
: Always use async def for endpoint functionsasync-endpoints
: Use async dependency injection properlyasync-dependencies
: Handle async database operations correctlyasync-database
: Implement background tasks with proper async handlingasync-background
2. Security & Authentication (CRITICAL)
: Implement JWT tokens securelysecurity-jwt
: Configure CORS properly for productionsecurity-cors
: Implement rate limiting for APIssecurity-rate-limiting
3. Validation & Models (HIGH)
: Use Pydantic models for all data validationvalidation-pydantic
4. Core Parameters (HIGH)
: Handle dynamic URL routing with type safetypath-parameters
: Flexible API filtering with validationquery-parameters
: Structured data submission with Pydanticrequest-body
: Consistent API responses with documentationresponse-models
5. API Design (HIGH)
: Follow RESTful API design principlesapi-restful
: Add pagination for large datasetsapi-pagination
: Return proper validation error responsesapi-error-handling
: Handle file uploads securelyapi-file-handling
: Implement API versioning strategiesapi-versioning
: Handle large data and real-time responsesstreaming-responses
6. Database & ORM (MEDIUM-HIGH)
: Handle async database operations correctlyasync-database
7. Testing (MEDIUM-HIGH)
: Set up proper async testingtesting-async
8. Performance (MEDIUM)
- Response caching and concurrency limits
9. Deployment (MEDIUM)
: Production server setupdeploy-production
10. Documentation (MEDIUM)
- OpenAPI documentation setup
11. Web & HTTP (MEDIUM)
: Client state management and authenticationcookie-parameters
: Metadata passing and API versioningheader-parameters
: Serving static assets and file resourcesstatic-files
: Application initialization and cleanuplifespan-events
12. Data Handling (MEDIUM-HIGH)
: HTML form processing and validationform-data-handling
: Advanced data types and JSON encodingextra-data-types
13. Application Structure (MEDIUM-HIGH)
: Multi-file application organizationbigger-applications
14. Development & Debug (MEDIUM)
: Development debugging and troubleshootingdebugging-fastapi
15. Response Handling (MEDIUM)
: HTML, CSV, XML, streaming responsescustom-response-classes
: Secure cookie management, sessions, preferencesresponse-cookies
: Security headers, caching, CORS, metadataresponse-headers
16. Documentation & Examples (MEDIUM)
: Comprehensive request model examplesrequest-examples
: Custom documentation URLs and API metadatametadata-docs
17. Advanced Patterns (LOW)
: Real-time bidirectional communicationwebsocket-support
: Partial updates and PATCH operationsbody-updates
: Comprehensive monitoring setupmonitoring-observability
: Advanced endpoint configurationpath-operation-config
Quick Start
- 📖 Overview:
skills/fastapi-skill/SKILL.md - 📚 Complete Reference:
skills/fastapi-skill/AGENTS.md - 🔍 Specific Rules:
skills/fastapi-skill/rules/[category]-[rule-name].md