What problem does it solve?
Many Go command-line tools suffer from inconsistent flag handling, brittle configuration layering, untestable I/O, improper signal handling, and brittle versioning. This Skill consolidates proven patterns and guardrails to build CLIs that behave predictably in automation, pipes, and production environments.
Core Features & Use Cases
- Opinionated patterns: guidance for Cobra + Viper project layout, root command setup, PersistentPreRunE config initialization, and silence/error handling.
- Operational concerns: flag binding to Viper, ldflags-based version embedding, stdout/stderr separation for pipe-friendly output, and signal.NotifyContext-based graceful shutdown.
- Developer ergonomics: shell completion setup, RegisterFlagCompletionFunc examples, and unit testing patterns that capture command output for CI.
- Use Case: scaffold a production-ready CLI with a minimal main, serve and version commands, robust config layering, and tests to validate output and exit codes.
Quick Start
Generate a minimal Cobra + Viper CLI scaffold with a root command, a serve subcommand, a version command using ldflags, and unit tests that capture stdout and stderr.