306477b5bef4bb1e304696050c477002978f1a9e
Python CLI Template
A minimal Cookiecutter template for building personal CLI tools with uv, Typer, and strict typing.
Features
- CLI with Typer
uv_buildbackend and lockfile-first reproducibility- Ruff for linting/formatting
- MyPy strict mode
- Pytest with coverage
- Invoke tasks for common operations
Quick Start
-
Generate a new project:
cruft create git@git.roxautomation.com:sjev/python-cli-template.gitOr locally:
cookiecutter /path/to/python-cli-template -
Post-generation hook runs
uv lockto createuv.lock. -
Bootstrap the generated project:
uv sync --frozen --group dev uv run invoke lint uv run invoke test
Template Variables
| Variable | Description | Example |
|---|---|---|
project_name |
Human-readable project name | "My CLI App" |
project_slug |
Repository/directory name | "my-cli-app" |
package_name |
Python package name | "my_cli_app" |
description |
Short project description | "A modern CLI tool" |
author_name |
Author's full name | "Your Name" |
author_email |
Author's email | "your.email@example.com" |
version |
Initial version | "0.1.0" |
Python is fixed to 3.12+ by template policy.
Generated Project Structure
your-project/
├── README.md
├── pyproject.toml
├── tasks.py
├── uv.lock
├── src/
│ └── your_package/
│ ├── __init__.py
│ ├── py.typed
│ └── cli.py
└── tests/
└── test_cli.py
Template Development
To modify this template:
- Edit files in
{{cookiecutter.project_slug}}/ - Update variables in
cookiecutter.json - Test changes:
./test.sh
Requirements
- Python 3.12+
uvcruftorcookiecutter
Languages
Shell
66.2%
Python
33.8%