/hep-python-tools:cli-creatorfrom hep-python-tools
Builds Python CLIs with Typer: add arguments, options, subcommands, input validation callbacks, and wire entry points into pyproject.toml. Useful for analysis scripts or HEP workflows.
Ships in hep-python-tools. 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.
None: SKILL.md is the whole skill.
Typer builds Python CLIs from type-annotated functions with minimal boilerplate.
It auto-generates --help, handles type coercion, and integrates with Rich for
pretty output. For HEP analysis scripts, use Typer for any script that takes
more than one or two parameters.
myscript process, myscript plot)pyproject.tomlargparse or manual sys.argv parsinghep-python-tools:standalone-script)| Concept | Notes |
|---|---|
typer.Argument | Positional — required unless default=... |
typer.Option | Keyword (--name) — always has a default |
Annotated[T, typer.Option(...)] | Modern syntax (Typer ≥ 0.9) — preferred |
pathlib.Path | Type annotation for file/dir args; pass exists=True to validate |
typer.Typer() + app() | Multi-command entry point |
Single-command script (most common in analysis):
# /// script
# requires-python = ">=3.11"
# dependencies = ["typer", "rich"]
# ///
from __future__ import annotations
from pathlib import Path
from typing import Annotated
import typer
app = typer.Typer()
@app.command()
def main(
dataset: Annotated[str, typer.Argument(help="Rucio dataset name")],
output: Annotated[Path, typer.Option(help="Output directory")] = Path("output"),
nfiles: Annotated[int, typer.Option(help="Max files (0 = all)")] = 1,
verbose: Annotated[bool, typer.Option("--verbose/--no-verbose")] = False,
) -> None:
"""Process ATLAS data from DATASET and write histograms to OUTPUT."""
output.mkdir(parents=True, exist_ok=True)
if verbose:
typer.echo(f"Processing {dataset}, max_files={nfiles or 'all'}")
# ... analysis code ...
if __name__ == "__main__":
app()
Multi-command tool:
app = typer.Typer()
@app.command()
def process(dataset: str, output: Path = Path(".")):
"""Run the analysis and write NTuples."""
...
@app.command()
def plot(input_dir: Path, output: Path = Path("plots")):
"""Read NTuples and produce plots."""
...
pyproject.toml entry point:
[project.scripts]
my-analysis = "my_package.cli:app"
Optional path argument with existence check:
input_file: Annotated[Path, typer.Argument(exists=True, file_okay=True, dir_okay=False)]
Enum for restricted choices:
from enum import Enum
class Backend(str, Enum):
xaod = "xaod"
uproot = "uproot"
backend: Annotated[Backend, typer.Option()] = Backend.xaod
Annotated[T, typer.Option(...)] over = typer.Option(...): Both
forms work, but Typer's docs recommend Annotated (added in 0.9). The
default-value form is not formally deprecated, but it is the legacy style; use
Annotated for new code.bool flags auto-generate pairs:
Annotated[bool, typer.Option("--flag/--no-flag")] creates two flags. If you
only write bool with no Option(...), Typer makes --flag only (sets True
if present).Path validation happens at parse time: If you annotate with Path and
add exists=True, Typer validates before your function runs — handy but may
surprise you in tests.app() not typer.run(fn): For multi-command tools, always define a
Typer() app. typer.run() is only for single-function one-liners.typer.echo() wraps print(); for richer output use
from rich import print or typer.style().uv run --scriptpyproject.toml are available
after pixi install or hatch env createfrom rich.progress import track
adds progress bars with no extra configWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub usatlas/marketplace --plugin hep-python-tools6 skills in this plugin
/code-quality-toolsUse when setting up code quality tooling for a HEP Python project: configuring pre-commit hooks, adding ruff for linting and auto-formatting, setting up mypy for static type checking, or debugging linter failures in CI or a pre-commit run./pytest-speedupUse when a pytest suite is slow and needs speeding up: profiling slow tests, reducing collection time, parallelizing with pytest-xdist or pytest-split, selecting a subset of tests to run, blocking inadvertent network or large-file disk access in HEP tests, or optimizing CI test run time./python-packagingUse when creating a new Python package, adding pyproject.toml to an existing project, choosing a build backend, setting up src layout, configuring VCS-based versioning, or managing a development environment with pixi or uv for a HEP Python project.