/tiran-skills:bootstrap-python-projectfrom tiran-skills
Scaffolds a new Python project from zero with src/ layout, PEP 621 metadata, build backend, type checking, testing, and hardened CI. Also upgrades existing projects via gap analysis.
Ships in tiran-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Status: Experimental — encodes one house style (the tiran/* repos: pycxxfilt,
zipwire, retread) plus current PyPA / Astral / Hynek Schlawack practice. Have a
human review the generated tree and first CI run.
Create a project that is correct, typed, tested, and releasable on day one — not
a bare uv init. This skill orchestrates four others rather than duplicating
them: choose-python-build-backend (the
backend), modernize-python-metadata (the
[project] table),
ship-type-information (the typing pass — new
projects are typed unless the user opts out; see step 5), and
secure-python-release-pipeline (the
release CI). Work in order.
Two modes. New project — run the steps to build the tree from zero. Improve an
existing project — run the same steps as a gap analysis: for each, compare what's
there against the target shape, adopt only what's missing, and respect the project's
existing choices (don't swap a working backend, task runner, or layout just to match
the house style — propose, don't impose). The four orchestrated skills already
operate on existing projects. Never overwrite or delete without the user's OK
(../GUARDRAILS.md).
Guardrails. Read
../GUARDRAILS.mdand follow it: work in a project-local.venvwith uv; preferuvxfor one-off tools; never touch global/user site-packages; don't commit/push without approval (never straight tomain); keep comments terse. Capitalize "Python"/"Torch" as product names.
Resolve current versions/pins at scaffold time — don't copy the template literals. Every version, action tag, SHA, and
rev:inreference/scaffold.mdis illustrative and stale. Pin GitHub Actions to the full commit SHA of their latest release (# vX.Y.Zcomment), pre-commitrev:s to latest tags, tool/dep versions to current floors, Python versions to those supported now (step 1).reference/scaffold.mdhas the exactgh/PyPI lookup commands.
Bundled references — open each only at the step that cites it:
reference/scaffold.md — the file tree and every file's contents (pyproject.toml
pure + compiled, tox.ini / noxfile.py, ruff/pytest/coverage, CI workflows,
.gitignore, SECURITY.md, pre-commit, changelog).reference/tooling-choices.md — decisions with >1 good answer: type checker, license,
tox vs nox, and template tools (recommended scientific-python/cookie; copier).reference/task-runners.md — nox vs tox rationale, and why not make / shell.reference/containers.md — the container house rule (only if containers are used).Authoritative sources (they win if this skill disagrees): PyPA — writing
pyproject.toml;
Scientific-Python Development Guide;
reference repos tiran/zipwire /
retread (pure) and
pycxxfilt (compiled).
Definition of done: a repo that installs (uv sync), lints clean (ruff),
type-checks clean, tests pass, builds a valid inspected sdist+wheel, and has hardened
CI + a Trusted-Publisher release workflow — with a README, a LICENSE file, and a
.gitignore. Nothing committed without the user's OK.
First establish the mode: an empty/new directory (build from zero) or an existing
project (improve). For an existing project, inventory what it already has — build
backend, layout, metadata, tooling, CI — and treat the rest of this skill as a
checklist of gaps; don't re-ask decisions the repo has already made, check upstream
first (../GUARDRAILS.md → Prior work), and don't clobber files.
Safeguard — get existing code into VCS with a clean tree before editing it. If the project holds any code that isn't safely committed (not a git repo, or a dirty working tree), stop and ask the user how to proceed — to commit or stash outstanding changes, or to initialize a repo and commit the current code — before you change anything. Don't
git initor commit on their behalf without their OK. This keeps every change this skill makes a reviewable, revertible diff and guarantees nothing pre-existing is lost — never modify code you can't diff against a committed baseline.
New projects have sticky defaults (name, import path, license, Python floor), so
ask before scaffolding. Collect (use AskUserQuestion where a default isn't
obvious):
[project.scripts];
app, not a library → packaged but may pin deps and skip PyPI.https://pypi.org/pypi/<name>/json (404 = available) or uv pip index versions <name>. PEP 503 normalizes -/_/./case, so check the normalized form (and
steer clear of confusable/typosquat-adjacent names). The import (package) name
should match the distribution name, hyphens → underscores (my-pkg → my_pkg),
unless there's a special reason to differ.bugfix/security status (not EOL). Floor
(requires-python + tool target-versions) = oldest supported; matrix = all
supported. Optionally add the next release once it reaches RC (not alpha/beta).reference/tooling-choices.md); record as SPDX.owner/repo.reference/tooling-choices.md).Reuse the answers everywhere downstream. Don't invent metadata you weren't given (author email, description) — ask or leave a marked TODO.
Run choose-python-build-backend with the
project type. Defaults:
| Project type | Backend | Versioning |
|---|---|---|
| Pure Python (default) | hatchling + hatch-vcs | [tool.hatch.version] source = "vcs" → generated _version.py |
| Compiled C/C++/CUDA/Cython | meson-python + vcs-versioning | computed in meson.build |
| Rust | maturin | maturin VCS / Cargo |
Prefer a purpose-built backend for new projects — hatchling for pure Python (no
setup.py, hatch-vcs tag-derived versions); reach for a compiled backend only when
there's native code, handing the build details to
port-to-meson-python /
port-to-scikit-build-core. These are
preferred over setuptools; choose-python-build-backend's reference/why-not-setuptools.md
has the rationale (setup.py deprecations, license-attribution history). setuptools
stays reasonable when migrating an existing project. [build-system] blocks are in
reference/scaffold.md.
If you pick meson-python, note its commit-before-build gotcha and record it in
the project's AGENTS.md (step 7) and release docs: uv build/python -m build
package the sdist from the latest git commit, silently ignoring uncommitted and
untracked changes — so contributors must commit before building or releasing. For
day-to-day development, use an editable install (pip install -e . --no-build-isolation,
or uv sync which installs the project editable): it builds from the working tree and
rebuilds the extension on import, so local edits are picked up without a commit — the
commit rule only bites at uv build/release. Details in
port-to-meson-python (step 8).
src/ layout (prevents importing the un-built package), house conventions:
src/<pkg>/__init__.py # curated public API tests/conftest.py
src/<pkg>/py.typed # empty PEP 561 marker tests/test_*.py
src/<pkg>/_*.py # private implementation
src/<pkg>/__main__.py # only if there's a CLI
Keep implementation in private underscore modules, re-export the public surface
from __init__.py, and add the empty py.typed marker now (this skill ships typed
code). Minimal __init__.py / __main__.py / conftest.py in reference/scaffold.md.
Run modernize-python-metadata for the
[project] table: name, dynamic = ["version"], description, readme, SPDX
license + license-files, requires-python, authors, keywords, classifiers
(include Typing :: Typed + the per-version Python rows; Private :: Do Not Upload if it must never hit PyPI), [project.urls], and dependencies with floors,
no upper caps. [project.scripts] for a CLI. Dev/test/docs deps go in PEP 735
[dependency-groups]. Worked blocks (both cases) in reference/scaffold.md.
Default runtime deps to the top-level
[project.dependencies]. Use[project.optional-dependencies](extras) only for genuinely optional, additional features the user explicitly asks to gate behind an extra (e.g.s3,gpu) — a feature a consumer can reasonably run without. Do not split core runtime deps into extras just to keep an install slim: that pushes complexity onto every consumer (import guards, lazy imports, degraded default behaviour). If a dependency is needed for the project's normal operation, it's a core dependency.
pyproject.toml)From reference/scaffold.md:
select = ["E","W","F","I","UP","B","SIM","TC","ANN","RUF"], ignore = ["E501","ANN401"], and a
per-file "tests/**" = ["ANN"] ignore. (TC = flake8-type-checking, enforces the
TYPE_CHECKING convention below; ANN enforces annotations. Resolve the current rule
codes — the set evolves, e.g. TCH was renamed to TC.)reference/tooling-choices.md.testpaths, an integration marker deselected by default
(addopts = "-m 'not integration'"), asyncio_mode = "auto" if async; coverage
branch/parallel, omit the generated _version.py.Imports & typing conventions (apply in generated code AND record in AGENTS.md):
py.typed) — new projects are typed
unless the user opts out. Use modern syntax (PEP 604 X | None, PEP 585 list[...],
collections.abc over typing aliases); add from __future__ import annotations for
forward refs and to keep annotations cheap. If the user opts out, skip annotations and
don't ship py.typed.if typing.TYPE_CHECKING: — satisfies ruff TC,
avoids runtime cost, and sidesteps cycles.# type: ignore. If a dependency is untyped, add its stub
package (e.g. types-requests) to the dev group so it's type-checked. Reserve
# type: ignore for libraries with neither inline types nor a stub package.For the deeper typing work — annotating an existing untyped codebase (autotyping,
pyrefly infer, MonkeyType), generating and packaging .pyi stubs for a compiled
C/C++/Cython/Rust extension, choosing modern syntax against the requires-python floor
(and typing_extensions vs. raising it), and verifying type completeness so the
built wheel actually carries its types — run
ship-type-information.
Default tox 4 + tox-uv + tox-gh (fast uv envs, [gh] CI mapping); envs:
py3XX, lint, fix, typecheck, coverage-report, docs. nox is the
recommended alternative when env setup needs real logic. Don't scaffold a
Makefile or shell scripts as the task runner (not portable, no env isolation) — a
Makefile is at most a power-user alias on top of tox/nox. CI invokes the same runner.
Templates in reference/scaffold.md; full rationale in reference/task-runners.md.
Mandatory (first three per the request):
LICENSE* file per license).
LICENSE.<dep>, list them in license-files = ["LICENSE*"], and use a
combined SPDX expression (e.g. Apache-2.0 AND BSD-3-Clause). tiran/pycxxfilt
(vendored LLVM → LICENSE.llvm) is a good model; setuptools' unattributed
vendoring is the counter-example (why-not-setuptools.md). A missing vendored
license is a real compliance defect..gitignore — fetch GitHub's canonical
Python.gitignore
and prepend a short project block (.claude/, the hatch-vcs src/<pkg>/_version.py).SECURITY.md — supported versions + GitHub private-advisory reporting.AGENTS.md + a CLAUDE.md → AGENTS.md symlink (ln -s AGENTS.md CLAUDE.md) — a brief agent guide: the project's key rules/conventions (use uv;
the task-runner commands for test/lint/typecheck; ruff for lint+format; typed code;
imports at module top-level — local imports only for cycles/optional-heavy deps;
typing-only imports under TYPE_CHECKING; annotate by default; prefer typeshed stubs
over # type: ignore; don't edit the generated _version.py; for meson-python,
develop with an editable install (pip install -e .) and commit before
uv build/release — the sdist packages the committed revision, not the working tree
(step 2); branch and don't commit without approval) and a map of the
layout (src/<pkg>/ public API vs _*.py, tests/, config in pyproject.toml, CI
in .github/). Keep it short — a pointer, not a manual. Template in
reference/scaffold.md.Opt-in, default off (the tiran/* style lints via tox + CI). Offer each; don't
scaffold unless the user says yes, and keep declined config out of the tree:
.pre-commit-config.yaml — common hook set (ruff-check/format, codespell,
validate-pyproject, pre-commit-hooks basics; prek runner). Template in scaffold.md..github/release.yml), a hand-kept Keep-a-Changelog
CHANGELOG.md, or towncrier fragments for frequent releases. All in scaffold.md..editorconfig — on request.reference/containers.md: OCI-standard
Containerfile building under both Podman and Docker, ARG over hard-coded
values, no dockerisms, a ready-made Python base (UBI/Fedora for Red Hat, Ubuntu for
Debian), multi-stage when building code, a venv in the image, run non-root
1001:0, Compose Spec, and the Dev Container standard for dev.Generate from reference/scaffold.md, then run
secure-python-release-pipeline to
finish the release path. Non-negotiable hardening: top-level permissions: {} +
least-privilege per job, every uses: SHA-pinned (# vX comment),
persist-credentials: false, concurrency cancel, uv throughout.
ci.yml (push/PR): lint, typecheck, test matrix over supported Pythons
(incl. free-threaded 3.Xt where relevant), coverage, and a build-package job
via hynek/build-and-inspect-python-package@v3
(sdist+wheel, check-wheel-contents + twine, uploads Packages). Docs job if applicable.release.yml (tags v*): pure-Python → uv build → publish; compiled → split
sdist → cibuildwheel from the sdist → verify tags → publish. Publish via PyPI
Trusted Publisher (OIDC) with id-token: write + attestations: write,
environment: pypi, attestations: true. secure-python-release-pipeline owns this.codeql.yml (python, + c-cpp for compiled), scorecard.yml,
zizmor.yml (persona: pedantic) — all covered by the release-pipeline skill.dependabot.yml — github-actions (+ pip for compiled), weekly, cooldown +
CodeQL grouping.Opt-in (default off): keep supported-Python declarations in sync across the four
places they drift (classifiers, requires-python, tox env_list, GHA matrix):
derive the CI matrix from classifiers via baipp's
supported_python_classifiers_json_array (snippet in scaffold.md), and/or the
check-python-versions linter (uvx check-python-versions . / pre-commit hook).
hatch-vcs vs. "don't commit without approval." hatch-vcs / setuptools-scm derive the version from git; with
git initbut no commit or tag yet,uv syncanduv buildfail to determine a version — but you must not commit without the user's OK. Resolve this by running the pre-approval gate with a pretend version:SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0 uv sync/... uv build. After the user approves committing, make the initial commit and an initial tag (git tag v0.1.0) so real versions are derived — don't leave the project depending on the pretend value.
git init; make the initial tree.uv venv && uv sync; commit uv.lock for reproducible dev envs (the pure-Python
reference repos do). (No commit yet? see the pretend-version note above.)uvx ruff check src/ tests/ && uvx ruff format --check src/ tests/
uvx pyrefly check # or: uvx ty check src/ / uvx mypy src/
uv run pytest
uv build && uvx twine check dist/*
Or tox for the whole matrix.uses:.*@v[0-9] with no SHA), leftover pins, and <pkg>/<dist>/<owner> markers.v* tag
triggers the release; walk the user through the one-time PyPI Trusted-Publisher
setup (secure-python-release-pipeline) before tagging.For a standard project (especially compiled), recommend scientific-python/cookie
— a copier template across 10 backends that emits a hardened project passing
sp-repo-review by construction. Use this skill's from-scratch path for the tiran/*
house style or full control. To reuse this style across many projects, capture it as
a copier template (copier update re-syncs generated repos). Full detail + the
uvx sp-repo-review . audit in reference/tooling-choices.md.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
12 skills in this plugin
/choose-python-build-backendRecommend the right PEP 517 build backend for a new or existing Python package, and give enough context to migrate. Chooses by three axes: purelib (pure Python) vs platlib (compiled C/C++/Rust/Torch), static vs dynamic/VCS metadata, and native language/build system. Covers uv-build, flit-core, hatchling (incl. compiled via scikit-build-core[hatchling] / a custom build hook), meson-python, scikit-build-core, maturin, and setuptools (legacy). Weighs compiled-project concerns: Cython, PyTorch extensions, pybind11/nanobind bindings, the stable Python ABI (abi3 / limited API), and fast parallel builds (CMake+Ninja, Meson). Use when asked "which build backend should I use", to pick a backend for a new project, or to decide whether to move an existing project off setuptools./crypto-fips-auditAudit a Python package — and any C/C++/Go/Rust code it ships — for its use of cryptography, across three use cases: inventory what crypto a package uses at all (algorithms, providers, linkage, RNG, CA stores), find insecure or weak cryptography, and assess FIPS 140-3 / NIST compliance. Flags insecure use of approved primitives (AES-ECB, RSA PKCS#1 v1.5, static IV/nonce, `random` for secrets, timing-unsafe compares, disabled TLS verification), weak RSA/EC key sizes, and — for FIPS — refused hashes (MD5, MD4, RIPEMD-160), restricted ones (SHA-1), non-approved primitives (BLAKE2/3, ChaCha20-Poly1305, 3DES, scrypt/Argon2/bcrypt, X25519/X448 key agreement, secp256k1), vendored or statically linked crypto (bundled OpenSSL/BoringSSL/AWS-LC/NSS/GnuTLS/libgcrypt/ nettle/libsodium) that escapes the system validated module, hardcoded TLS versions/ciphers that bypass crypto-policies, bundled CA trust stores, and problematic PyPI deps (bcrypt, pycryptodome, pynacl, ecdsa, rsa, m2crypto, …). Source-first, then confirmed against the built wheel/binaries. Gathers evidence; does not certify compliance./modernize-python-metadataImprove a Python package's metadata and move it into a PEP 621 [project] table in pyproject.toml — filling in what's missing along the way. Covers the readme field (dropping the open().read() hack), SPDX license expressions, trove classifiers, well-known project URLs, authors/keywords/requires-python, dependency version constraints (avoid upper caps), PEP 735 dependency groups vs extras, and the build-system table. Keeps the existing build backend (setuptools is fine). Includes a Poetry → PEP 621 migration lens (the [tool.poetry] field map and caret/tilde → floor translation; PDM too). Use when asked to clean up packaging metadata, move metadata out of setup.py/setup.cfg, migrate a Poetry (or PDM) project to [project]/PEP 621, or improve a project's PyPI page./port-to-free-threaded-pythonMake a Python package work correctly on the free-threaded (no-GIL) CPython build (PEP 703; the cp313t/cp314t "t" ABI) and declare that it does, so importing it does not silently re-enable the GIL. Covers the pure-Python thread-safety pass (mutable global/class state, caches, contextvars vs threading.local) and, for C/C++/Cython/pybind11/nanobind/Rust-PyO3 extensions, declaring support (Py_mod_gil / PyUnstable_Module_SetGIL / the per-binding flag), fixing data races with critical sections (Py_BEGIN_CRITICAL_SECTION), PyMutex, atomics and thread-local state, the borrowed-reference hazards and their strong-reference replacements (PyList_GetItemRef, PyDict_GetItemRef), building cp3Xt wheels (meson-python, scikit-build-core, maturin, setuptools, cibuildwheel), and testing under load with ThreadSanitizer and pytest-run-parallel. Use to add free-threading / no-GIL / nogil / free-threaded / PEP 703 support, ship a cp313t/cp314t wheel, or stop the GIL being re-enabled. For a single stable-ABI abi3t wheel (3.15+) pair it with port-to-python-limited-api./port-to-meson-pythonBuild a Python package (usually with a compiled C/C++/Cython/Fortran/Rust extension) with the meson-python PEP 517 backend, or port one off a bespoke setuptools setup.py. Covers the pyproject.toml backend, the meson.build (project / extension_module / install_sources), VCS/dynamic versioning computed in meson.build, editable installs, config-settings, and abi3 / limited-API wheels. Use when asked to adopt meson-python or Meson, scaffold a new meson-python project, drop setup.py, or produce standards-based wheels./port-to-python-limited-apiPort a hand-written C/C++ CPython extension from the version-specific C API to the Limited API (Py_LIMITED_API) so one stable-ABI abi3 wheel loads on every later Python instead of one per version — and optionally target Python 3.15 abi3t (PEP 803 + PEP 793 PyModExport) for a single wheel across GIL-enabled and free-threaded builds. Covers the usual first step of converting static PyTypeObject types to heap types (PyType_FromSpec / PyType_Slot), module state, multi-phase init, API substitutions, and the build flags / abi3 / abi3.abi3t wheel tags for meson-python, scikit-build-core, maturin, and setuptools. Use to adopt the limited API / stable ABI / abi3 / abi3t, stop rebuilding a C extension per Python version, or convert static types to heap types. Not for pybind11/nanobind (see pybind11-to-nanobind) or the PyTorch C++ ABI (see port-to-torch-stable-abi).npx claudepluginhub tiran/agent-skills --plugin tiran-skills