What problem does it solve?
This Skill helps you develop, extend, or audit Go command-line tools with predictable behavior, correct configuration handling, and automation-friendly I/O so your CLI works reliably in scripts and pipelines.
Core Features & Use Cases
- Command design & structure: build consistent Cobra command trees with proper root/subcommand organization and minimal
main() entry points.
- Flags, validation, and completions: implement robust flag binding, required/constraint rules, argument validators, and shell completion support.
- Configuration layering with Viper: ensure correct precedence across flags, environment variables, and config files while handling missing config safely.
- Operational correctness: enforce stdout/stderr discipline, Unix exit code conventions, version injection via
ldflags, and graceful cancellation via signal.NotifyContext.
- Testing patterns: test commands by executing them programmatically and capturing output using Cobra’s output writers for deterministic assertions.
Quick Start
Ask the agent to build a Cobra-based Go CLI with a root command, add a serve subcommand, initialize Viper in PersistentPreRunE, bind flags to Viper, implement argument validation, support shell completion, and ensure logs go to stderr while results go to stdout.