python-cli-typer

Use when building or structuring Python CLI commands with Typer, including commands, options, and multi-command apps.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "python-cli-typer" with this command: npx skills add narumiruna/agent-skills/narumiruna-agent-skills-python-cli-typer

Python CLI with Typer

Overview

Use Typer for ergonomic CLI construction. Core principle: keep CLI entry points explicit and testable.

Install

uv add typer

Quick Reference

TaskPattern
Single command@app.command()
Optionsfunction args with defaults
Multiple commandsmultiple @app.command()

Workflow

  • Define a typer.Typer() app in cli.py.
  • Keep command functions small; move logic into separate modules.
  • Run CLI via uv run python -m <module> or uv run python cli.py.

Example

import typer

app = typer.Typer()

@app.command()
def greet(name: str, count: int = 1) -> None:
    for _ in range(count):
        typer.echo(f"Hello, {name}!")

if __name__ == "__main__":
    app()

Usage:

uv run python cli.py --help
uv run python cli.py Alice
uv run python cli.py Alice --count 3

Multiple commands:

import typer

app = typer.Typer()


@app.command()
def create(name: str) -> None:
    """Create a new item."""
    typer.echo(f"Creating {name}...")


@app.command()
def delete(name: str, force: bool = False) -> None:
    """Delete an item."""
    if not force:
        if not typer.confirm(f"Delete {name}?"):
            raise typer.Abort()
    typer.echo(f"Deleted {name}")


if __name__ == "__main__":
    app()

Common Mistakes

  • Putting heavy business logic inside CLI functions.
  • Forgetting to wire if __name__ == "__main__" for script entry.

Red Flags

  • CLI guidance that ignores Typer when Typer is the chosen framework.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

python-packaging-uv

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

python-logging

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

python-modern-tooling

No summary provided by upstream source.

Repository SourceNeeds Review