console-cli

Installation
SKILL.md

Console Apps & CLI Tools (.NET 10)

Core Principles

  1. stdout is data, stderr is everything else — Results go to stdout so mytool list | jq works. Logs, progress, prompts and errors go to stderr. Mixing them breaks every pipe and script that consumes your tool.
  2. Exit codes are the API — 0 = success, non-zero = failure, and each failure class gets a stable code. Scripts and CI branch on exit codes, never on parsing your error text.
  3. Use System.CommandLine 2.x, not hand-rolled args parsing — It went stable at 2.0 and gives help, --version, validation, tab completion and Ctrl+C handling for free. Hand parsing always misses --opt=value, quoting, and help output.
  4. Cancellation flows from Ctrl+C to every await — System.CommandLine turns SIGINT/SIGTERM into a CancellationToken. Pass it all the way down, or Ctrl+C becomes a hard kill that corrupts half-written files.
  5. Generic Host only when you need it — DI, configuration, logging and IHttpClientFactory justify Host.CreateApplicationBuilder. A 50-line utility does not; startup time matters for CLIs.

Patterns

Command Tree with System.CommandLine 2.x

Verified against System.CommandLine 2.0.x (stable). The beta-era APIs (SetHandler, InvocationContext, CommandLineBuilder) are gone.

using System.CommandLine;
Installs
40
GitHub Stars
801
First Seen
1 day ago