Back to Gallery
Fastapi Agent Rule
View Full Resolution
100% Free Access
AI Architecture Cursor AI / Claude 3.5
Category AI Agents
Best Use Case Commercial & Cinematic
AI Agents Verified Blueprint

Fastapi Agent Rule

FastAPI best practices and patterns for building modern Python web APIs

Ready-to-Run Prompt
100% Free Copy
# FastAPI Best Practices

## Project Structure
- Use proper directory structure
- Implement proper module organization
- Use proper dependency injection
- Keep routes organized by domain
- Implement proper middleware
- Use proper configuration management

## API Design
- Use proper HTTP methods
- Implement proper status codes
- Use proper request/response models
- Implement proper validation
- Use proper error handling
- Document APIs with OpenAPI

## Models
- Use Pydantic models
- Implement proper validation
- Use proper type hints
- Keep models organized
- Use proper inheritance
- Implement proper serialization

## Database
- Use proper ORM (SQLAlchemy)
- Implement proper migrations
- Use proper connection pooling
- Implement proper transactions
- Use proper query optimization
- Handle database errors properly

## Authentication
- Implement proper JWT authentication
- Use proper password hashing
- Implement proper role-based access
- Use proper session management
- Implement proper OAuth2
- Handle authentication errors properly

## Security
- Implement proper CORS
- Use proper rate limiting
- Implement proper input validation
- Use proper security headers
- Handle security errors properly
- Implement proper logging

## Performance
- Use proper caching
- Implement proper async operations
- Use proper background tasks
- Implement proper connection pooling
- Use proper query optimization
- Monitor performance metrics

## Testing
- Write proper unit tests
- Implement proper integration tests
- Use proper test fixtures
- Implement proper mocking
- Test error scenarios
- Use proper test coverage

## Deployment
- Use proper Docker configuration
- Implement proper CI/CD
- Use proper environment variables
- Implement proper logging
- Use proper monitoring
- Handle deployment errors properly

## Documentation
- Use proper docstrings
- Implement proper API documentation
- Use proper type hints
- Keep documentation updated
- Document error scenarios
- Use proper versioning

Structured JSON Schema

Use with automated API pipelines, LangChain, or custom image generators

{
    "system_prompt": "# FastAPI Best Practices\n\n## Project Structure\n- Use proper directory structure\n- Implement proper module organization\n- Use proper dependency injection\n- Keep routes organized by domain\n- Implement proper middleware\n- Use proper configuration management\n\n## API Design\n- Use proper HTTP methods\n- Implement proper status codes\n- Use proper request/response models\n- Implement proper validation\n- Use proper error handling\n- Document APIs with OpenAPI\n\n## Models\n- Use Pydantic models\n- Implement proper validation\n- Use proper type hints\n- Keep models organized\n- Use proper inheritance\n- Implement proper serialization\n\n## Database\n- Use proper ORM (SQLAlchemy)\n- Implement proper migrations\n- Use proper connection pooling\n- Implement proper transactions\n- Use proper query optimization\n- Handle database errors properly\n\n## Authentication\n- Implement proper JWT authentication\n- Use proper password hashing\n- Implement proper role-based access\n- Use proper session management\n- Implement proper OAuth2\n- Handle authentication errors properly\n\n## Security\n- Implement proper CORS\n- Use proper rate limiting\n- Implement proper input validation\n- Use proper security headers\n- Handle security errors properly\n- Implement proper logging\n\n## Performance\n- Use proper caching\n- Implement proper async operations\n- Use proper background tasks\n- Implement proper connection pooling\n- Use proper query optimization\n- Monitor performance metrics\n\n## Testing\n- Write proper unit tests\n- Implement proper integration tests\n- Use proper test fixtures\n- Implement proper mocking\n- Test error scenarios\n- Use proper test coverage\n\n## Deployment\n- Use proper Docker configuration\n- Implement proper CI/CD\n- Use proper environment variables\n- Implement proper logging\n- Use proper monitoring\n- Handle deployment errors properly\n\n## Documentation\n- Use proper docstrings\n- Implement proper API documentation\n- Use proper type hints\n- Keep documentation updated\n- Document error scenarios\n- Use proper versioning",
    "prompt_type": "agent_rule",
    "framework": "cursor",
    "globs": "**/*.py, app/**/*.py, api/**/*.py",
    "compatible_models": [
        "Claude 3.5 Sonnet",
        "GPT-4o",
        "Cursor AI",
        "Gemini 2.5 Flash"
    ],
    "download_filename": "fastapi.cursorrules",
    "tags": [
        "cursor",
        "cursorrules",
        "agent",
        "coding",
        "fastapi"
    ]
}
Internal Discovery

More AI Agents Prompts

View All →