What problem does it solve?
It helps you build and maintain Go command-line interfaces with predictable command trees, consistent validation, and correct error handling by using spf13/cobra patterns instead of ad-hoc parsing.
Core Features & Use Cases
- Command tree architecture: Define a root command, register subcommands, and organize help output with groups to match real CLI UX expectations.
- Correct hook lifecycle: Use RunE and the PersistentPreRunE → PreRunE → RunE → PostRunE → PersistentPostRunE execution chain with proper inheritance semantics.
- Robust args and flag handling: Apply cobra Args validators, persistent vs local flags, mutual-exclusion/required-together constraints, and shell completion functions with proper testing via SetArgs/SetOut/SetErr patterns.
- Use case: You are implementing a CLI with nested subcommands like serve, media, and tasks, and you want consistent validation, auth/config initialization before every subcommand, and shell completions that match your domain entities.
Quick Start
Use the golang-spf13-cobra skill to design your cobra root command and subcommand structure, wire PersistentPreRunE correctly, and implement each command with RunE plus cobra Args validators.