# Build Structured Async FastAPI Services

New FastAPI services often mix routing, data access, and business logic. This skill provides layered patterns for async APIs, authentication, persistence, and tests.

## Install

```bash
npx skillstore add sickn33/fastapi-templates
```

## Metadata

- Status: approved
- Slug: sickn33-fastapi-templates
- Skillstore revision: r2
- Version status: missing
- Tree hash: e6810302733f32a9d14935cdab827c21bd640c0c57a5788f8b1fede8ba9342b8
- Author: sickn33
- GitHub username: sickn33
- License: MIT
- Repository: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/fastapi-templates
- Ref: 88a8e9a07f4c54ab105c1c41b6267c287146b07b
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: confirmation\_required
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: network, env\_access, external\_commands
- Quality score: 38
- Quality tier: warning
- Public page: https://skillstore.pages.dev/skills/sickn33-fastapi-templates
- Manifest: https://skillstore.pages.dev/api/skills/sickn33-fastapi-templates/manifest

## Capabilities

- Proposes a layered FastAPI project structure for routes, configuration, models, schemas, services, and repositories.
- Demonstrates async SQLAlchemy session management and generic repository operations.
- Shows dependency-injected endpoints with validation and HTTP error responses.
- Provides password hashing, JWT creation, and authenticated-user dependency patterns.
- Outlines pytest fixtures for isolated async database and API tests.
- Identifies common async, session, typing, coupling, and testing mistakes.

## Use Cases

- Start a Backend Service: Define a maintainable package structure and async request flow for a new FastAPI service.
- Standardize Team Architecture: Separate routes, services, repositories, schemas, and configuration across a shared Python API.
- Teach Async API Patterns: Explain dependency injection, async sessions, authentication, and integration testing through connected examples.

## Prompt Templates

### Plan a Basic Service

```
Design a FastAPI project structure for [service], including routes, schemas, services, repositories, configuration, and tests.
```

### Add Async Persistence

```
Add async SQLAlchemy persistence for [entity], with session dependencies, repository methods, validation schemas, and rollback behavior.
```

### Implement Authentication

```
Design JWT authentication for [application], including password hashing, token validation, ownership checks, configuration, and failure responses.
```

### Review Production Readiness

```
Review this FastAPI architecture for async correctness, authorization, CORS, session handling, error consistency, test coverage, and deployment risks: [details].
```

## Limitations

- The skill provides guidance and snippets, not a complete executable project generator.
- Examples require dependency versions, migrations, schemas, and deployment settings from the target project.
- Security-sensitive examples need review, especially authorization and CORS configuration.
- The included tests cover one creation flow and do not form a comprehensive test suite.

## Best Practices

- Keep route handlers small and place business rules in services.
- Use async-compatible clients and database drivers throughout each request path.
- Test authorization, transaction rollback, validation, and error responses independently.

## Anti Patterns

- Do not copy wildcard CORS settings into a production service.
- Do not treat authentication as authorization for user-selected resources.
- Do not mix synchronous database operations into async route handlers.

## Security Audit

- Audited at: 2026-07-23T22:04:07.865\+00:00
- Summary: All 15 static findings are benign documentation examples or scanner misclassifications. However, the playbook includes a user lookup without object-level authorization and a permissive CORS configuration. These template flaws require correction before production use.

## Stats

- Views: 143
- Downloads: 7
- Favorites: 0
- Popularity score: 0
