DEV Community

yuxuzi
yuxuzi

Posted on Originally published at linkedin.com AI-assisted

How to publish a Python template pack anyone can verify: tag, commit, digest

I build pytemplate-uv, a tool that generates typed, uv-native Python projects from templates. This week I shipped pytemplate-hub 1.0, an open index of template packs for it: https://yuxuzi.github.io/pytemplate-hub/

This post is the implementation walkthrough: how the pin works, how to try it, and how to publish a pack of your own.

The problem in one command

A template is code you run. When you pick one from a stranger's repository, you trust the tag — and tags move. In March 2025, the GitHub Action tj-actions/changed-files was compromised and its version tags were moved to a malicious commit. Thousands of repos that "pinned" to a tag ran the attacker's code.

The hub replaces "trust the tag" with something checkable: a pin. Each listing binds three things together — a tag, the exact 40-character commit that tag pointed to when it was checked, and a SHA-256 digest over every file's path and bytes in the pack.

Try the pin

You need uv and nothing else:

uvx pytemplate-uv@latest create orders-api -h yuxuzi/fastapi-service@v1.0.0 -p service-sql -y
Enter fullscreen mode Exit fullscreen mode

That generates a layered FastAPI service — routers, schemas, error handling, dependencies, health checks, settings, structured logs, SQLAlchemy with SQLite — and then you can run its own checks:

uv run ruff check . && uv run ruff format --check . && uv run mypy orders_api tests && uv run pytest -q
Enter fullscreen mode Exit fullscreen mode

22 tests, green from the first commit. The first line of the create output tells you what the hub recorded: the pack, the commit, the digest, and whether it is listed or reviewed.

Now the interesting part — what happens when something changes. Pin the same pack to a digest that doesn't match:

uvx pytemplate-uv@latest create tampered \
  --template gh:yuxuzi/fastapi-service --template-ref v1.0.0 \
  --template-commit 162d0b5c08c4574d47109f04cfe525d50e892c59 \
  --template-digest 0000000000000000000000000000000000000000000000000000000000000000 \
  -p service -y
Enter fullscreen mode Exit fullscreen mode
Error: Template pack 'gh:yuxuzi/fastapi-service' at v1.0.0 has digest 5c129b56…,
not the pinned 0000000000…. Nothing was rendered.
Enter fullscreen mode Exit fullscreen mode

Nothing was rendered. No half-written directory, no files to clean up. The check runs before a single template file is read. In CI or offline you can pin all three values in the command itself and skip the hub lookup entirely.

Every generated project also records its origin in .pytemplate.toml — generator version, pack, commit, digest, and a hash of every file written — so pytemplate status later shows what you changed since generation.

What the checks prove — and what they don't

Every listed version renders with Copier running unsafe=False (no tasks, migrations, Jinja extensions, symlinks, or submodules), then runs each profile's lifecycle commands with default answers. A weekly job re-verifies every listing.

But a listing proves only that the pack rendered and passed its checks at one commit. It does not prove anyone reviewed the code, or that it's safe. "Listed" and "reviewed" are separate states, and pytemplate-uv tells you which one you're getting every time it renders a pack. The hub's "What the checks mean" page spells out the limits next to the claims — I'd rather undersell than overclaim.

Publish your own pack

If your team has a project shape it's proud of — a Django app, a Streamlit dashboard, an ML training job, a Celery worker, a CLI with plugins — it's one tag and one pull request away from being a pack anyone can use with a pinned command:

1. Make the pack. A Git repo with a small manifest, pytemplate-pack.toml, plus a folder per profile holding its profile.toml and template files. Try it locally as you build it:

uvx pytemplate-uv@latest create my-tool -p tool --template ./my-pack -y
Enter fullscreen mode Exit fullscreen mode

2. Tag it.

git tag v1.0.0 && git push origin v1.0.0
Enter fullscreen mode Exit fullscreen mode

3. Add it to the index from a fork of the hub:

uv sync
uv run pytemplate_hub add https://github.com/<you>/<pack> --tag v1.0.0 --license MIT
Enter fullscreen mode Exit fullscreen mode

That writes the entry — commit, digest, profiles, categories — all read from your pack and the check. You don't write any of it by hand.

4. Open the pull request. CI re-verifies the entry against your tag from a clean checkout, with no secrets. Once merged, your pack appears on the website with its own page and a copy-ready command.

The ask

The hub lists 8 packs and 17 profiles today, and all eight are mine. Try one and tell me where the flow breaks — an issue on https://github.com/yuxuzi/pytemplate-hub with the exact place you got stuck is the most useful thing you can send. Or publish a pack: the first packs from other people will shape what this ecosystem becomes.

Both projects are free and MIT-licensed. The full write-up is here: https://www.linkedin.com/pulse/pytemplate-hub-from-application-factory-template-ecosystem-liu-xor1c/

Disclosure: this article was drafted with the help of AI and edited by me.

Top comments (0)