Generators: create the baseline first
Generator documentation reviewed: 2026-10-23. Evidence: documentation-reviewed; commands not executed.
Required workflow
- Before writing a new project's application files, read its profile's starting points and use the official framework or language initializer appropriate to the component. Do not hand-recreate a generated skeleton. Where no full application generator exists, use the documented module/package initializer and assemble only the missing application pieces.
- Choose one starting point per component. Check the installed generator's version and help, prerequisites, template, database, UI, test and runtime options. Commands are examples: replace names and paths, resolve compatible versions, and record the exact invocation and selected options. Do not blindly run every listed generator.
- Generate in a new empty destination. For an existing repository, preserve its conventions and use relevant incremental generators. If a baseline comparison is needed, generate a separate disposable reference with matching versions/options and reconcile deliberately; never regenerate over existing work.
- Keep applicable generated configuration, hidden files, formatter/linter settings, ignore rules, manifests, lockfiles, tests, wrappers and entry points. Extend them for the project instead of replacing them with abbreviated handwritten copies. A generator may initialize version control or offer a commit; respect the user's Git instructions.
- Run the generated baseline's documented checks before feature changes, then relevant checks after configuration and implementation. Inspect what version control would include, including hidden files, build output, local secrets and operating-system metadata. Add needed ignore rules explicitly: no generator guarantees that .DS_Store or every local artifact is ignored.
- Use follow-up generators only when their feature or tool is selected. Review generated changes and dependencies, apply required migrations in the intended environment, and exercise the generated behavior. Scaffolding does not establish authorization, safe retries, production readiness or every best practice.
- If the required generator, template or IDE is unavailable, report the missing prerequisite and the documented route. Do not silently substitute a handwritten scaffold. Keep documentation review, generator execution, baseline checks and application qualification as separate evidence.
Choose a starting point
Official fastapi-new project scaffold
Use when: A new FastAPI API where the official basic uv-configured scaffold is a suitable starting point; use the minimal assembly path below when you need a smaller/custom layout, or the full-stack template only when its additional choices fit.
- Install uv using its official platform instructions, inspect uvx --help and the fastapi-new project README/release notes, and choose a new absent target directory. The package requires Python 3.10 or newer.
- Run the official scaffold in the source parent, then inspect generated files, dependencies, README, ignore rules and lockfile before adapting it. Record the resolved fastapi-new, uv and Python versions.
- Follow the generated README to start the app and check its initial endpoint; adapt the generated application deliberately to the requested API rather than assuming the scaffold covers production requirements.
Working directory: A local source-workspace parent; target must not already exist
Inspect the selected installed release's options before generating.
uvx fastapi-new --help
Working directory: A local source-workspace parent; api-service must not already exist
Generate the official basic FastAPI project configured with uv.
uvx fastapi-new api-service
Working directory: The generated api-service directory
Run the generated development application after reviewing its README and files.
uv run fastapi dev
- This is an official FastAPI organization project, but PyPI classifies it as Development Status 4 - Beta, has one maintainer, and its 0.0.7 release was uploaded 19 June 2026. Treat it as an optional scaffold and review the generated output; the documentation was reviewed but the command was not executed here.
- The official repository README documents `uvx fastapi-new <project-name>` and bare `uvx fastapi-new` for an existing directory. Do not use the latter on a populated project without first inspecting what it will add or change.
- This scaffold is distinct from FastAPI CLI's `fastapi dev`/`fastapi run` commands, which serve an existing application, and from the larger Full Stack FastAPI Template.
uv project initialization with explicit minimal FastAPI assembly
Use when: A new API/service requiring FastAPI without an entire full-stack template.
- Install uv and inspect uv --version and uv init --help. Replace /path/to/local/source with an existing local source parent; use a new, absent target directory. Set PYTHON_VERSION to a supported Python minor compatible with the selected framework and dependencies. Record generator versions, selected flags and deliberate deviations.
- Run uv initialization and dependency installation, then implement the minimal FastAPI application in app/main.py with app/__init__.py. This is deliberate assembly for the custom minimal uv path; use the official fastapi-new scaffold above when its generated baseline fits.
- Use the official first-steps example as the initial app, add the required endpoint and test, then start the development server. Configure [tool.fastapi] entrypoint when the project uses a different import path.
Working directory: /path/to/local/source
Generate managed project metadata for the conventional flat app/ layout.
uv init --no-package --python "$PYTHON_VERSION" api-service
Working directory: /path/to/local/source/api-service
Resolve FastAPI and its CLI/server dependencies.
uv add "fastapi[standard]"
Working directory: /path/to/local/source/api-service
After the app file exists, run the development server; this command does not scaffold an application.
uv run fastapi dev app/main.py
- FastAPI documents a small application assembled from Python modules. The official fastapi dev and fastapi run commands serve existing apps; `fastapi-new` is the separate optional official project scaffold documented above.
- Inspect the generated uv sample main.py; adapt/remove it explicitly if app/main.py replaces it. Document any chosen package layout instead of letting two entry points drift.
- Choose a source parent outside another uv workspace, or intentionally use --no-workspace when creating an independent project under a directory with parent pyproject.toml metadata.
Official Full Stack FastAPI Template
Use when: The requested product explicitly needs the template’s React frontend, SQLModel/PostgreSQL, accounts and deployment structure.
- Review the official repository README and its current development documentation. Record the selected revision and verify its actual dependency/layout choices.
- Use GitHub Use this template to create the requested repository, then clone it into a local source workspace and follow its own initialization instructions.
- Configure project identity and environment-owned secrets; replace example credentials and inspect generated workflows before enabling external effects.
- This is an official optional template, not the default for every API. Its extra frontend, ORM and infrastructure choices must match the application.
- The reviewed official README uses GitHub template creation; no unsupported Copier command is prescribed. Do not run another uv init over the template or replace its maintained lock/environment workflow.
Conditional follow-up generators
Conditional Alembic migration environment and revisions
Use when: SQLAlchemy-backed persistent state is required; skip for stateless APIs/workers and preserve an existing migration owner.
Working directory: /path/to/local/source/api-service
Install the selected PostgreSQL data dependencies; use a compatible driver for another chosen database.
uv add sqlalchemy alembic "psycopg[binary]"
Working directory: /path/to/local/source/api-service
Generate the standard migration environment and config.
uv run alembic init migrations
Working directory: /path/to/local/source/api-service
After configuring env.py metadata and database access, generate a candidate schema revision.
uv run alembic revision --autogenerate -m "initial schema"
Working directory: /path/to/local/source/api-service
After manual review, apply the candidate migration to a disposable development database.
uv run alembic upgrade head
- Between init and revision, configure the database URL from environment-owned secrets and target_metadata from the application models. The default generic template is synchronous; use alembic list_templates and choose the async template only for an actual async DBAPI.
- Autogeneration cannot reliably infer every rename, constraint or data transformation. Review upgrade/downgrade operations and write data migrations intentionally; do not blindly apply its output.
- Commit migrations, env.py and the non-secret configuration, while keeping database credentials out of source. Verify upgrades and required rollback behavior before release.
Preserve the generated foundation
- Keep generator-created project metadata, Python requirements, version selection and ignore rules; extend them rather than replacing them with a handwritten approximation.
- Commit the resolved uv.lock for projects; exclude .venv, caches, secrets and platform debris such as .DS_Store. Do not hand-edit lockfiles.
- Keep source repositories, virtual environments and caches in a local development workspace outside cloud-synced document folders.
- Preserve the selected application layout, explicit FastAPI entrypoint and any chosen template tests/configuration; record template revision and changes.
- Do not add an ORM, database, frontend or queue solely to imitate a full-stack template.
Baseline and generation checks
- From /path/to/local/source/api-service: uv sync --locked. Import the implemented app and exercise its API tests after installing/configuring the selected test tooling.
- With uv run fastapi dev app/main.py running locally, verify a real endpoint and /openapi.json. Choose and document production startup separately; development reload is not a deployment check.
- When Alembic is configured, run uv run alembic check and uv run alembic current against the disposable development database; verify migration behavior.
- Compare project metadata with a disposable scaffold from the same uv version and flags, or the selected official template revision. Review tracked/staged files and ensure local environments, secrets and .DS_Store are excluded.
Generation receipt
- Component and selected starting point, or the documented absence of a full application generator
- Generator/toolchain versions, exact commands or IDE template/settings, working directory and generated destination
- Generated files retained, deliberate deviations with reasons, and required supplemental ignore rules
- Baseline checks and later checks actually run, results and remaining prerequisites or untested behavior
Generator sources