Skip to main content

pytemplate-uv

PyPI Python CI License: MIT

Generate production-ready Python projects in seconds. A deterministic application factory with profiles, composable components, and template packs.

A modern application factory that generates uv-native Python projects. With the bundled templates, every project passes linting, formatting, type-checking, and tests from the first commit. Choose a profile (a typed package with a CLI, or a FastAPI service), add components (database, authentication, background jobs), and get a ready-to-deploy project.

  • ✅ Deterministic: identical requests produce byte-identical projects
  • ✅ Checked: every bundled component combination passes strict quality gates in CI
  • ✅ uv-native: generated projects need only uv and uvx (no pip, virtualenv activation, or make)
  • ✅ Extensible: use template packs to customize without forking
  • ✅ Type-safe: strict mypy on generated code; requests are validated before anything is written

Looking for more templates? pytemplate-hub is the official place to find template packs for pytemplate-uv: each listing is checked and gives a ready command pinned to the exact files that were checked. New to both? Start with the tutorial.

What you get

Profiles (choose one)

  • python — a typed package with a Typer CLI; great for tools
  • library — a typed package with no CLI or console script; great for code others import
  • fastapi — a layered REST API service with structured logging, health checks, security, and organized architecture

Components (mix and match)

Component Purpose When to use
database SQLAlchemy 2.x ORM + Alembic migrations When you need persistent data
worker A task-queue port with an in-process adapter and job endpoints For background work
auth-api-key API key authentication with scopes For service-to-service auth
auth-oidc OpenID Connect (JWT) authentication For user login via identity provider
container Dockerfile and .dockerignore For containerized deployment
devcontainer A .devcontainer/devcontainer.json for VS Code and Codespaces with uv installed For a one-click development environment
release A trusted-publishing PyPI release workflow triggered by a v* tag (python and library profiles) To publish a package
mcp An MCP server over stdio, with a typed tool, a test, and .mcp.json (python and library profiles) To give AI agents tools they can call

Mix components freely — the generator validates combinations and adds required dependencies.

Quality from day one

Every project generated from the bundled templates passes:

  • ✅ ruff check and ruff format --check (code quality and style)
  • ✅ Strict mypy (type safety)
  • ✅ pytest (tests included)

This is verified across all 28 bundled component combinations on every commit. Projects from your own template packs are not covered by these checks; test your pack the same way.

Built for teams

  • Inspectable: plan shows files and dependencies without writing anything
  • Reproducible: .pytemplate.toml records exact versions and checksums for each file
  • Scriptable: --json output and stable exit codes for CI/CD integration
  • Extensible: bring your own profiles and components via template packs

Why pytemplate-uv?

The problem it solves:

  • Boilerplate is brittle—missing auth, wrong config, outdated patterns, integration test gaps
  • Every team reimplements auth, logging, database connections, container config
  • Generated code is usually messy, missing checks, and needs cleanup

The solution:

  • Start from reviewed patterns: layered architecture, health checks, structured logs, auth behind a principal and scopes
  • Every bundled component combination is generated and checked in CI (28 combinations, on Linux and Windows)
  • Script it: the same request always produces the same project

Good fit for:

  • Teams starting FastAPI services or typed CLI tools
  • Platforms that generate many similar apps from one reviewed template
  • CI pipelines and AI agents that need a scriptable, validated scaffolding step

Install

No installation needed to try it:

uvx pytemplate-uv --help

To install the pytemplate command:

uv tool install pytemplate-uv

Requires Python 3.11–3.15. Runs on Linux, macOS, and Windows. Also available via pip install pytemplate-uv.

Create a project

30-second quickstart

uvx pytemplate-uv create my-api -p fastapi -c database -c auth-oidc -y
cd my-api
uv sync
uv run pytest

(If you installed the pytemplate command, write pytemplate create ....) When it finishes, create prints the next steps: the cd and the profile's own lifecycle commands.

That's it: a layered FastAPI service with a database, OIDC authentication, tests, a GitHub Actions workflow, structured logging, and health checks.

More examples

# Python CLI tool
pytemplate create my-tool -p python -y

# FastAPI service with background jobs
pytemplate create my-service -p fastapi -c worker -c database -y

# Containerized API with API key auth
pytemplate create my-api -p fastapi -c auth-api-key -c container -y

# Preview before writing anything
pytemplate plan --name my-api -p fastapi -c database -c auth-oidc

# Validate a request (catches mistakes early)
pytemplate validate --name my-api -p fastapi -c auth
# Error: Component 'auth' needs one of: auth-api-key, auth-oidc; add --component auth-api-key.

create-project is an optional shortcut with the same arguments and options as pytemplate create (uvx pytemplate-uv create NAME needs no shortcut):

uvx --from pytemplate-uv create-project pricing-api -p fastapi -y

Commands

Command What it does
create NAME Generate a project
plan Preview files and dependencies (no write)
validate Check for errors before rendering
create-from-config FILE Render from a TOML request file
status [PATH] List files changed, deleted, or added since generation (read-only)
list-profiles / describe-profile ID Show profiles and their inputs
list-components / describe-component ID Show components: requirements, conflicts, dependencies, files, settings
schema NAME Print a JSON Schema (profile, component, pack, request, manifest)
skill install / skill show Install or print the AI project-creation skill

Tips:

  • Every command except schema (which already prints JSON) and skill accepts --json
  • Use --template to render from your own template pack
  • plan and validate write nothing

Exit codes:

  • 0: success.
  • 1: an invalid request; nothing was written. With --json, the error is printed as {"ok": false, "error": {...}}.
  • 2: a valid request that failed while rendering or writing.

create options

  • --profile, -p: profile identifier (default python).
  • --component, -c: add a component; repeat as needed. Profile defaults are always included, and required components are added automatically.
  • --output-dir, -o: existing parent directory (default .).
  • --data, -d KEY=VALUE: answer a template question; repeat as needed.
    • Inputs are package_name, description, author, email, python_version (3.11–3.15), and license (an SPDX expression).
  • --template, -t SOURCE and --template-ref REF: render from a template pack (see below).
  • --yes, -y: accept the template defaults instead of prompting. Without it, create prompts, and the picker below asks for optional components; when standard input is not a terminal it exits 1 before rendering and asks for -y. --json implies -y. --no-input still works but is deprecated: it prints a warning on stderr and goes away in 4.0.
  • --git: after rendering, run git init and commit everything as "Initial commit from pytemplate-uv". --lock: run uv lock first, so the commit includes uv.lock. Neither is ever the default, and neither runs with --dry-run. If a step fails, the project stays and the exit code is 2 with a message saying what was created and what failed.
  • --dry-run: validate and show the target without writing.
  • --force, -f: replace an existing directory. The project is rendered into a staging directory and swapped in only after rendering succeeds, so no stale files remain.
  • --json: print the result as JSON.

Component picker, completion, and status

  • In a terminal, without -y, --json, or -c, create offers the profile's optional components as a multi-select list. Required components are still added, and conflicts still refused.
  • --profile and --component complete in your shell (for the bundled catalog) once you run pytemplate --install-completion.
  • pytemplate status [PATH] compares a generated project with the SHA-256 inventory in .pytemplate.toml and lists the files you changed, deleted, or added. It ignores .git/, .venv/, caches, uv.lock, and the manifest, never writes, accepts --json, and exits 1 when PATH has no valid manifest.
  • Errors and warnings go to stderr; only --json output and results go to stdout. A misspelled profile, component, schema, or --data key gets a "Did you mean" suggestion.

Reproducible render requests

# pricing-api.toml
project_name = "pricing-api"
profile = "fastapi"
components = ["database", "auth-api-key"]
output_dir = "./projects"   # relative to this file

[data]
description = "Pricing service"
author = "Quant Team"
pytemplate validate pricing-api.toml
pytemplate plan pricing-api.toml --json
pytemplate create-from-config pricing-api.toml

Each project records how it was generated, and neither file stores secrets or environment values:

  • .pytemplate.toml records the generator, template source, and profile and component versions (with why each component is present), the answers, and a SHA-256 hash and owner for every generated file;
  • .copier-answers.yml records the Copier answers and the template source.

pytemplate schema manifest describes the format.

Find templates on the hub

The bundled profiles cover common cases. For more, browse pytemplate-hub, the official index of template packs. The hub stores references, not files: each pack stays in its author's own GitHub repository, and each listed version records the tag, commit, and digest that passed the hub's checks.

  1. Find a pack on the hub and read its repository (a pack's generated project runs code when you use it).
  2. Note the listing's tag, commit, and digest, and pass all three to every command, so you see and render exactly the files the hub checked. A pack that does not match them is refused before anything is read.
  3. See its profiles, then create a project:
uvx pytemplate-uv@latest list-profiles \
  --template gh:yuxuzi/pytemplate-starters --template-ref v1.0.0 \
  --template-commit 2886e570d1b964811e63b6aa93f3e0ede2e8e7d2 \
  --template-digest 9257161472cfe280e79c7452ff0e01618b278ea57b7d74280b882976969de924

uvx pytemplate-uv@latest create my-app -p cli \
  --template gh:yuxuzi/pytemplate-starters --template-ref v1.0.0 \
  --template-commit 2886e570d1b964811e63b6aa93f3e0ede2e8e7d2 \
  --template-digest 9257161472cfe280e79c7452ff0e01618b278ea57b7d74280b882976969de924 -y

Made a pack others could use? List it on the hub: you keep the repository, and the hub checks each tag you submit.

Template packs

A template pack is a directory or git repository with your own profiles and components. It has the same layout as the bundled templates:

my-pack/
  pytemplate-pack.toml       # contract = 1, id, name, description, version
  copier.yml                 # _subdirectory: "{{ profile }}/template"; --- !include questions.yml
  questions.yml              # profile, project_name, package_name, components, ...
  <profile>/profile.toml     # the profile manifest (pytemplate schema profile)
  <profile>/template/...     # the project tree; only *.jinja files are rendered
  components/<id>.toml       # component manifests (pytemplate schema component)
pytemplate list-profiles --template ./my-pack
pytemplate create my-tool -p tool --template gh:org/my-pack --template-ref v1.2.0 -y
  • Packs are selected explicitly for each request; nothing is discovered or installed.
  • They follow the same rules as the bundled templates:
    • they render with Copier's unsafe=False;
    • _tasks, _migrations, _jinja_extensions, _external_data, and symlinks are rejected, including in files a pack's copier.yml includes.
  • Pack-generated projects record the pack's source and tag.
  • Projects from a git pack also record the commit and digest they were rendered from. To refuse a pack that changed, pin them:
    pytemplate create my-tool -p tool --template gh:org/my-pack --template-ref v1.2.0 \
      --template-commit <commit> --template-digest <digest> -y
    
    --template-ref also accepts a full commit hash. The discovery commands (list-profiles, describe-profile, list-components, describe-component) accept the same pins. A pack pinned to both a commit and a digest is cached under your user cache directory and checked against the digest on every use; a cached copy is not fetched again, so it always renders the pinned files, and a moved tag is only noticed on the next fetch. Pass --no-cache (or set PYTEMPLATE_NO_CACHE=1) to fetch it again; PYTEMPLATE_CACHE_DIR moves the cache. Git never prompts for credentials, and a clone stops after 120 seconds (PYTEMPLATE_GIT_TIMEOUT).
  • See docs/compatibility.md for the versioning rules.

Built for AI coding agents

Every generated project carries an AGENTS.md: its commands, layout, conventions, and safety rules, for any agent that reads the AGENTS.md format. CLAUDE.md is a one-line import of it, so Claude Code reads the same text.

To build something an agent can call, add mcp to a python project:

pytemplate create pricing-tools --profile python --component mcp -y
cd pricing-tools && uv sync && uv run pytest

You get a Model Context Protocol server on the official SDK, a pricing-tools-mcp command, a test that calls the tool through the server, and a .mcp.json that registers it for agents working in the repository. Rendering it calls no model and needs no API key.

Create projects with Claude or other AI tools

pytemplate-uv ships an agent skill (SKILL.md) that teaches an agent to:

  • discover profiles and components;
  • write a render request and check it with plan;
  • wait for your confirmation;
  • create the project and run its checks.
uvx pytemplate-uv skill install            # ~/.claude/skills/pytemplate/SKILL.md (all projects)
uvx pytemplate-uv skill install --project  # ./.claude/skills/pytemplate/SKILL.md (this repo)
uvx pytemplate-uv skill install --agent agents  # ~/.agents/skills, for Codex and other clients

Then ask, for example, "Create a FastAPI service called pricing-api with a database and OIDC login". For other AI tools, give them the instructions from uvx pytemplate-uv skill show.

Use from Python or other tools

From Python:

from pathlib import Path
from pytemplate import api

# Plan without writing
request = api.RenderRequest("fastapi", "my-api", Path("."), components=("database",), no_input=True)
plan = api.plan(request)
print(plan.resolution.dependencies)  # what will be added
print(plan.files)  # every generated file

# Or render the project
api.render(request)

From scripts, CI/CD, or other languages:

# Output JSON for integration
pytemplate plan --name my-api -p fastapi -c database --json | jq .

# Validate requests before rendering
pytemplate validate request.toml --json

# Get schemas for validation
pytemplate schema request

Generated FastAPI layout

pricing-api/
  AGENTS.md  CLAUDE.md  README.md  pyproject.toml  .env.example  .copier-answers.yml  .pytemplate.toml
  pricing_api/
    api/             routers/, schemas, dependencies, errors, middleware, health
    application/     use cases
    domain/          entities, rules, errors, ports
    infrastructure/  memory adapter (database/ with -c database)
    bootstrap/       settings, logging, container, create_app()
    security/        with -c auth-api-key or -c auth-oidc
  migrations/  alembic.ini       with -c database
  SECURITY.md                    with authentication
  Dockerfile  .dockerignore      with -c container
  tests/unit/  tests/integration/

Contribute

Getting started:

uv sync
uv run pytest                    # run unit tests
PYTEMPLATE_SMOKE=1 uv run pytest # verify all 28 component combinations work
uv run ruff check .
uv run mypy

Adding a component:

  1. Create pytemplate/components/my-component.toml with the manifest
  2. Add its files to the compatible profile's template/ tree and list them in the manifest's paths
  3. Add its id to the components choices in pytemplate/templates/questions.yml
  4. The composition tests render every combination automatically

See CONTRIBUTING.md for the full guide.

Sharing a template: a new kind of project usually belongs in your own template pack rather than in the bundled catalog. Publish it in your GitHub repository and list it on pytemplate-hub so others can find it. Contributions to the hub itself, from fixes to new checks, are welcome too: see pytemplate-hub.

Learn more

FAQ

Can I use this in production? The generated code is a starting point you own. Every stable bundled component combination passes lint, format, strict type-checking, and its tests in CI. Projects with authentication also get a SECURITY.md that lists what you still need to configure for deployment; for others, review the generated README.md (and .env.example for FastAPI services).

What if I want to customize the templates? Use --template to point to your own template pack (a directory or git repo). You get all the composition logic but with your own code. Before writing one, look on pytemplate-hub for a pack that already fits, and once yours works, list it there; the tutorial walks through both.

How do I keep my project updated? The generated project is yours from the first commit; pytemplate does not merge later template releases into it. Keep dependencies current with uv lock --upgrade or a bot such as Dependabot. To see what a newer release changed, generate a fresh project with the same answers and compare.

Do I need to commit the generated code? Yes—generate the project into a git repo and commit it. .pytemplate.toml records how it was made.

Is the generated code opinionated? Yes, intentionally. We have opinions on:

  • Async-first FastAPI with structured logging
  • SQLAlchemy 2.x (not SQLModel or ORM auto-magic)
  • Layered architecture (domain, application, infrastructure)
  • Type safety (strict mypy by default)

Each generated project's README.md and AGENTS.md describe its layout and conventions.

Can I generate projects without a network connection? Yes, with the bundled templates: rendering never touches the network or reads your environment, and Copier runs with unsafe=False, so templates can't execute code. Git template packs and the generated project's uv sync need network access.

License

MIT. See LICENSE.

Metadata

Release files for pytemplate-uv 3.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytemplate-uv 3.3.0
File Size Uploaded Provenance Actions
pytemplate_uv-3.3.0.tar.gz 148.6 kB With provenance Details for pytemplate_uv-3.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytemplate-uv 3.3.0
File Interpreter ABI Platform Actions
pytemplate_uv-3.3.0-py3-none-any.whl Python 3 none any Details for pytemplate_uv-3.3.0-py3-none-any.whl

Total release size: 311.0 kB

Release files / pytemplate_uv-3.3.0.tar.gz

Download URL pytemplate_uv-3.3.0.tar.gz
Size 148.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ef98a34706b31fcbd3116d88cd8ea7de5b21c261d2e0bd117502c4d73371d958
BLAKE2b-256 checksum
How to use checksums
58935852a11319720d6f684645f3223ef75f6c6b32ab698908d086b332c5db32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / pytemplate_uv-3.3.0-py3-none-any.whl

Download URL pytemplate_uv-3.3.0-py3-none-any.whl
Size 162.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f25afed5bf9ff9582cce4c1c9904e87810e009cbfb1cf8d3b7b8beebef11b262
BLAKE2b-256 checksum
How to use checksums
aebcb52c743fc05c6300af0bf2340f3c141a998f3f6b9e5dea5987fa4b1b1423
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for pytemplate-uv 3.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytemplate_uv-3.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page