Entry point and working agreement for building professional FastAPI backends - the router that decides which other fastapi-* skill to use. Use this skill FIRST whenever the user starts, plans, extends, restructures or reviews a Python/FastAPI backend project (APIs, workers, MongoDB, Redis, MinIO, Docker, Nginx), asks "how should I build / add / organize X", or wants amateur backend code raised to senior, production-grade quality - even if they never say "skill" or "workflow".
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Fastapi Pro Workflow?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/amralhorimy-fastapi-pro-workflow)
---
name: fastapi-pro-workflow
description: Entry point and working agreement for building professional FastAPI backends - the router that decides which other fastapi-* skill to use. Use this skill FIRST whenever the user starts, plans, extends, restructures or reviews a Python/FastAPI backend project (APIs, workers, MongoDB, Redis, MinIO, Docker, Nginx), asks "how should I build / add / organize X", or wants amateur backend code raised to senior, production-grade quality - even if they never say "skill" or "workflow".
---
# FastAPI Pro Workflow
The operating system for every backend task: how we work, which skill to use, what "done" means.
Distilled from a real production-grade codebase (modular monolith, hexagonal, 13 modules, workers, event
stream, audit chain, monitoring) and two smaller showcase projects.
## 1. Choose the architecture profile (once per project)
| | **Profile A - Hexagonal modular monolith** (default for real products) | **Profile B - Lite service/repo** (small or showcase projects) |
|---|---|---|
| Shape | `src/<pkg>/{modules,platform,shared,entrypoints}`; each module `domain / application / adapters` | `app/modules/<m>/{routes,service,repo,schemas,errors}` + `app/platform/<tech>/` + `workers/` |
| Rule enforcement | import-linter contracts + AST architecture test in `make check` | convention + review |
| Use when | several modules, a team, long life, ML/async pipelines, security needs | one clear idea, <= ~5 modules, teaching/portfolio |
| Skills section | `fastapi-foundation/references/layout.md` | `fastapi-foundation/references/lite-profile.md` |
Default to **A** unless the user says the project is small/showcase. Lite projects can graduate to A
module by module (see `fastapi-code-upgrade`).
## 2. Working agreement (always)
1. **Agree scope before code.** Restate the goal in 3-6 lines, list what is explicitly out of scope, name the
phase. Large request -> split first (`fastapi-phase-planning`). Never build more than agreed.
2. **Pick the delivery mode** (ask once, remember):
- **Guided** - the user writes the code. Give the step (goal, files, code, why, alternatives, verify
command), let them write it, then compare their version to the reference honestly: what is
equivalent, what is below reference level and what it would cost.
- **Delivery** - you write complete files / an overlay (only new+changed files) / a zip, with run steps.
3. **Inside-out build order**: domain -> application -> test with fakes -> persistence adapter + integration
test -> HTTP/worker adapter -> wiring -> docs. Contracts and ports first.
4. **Decisions are written down.** Every non-obvious choice with a rejected alternative becomes a short ADR:
context, decision, rejected alternatives, consequences, *when to revisit*.
5. **Honest evaluation.** Say when something is below reference level, when an idea has a real cost, when a
decision should be reversed. Never flatter, never hide risk.
6. **Evidence before "done".** Run `make check` (lint, types, architecture, tests) plus the stage's scenario and
report real output. Every phase doc ends with **what was verified and what was not** - never claim more.
7. **Small, runnable steps.** Each step leaves the project working; risky changes get flags and rollback.
## 3. Routing table
| The user wants... | Use skill |
|----------------------------------------------------------------|---------------------------------|
| A brand-new backend project / skeleton / infra | `fastapi-foundation` |
| Split a big goal into phases and steps, order, acceptance | `fastapi-phase-planning` |
| Define ports, commands, DTOs, events, statuses first | `fastapi-contracts-types` |
| Add one separate feature / module end to end | `fastapi-add-module` |
| A large feature needing system design (AI, feed, pipelines) | `fastapi-major-feature` |
| Error handling, logs, correlation ids | `fastapi-errors-logging` |
| Auth, RBAC, rate limits, uploads, secrets, audit, detection | `fastapi-security` |
| Health, metrics, log pipeline, alerts | `fastapi-observability` |
| Queues, workers, event streams, pub/sub, SSE, streaming | `fastapi-async-workers` |
| Tests, architecture tests, labs, load/failure tests, gates | `fastapi-testing-verification` |
| Audit and upgrade existing amateur code | `fastapi-code-upgrade` |
| ARCHITECTURE.md, ADRs, module docs, README (bilingual), CI | `fastapi-docs-release` |
Typical chains:
- **New project**: planning -> foundation -> errors-logging -> security -> first module -> observability -> docs.
- **New feature**: contracts-types -> add-module (+ async-workers if background work) -> testing-verification.
- **Big feature**: major-feature (design + sub-phases + ADR) -> add-module per sub-phase.
- **Existing project**: code-upgrade (audit + migration map) -> planning -> add-module style steps.
## 4. Architecture rules in one paragraph (Profile A)
Imports point inward only: `adapters -> application -> domain`. Domain holds entities, rules, domain errors and
**ports** (`Protocol`s); application holds one use case per file (commands write, queries read); adapters hold
HTTP routes, persistence, jobs, WebSocket. Domain and application import only stdlib + `shared` + their own module.
`platform` holds infrastructure (settings, Mongo/Redis/MinIO/auth clients, jobs, errors, metrics) and never knows
modules. Modules never import each other: they react to **events**, or depend on a **port they own** whose
implementation is bridged in `entrypoints/`. `entrypoints/` is the only place that knows everything (composition
root: API app, workers, CLIs). Absolute imports only. All of it is enforced by tests, not by good intentions.
## 5. Definition of done (every task)
- [ ] Scope + out-of-scope respected; ADR written if a real decision was made
- [ ] Domain rules live in entities/domain; use case is one file; ports are `Protocol`s
- [ ] Unit tests with in-memory fakes (happy path + every error + permission denial + idempotency)
- [ ] Persistence adapter has `<tech>_guard`, indexes declared (`essential=True` when correctness depends on it), integration test on real Mongo/Redis
- [ ] Route is thin (DTO `to_command`, handler call, `from_entity`), auth + rate limit declared
- [ ] Error codes unique and listed in `docs/errors.md`
- [ ] `make check` green; scenario/lab run; real output reported
- [ ] Module doc updated incl. known limits and verified/not-verified
- [ ] Next step named
## 6. Response format when guiding
**Goal** -> **Files** -> **Code** -> **Why this way** -> **Alternatives/trade-offs** -> **Verify** (exact command).
Steps small enough for one sitting; after the user's version, review by severity: correctness > security >
layering > naming > style.