Skip to content
Back to skills

Python Cli

ASecurity

Use when building or extending a Python command-line tool — typer app and command structure, configuration handling, logging setup and error reporting for CLIs, and distribution via uv tool.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
developmentpythongodebuggingdocumentation

Works with

  • cli

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add missing-bits/claude-plugins --skill python-cli --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Python Cli?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Python Cli
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/missing-bits-python-cli/badge)](https://www.skillsdirectory.com/skills/missing-bits-python-cli)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: python-cli
description: Use when building or extending a Python command-line tool — typer app and command structure, configuration handling, logging setup and error reporting for CLIs, and distribution via uv tool.
---

# Python CLI tools

Standards for command-line tools. Cite rules in review findings as
`(standard: python-cli, rule: <id>)`. Each rule names its source: a
PEP, an official doc, a Unix convention, or `this standard` (a recorded
house decision). Errors and logging for CLIs live here — there is no
separate errors/logging skill.

## Framework — typer

typer is the CLI framework: type-hint-driven, subcommand-friendly,
help text for free. Structure:

- one `typer.Typer()` app per tool, subcommands as functions —
  `tool run`, `tool list`, never flag-switched modes (`tool --run`);
- **arguments** for what the command operates ON (required, positional);
  **options** for how it behaves (defaults, `--flags`);
- every command and option carries help text — a CLI whose `--help`
  needs external docs fails review.

Complete skeleton: [reference/cli-skeleton.py](reference/cli-skeleton.py).
(id: `cli-typer-structure`; severity: minor; source: typer
documentation; the subcommands-over-flag-modes rule is this standard)

## Configuration

Precedence, strictest wins: **flags > environment variables > config
file > defaults**. A value settable in the file is settable by flag;
the flag names the file key (`--retry-count` ↔ `retry_count`).
Config file format is TOML — readable with the stdlib `tomllib`
(PEP 680), no parsing dependency; location follows the platform
convention (`platformdirs.user_config_dir(app_name)`) — never a dotfile
invented ad hoc in `$HOME`. (id: `cli-config-precedence`; severity:
minor; source: PEP 680 for tomllib, platformdirs documentation and the
XDG Base Directory specification for locations; the precedence order
is this standard)

## Logging and errors

- Logging goes to **stderr**; stdout is reserved for the command's
  DATA (so pipes work). (id: `cli-stderr-logs`; severity: important;
  source: the Unix stream convention as documented in CPython's
  `sys.stderr` docs)
- Default level INFO, `--verbose` switches DEBUG — configuration in
  [reference/logging-config.py](reference/logging-config.py);
  `print()` for diagnostics fails review (ruff `T201` when enabled;
  data output via `typer.echo`/`rich` is fine).
  (id: `cli-logging-config`; severity: minor; source: CPython Logging
  HOWTO; the INFO-default/--verbose split is this standard)
- **Expected failures** (bad input, missing file, remote refusal) end
  as one clear stderr message + exit code 1 — no traceback. Tracebacks
  are for bugs, and `--verbose` re-enables them for debugging.
  (id: `cli-errors-no-traceback`; severity: important; source: this
  standard)
- Exit codes: `0` success, `1` runtime failure, `2` usage error
  (typer's default for bad invocations). Scripts depend on these.
  (id: `cli-exit-codes`; severity: important; source: the Unix
  exit-status convention; usage-error 2 as documented by argparse and
  click/typer)

## Distribution

Tools install via `uv tool install <package>` (or run ad hoc with
`uvx <package>`), wired to the `[project.scripts]` entry point — the
entry-point convention itself belongs to python-project-layout.
(id: `cli-uv-tool`; severity: minor; source: uv documentation — tools)

Files in this skill

  • SKILL.md3.3 KB
  • reference/cli-skeleton.py1.5 KB
  • reference/logging-config.py919 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.