scaffold-fastapi-service
Skill7 starsChanged 16 days agoMITView on GitHub
Use when starting a Python HTTP API or adding a service to a repo with no FastAPI app yet — scaffolds a uv src-layout FastAPI service with lifespan, pydantic-settings, ruff, mypy, pytest, health/readiness, problem+json errors and an async SQLAlchemy session dependency.
- Reads credentials
1 other project uses a version of this.
Adopted by
Most recently taken up by
- VelimirMueller/ai-development-skillsword for word, first seen Oct 25, 2026
Other versions1 project uses a version of this.
Word for word · 1
- VelimirMueller/ai-development-skills★ 7100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository156 other files it gives its agents.
- skills/swift/swiftui-design-principles/AGENTS.mdAGENTS.md
- skills/swift/ios-code-audit/CLAUDE.mdCLAUDE.md
- skills/swift/swift-focusengine-pro/llms.txtllms.txt
- build-llm-seamSkill
- build-mcp-serverSkill
- build-rag-pipelineSkill
- secure-llm-featuresSkill
- set-up-llm-evalsSkill
- build-nextjs-backendSkill
- build-supabase-edge-functionSkill
- configure-backend-testsSkill
- design-http-apiSkill
- harden-backendSkill
- scaffold-go-serviceSkill
- scaffold-hono-serviceSkill
- secure-supabase-rlsSkill
- set-up-backend-authSkill
- set-up-background-jobsSkill
- set-up-databaseSkill
- set-up-nextjs-supabase-authSkill
- set-up-observabilitySkill
- set-up-supabaseSkill
- build-cliSkill
- release-cliSkill
- set-up-dev-toolchainSkill
- audit-securitySkill
- audit-toolchainSkill
- extend-skillsetSkill
- promote-releaseSkill
- set-up-stack-profileSkill
- write-commit-messagesSkill
- write-pull-requestsSkill
- analyze-complexitySkill
- apply-algorithmsSkill
- apply-design-patternsSkill
- apply-design-principlesSkill
- apply-solidSkill
- choose-data-structureSkill
- debug-systematicallySkill
- enforce-dependency-ruleSkill
- refactor-safelySkill
- slice-and-estimateSkill
- write-clean-testsSkill
- write-readable-codeSkill
- clean-frontend-scaffoldingSkill
- configure-accessibilitySkill
- configure-analyticsSkill
- configure-ciSkill
- configure-error-trackingSkill
- configure-lintingSkill
- configure-test-stackSkill
- configure-typescriptSkill
- create-moduleSkill
- optimize-performanceSkill
- scaffold-frontend-projectSkill
- set-up-authSkill
- set-up-design-systemSkill
- set-up-document-headSkill
- set-up-error-boundariesSkill
- set-up-feature-flagsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Read the profile first; detect only what it leaves open (stack-profile.md).
- Distinctive: line 28
All present and step 7 passes: report "already in place" and stop.
- Very specific: line 54
Create the files from fastapi-files.md, skipping any that exist.
- Very specific: line 69
Add an empty __init__.py to platform/, repository/, service/, transport/.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Scaffold FastAPI Service
Rationale and rules: fastapi-patterns.md. Full file contents: fastapi-files.md. Shared standards: service-layout.md, config.md, stack-versions.md.
1. Audit (change nothing)
cat .claude/stack-profile.md ~/.claude/stack-profile.md 2>/dev/null # backend.track, database.orm, tests.layout, task_runner, observability
ls pyproject.toml uv.lock .python-version ruff.toml src tests alembic.ini 2>/dev/null
grep -E 'fastapi|flask|django|litestar|sqlalchemy|pydantic' pyproject.toml requirements*.txt 2>/dev/null
uv --version; python3 --versionRead the profile first; detect only what it leaves open (stack-profile.md).
backend.trackis set and is notfastapi: stop and name the track the profile says; suggest the matching scaffold skill.backend.trackis unset andflask,djangoorlitestaris in the dependencies: ask one question ("add FastAPI next to it, or extend it?"). Otherwise do not ask.requirements.txtwithoutpyproject.toml: the repo does not use uv. Say so and ask once before introducing it;package_manager: uvin the profile answers the question.
2. Decide
- No
pyproject.toml: full scaffold (steps 3 to 7). pyproject.tomlpresent, no FastAPI app: add the dependencies and the package folders; keep the existing[project]table, merge the tool tables by hand.- All present and step 7 passes: report "already in place" and stop.
3. Detect track
| Question | Source | Default |
| Package name | folder name, snake_case | svc in the files becomes this name |
| Python line | requires-python, .python-version | 3.14 (stack-versions.md) |
| Database | database.orm | sqlalchemy: keep platform/db.py, make DATABASE_URL required, add Alembic via the Alembic skill of this catalogue. none: delete platform/db.py and the sessionmaker lines in app.py |
| Type checker | repo config, else profile lint_format | mypy strict. ty is beta: add it as a second CI step only if asked |
| Tests | tests.layout | tests/ always for Python; colocated is unusual here: ask before changing testpaths |
| Observability | observability.otel | true: add OTel bootstrap in platform/ before configure_logging (observability.md) |
| Task runner | task_runner | just: recipes dev, test, lint, typecheck calling the commands in step 7 |
4. Install only what is missing
uv init --package --python 3.14 --name <pkg> . # only when pyproject.toml is missing
uv add "fastapi[standard]" pydantic-settings structlog "sqlalchemy[asyncio]" "psycopg[binary,pool]"
uv add --dev ruff mypy pytest pytest-asyncio httpx--package gives the src/ layout and the uv_build backend. Delete the generated README.md reference from pyproject.toml if you do not keep one: the build fails on a missing readme. Check each line against stack-versions.md. Commit uv.lock.
5. Generate the seams
Create the files from fastapi-files.md, skipping any that exist; merge the tool tables into pyproject.toml.
src/<pkg>/config.py pydantic-settings, fails fast on import of main
src/<pkg>/platform/{logging,db,problem}.py
src/<pkg>/repository/*.py the only layer with SQL
src/<pkg>/service/*.py use cases, no FastAPI types
src/<pkg>/transport/{health,notes,errors,schemas}.py
src/<pkg>/app.py create_app(settings), lifespan
src/<pkg>/main.py `app = create_app(get_settings())`
tests/test_app.py httpx ASGITransport, in-process
pyproject.toml tool tables fastapi, pytest, ruff, mypy
.env.example .gitignore .env ignoredAdd an empty __init__.py to platform/, repository/, service/, transport/. Rename notes to the first real module.
6. Wire
[tool.fastapi] entrypoint = "svc.main:app"letsfastapi devandfastapi runfind the app.- Development:
uv run fastapi dev(reload on, binds localhost). Production:uv run uvicorn <pkg>.main:app --host 0.0.0.0 --port "${PORT:-8000}" --timeout-graceful-shutdown 10 --no-access-log, orfastapi run --port "${PORT:-8000}". Uvicorn stops accepting on SIGTERM, drains, then runs the lifespan shutdown.--workersonly on a bare VM; in containers scale replicas. - Readiness: append one coroutine to
app.state.readiness_checksper dependency in the lifespan (partial(ping, engine)). - Sessions: repositories take an
AsyncSessionfromDepends(get_session); the service never sees it. Needs a database: setDATABASE_URLin.env. .python-versionandrequires-pythonstay in step withmise.tomlwhen the profile uses mise.- CI, Docker and deploy are out of scope; the
devcoreandinfraskillsplugins own them (CI:uv sync --locked).
7. Verify
uv sync --locked # expect: no changes
uv run ruff format --check . && uv run ruff check . # expect: "All checks passed!"
uv run mypy # expect: "Success: no issues found"
uv run pytest -q # expect: 6 passed
uv run fastapi run --port 8087 & # expect a JSON "starting" line, then uvicorn "Application startup complete"
curl -si localhost:8087/notes/nope # expect 404 and content-type: application/problem+json
curl -s localhost:8087/readyz # expect {"status":"ok"}
curl -s localhost:8087/openapi.json | head -c 60 # expect {"openapi":"3.1.0",...
LOG_LEVEL=LOUD uv run python -c "import svc.main" # expect a ValidationError naming log_level
kill -TERM %1 # expect "stopping" in the log, exit code 0A second run of this skill finds everything in place and changes nothing.
References
- fastapi-patterns.md: why each choice, when to deviate.
- fastapi-files.md: the files.
- service-layout.md, config.md.
- logging-contract.md, security-baseline.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

