---
name: fastapi-skill-63d8ff7b4a8b
description: "> Loaded by: Backend Division agents | Version: 1.0"
---

# FastAPI Skill

> Loaded by: Backend Division agents | Version: 1.0

## Project Structure

```
src/
  api/v1/routes/, schemas/, dependencies/
  core/config.py, security.py
  models/
  services/
  utils/
```

## Best Practices

### Routes

```python
from fastapi import APIRouter, Depends, HTTPException, status

router = APIRouter(prefix="/users", tags=["users"])

@router.post("/", response_model=UserResponse, status_code=status.HTTP_201_CREATED)
async def create_user(user: UserCreate, db: Session = Depends(get_db)):
    return await UserService(db).create(user)
```

### Error Handling

```python
raise HTTPException(
    status_code=status.HTTP_404_NOT_FOUND,
    detail={"error": "user_not_found", "message": "User with this ID does not exist"}
)
```

### Validation

- Pydantic models for all request/response schemas
- Validate at schema level, not in routes
- Custom validators for business rules

## Anti-Patterns

- Do NOT put business logic in routes
- Do NOT use raw SQL without parameterization
- Do NOT return database models directly (use schemas)
- Do NOT catch broad exceptions silently
- Do NOT hardcode configuration values

## Checklist

- [ ] Routes use proper HTTP methods and status codes
- [ ] Request/response schemas defined
- [ ] Error responses are structured
- [ ] Database sessions properly managed
- [ ] Authentication applied where needed


---
Source attribution: Ab-aswini
Original project: https://github.com/Ab-aswini/Agent-kit-P1/blob/16ae07362b19abdfca76a3c20a7e34bb40dbadff/.agent-os/skills/fastapi/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Dave AI.

## Upstream license notice

MIT License

Copyright (c) 2025 Ab-aswini

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Dave AI resource metadata

Creator / publisher: Ab-aswini
Original project: https://github.com/Ab-aswini/Agent-kit-P1/blob/16ae07362b19abdfca76a3c20a7e34bb40dbadff/.agent-os/skills/fastapi/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering
Roles: Backend Developer, DevOps / SRE, Full-Stack Developer
Specialties: Backend
Tools: Fastapi
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: bfb38d70641fe328e13fd176ab7f4459bc174835164181f058f244938d0d959d
