python-cli-typer

A guide to building Python command-line tools with Typer or Click. Command-line tools are programs users run from a terminal; this covers commands, options, environment settings, exit codes, and tests.

In plain words
What is it for?
Use it when creating or extending a Python CLI with subcommands, configuration from environment variables, defined exit codes, or in-process tests.
Why use it?
It helps give terminal programs predictable arguments, useful help text, clear failure signals, and an entry point that can be tested without starting another process.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/vikasudasi/skill-vault/python-cli-typer
Any agent
npx skills add vikasudasi/skill-vault --skill python-cli-typer
Clone the repo
git clone --depth 1 https://github.com/vikasudasi/skill-vault

Made for: Claude Code, Codex.

Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 509 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00034 $0.00509
Opus 5 $0.00017 $0.00254
Sonnet 5 $0.00007 $0.00102
Haiku 4.5 $0.00003 $0.00051

Measured yesterday against content hash 11ab62596fcb, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python-cli-typer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/demo_cli.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skill_vault/data/skills/python-cli-typer/SKILL.md · 68 lines

What it actually says

Building Python CLIs with Typer

Use when scaffoldng or extending a Python command-line tool and you want a maintainable argument surface, clean help, and a testable entrypoint.

Scaffold

from __future__ import annotations

import typer

app = typer.Typer(add_completion=False)


@app.command()
def scan(path: str, recursive: bool = typer.Option(False, "--recursive", "-r")) -> None:
    """Scan a directory."""
    ...


if __name__ == "__main__":
    app()

Conventions that matter

  • Use --flag for booleans, --opt VALUE for options; put required positional args first. Never mix a required option with a positional that can be omitted.
  • Read config from env with a small settings dataclass instead of scattering os.getenv through commands (mirrors Skill Vault's get_settings).
  • Exit codes: 0 success, 1 runtime/API error, 2 invalid args (click does this by default), 3 "no valid results". Raise a typed exception and map it in a top-level handler rather than sys.exit inline.

Testing

Expose a main(argv: list[str]) -> None that calls app(args=argv, standalone_mode=False). This lets you invoke commands in-process without spawning a process.

from cli import main


def test_scan_ok():
    with pytest.raises(SystemExit) as e:
        main(["scan", "src"])
    # assert stdout via capsys

Pitfalls

  • Typer's --help is auto-generated — keep docstrings accurate, they become help.
  • For streaming/progress use rich (Typer integrates via rich.markup), not print.
  • Don't make the CLI print secrets or API keys on the happy path.
Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 68 lines · 34 tokens per session scan A 11ab62596fcb

Subscribe to this mod's changes

python-cli-typer is a skill published in the GitHub repository vikasudasi/skill-vault (0 stars, last pushed 16d ago), licensed Apache-2.0. It adds 34 tokens to every session and 509 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

cli-tool-design

Design command-line interfaces with clear argument parsing, subcommands, help text, output formatting, and exit codes. Covers Click, Typer, argparse, and shell completion. Triggers on CLI tool development, argument parsing, or terminal UX design requests.

organvm-iv-taxis/a-i--skills · 54 tokens

cli-sdk-guide

Guide for implementing Backend.AI client SDK and CLI (Session, BaseFunction, @apifunction, Click commands, Pydantic models, FieldSpec, output handlers, APIConfig, testing).

lablup/backend.ai · 43 tokens

compose-python-stack

Design and generate a compatible project from the Python Template component layers or presets. Use when choosing a workload, framework, AI providers, data engines, interfaces, training and serving tools, deployment target, or IaC option; also use when a user wants a simple library, CLI, or API without AI.

leynier/python-template · 65 tokens

maintain-python-template

Extend or repair the Python Template repository while keeping its catalog, Copier questions, templates, generated references, and tests synchronized. Use for adding a framework, provider, database, interface, ML tool, deployment target, preset, compatibility rule, or generated-project capability.

leynier/python-template · 57 tokens

validate-python-stack

Validate the Python Template repository or a project generated from it. Use before committing, publishing, deploying, or reviewing a stack to check catalog compilation, rendering, dependencies, formatting, tests, security workflows, skills, and representative runtime behavior.

leynier/python-template · 51 tokens

operate-ai-stack

Develop, test, and troubleshoot this generated AI or ML workload across its framework, model and embedding providers, retrieval stores, interfaces, training, serving, and observability layers. Use when changing prompts, tools, agents, RAG, MCP, inference, fine-tuning, evaluations, or provider integration.

leynier/python-template · 65 tokens