// the find
spf13/cobra-cli
Cobra CLI tool to generate applications and commands
cobra-cli is the official scaffolding tool for spf13/cobra, the most widely-used Go CLI framework. It generates the boilerplate project structure and individual command files so you don't have to copy-paste the same cmd/ layout every time. Aimed at Go developers starting a new CLI tool who want the correct cobra idioms from the first commit.
The golden-file test approach is solid — generated output is compared against committed fixtures, so regressions in templates are caught immediately. The config file (~/.cobra.yaml) is a nice touch that avoids repeating --author and --license on every invocation. Parent command wiring via -p flag maps cleanly to how cobra's command tree actually works, which prevents the usual confusion about attaching subcommands. Being maintained in the same org as cobra itself means the scaffolded code stays in sync with the library's conventions.
The tool only does two things (init and add), and neither has evolved much since 2022 — last real push was mid-2024 and the commit history is sparse. There's no way to generate completion scripts, persistent flags, or argument validators as part of the scaffold, so you're immediately back to hand-writing boilerplate. camelCase-only command names is a real footgun with no tooling guard — you get a cryptic error if you pass kebab-case. The generated code still uses the old-style viper global instance pattern rather than the newer cobra v1.8+ approach with bound flag values, so new projects inherit slightly dated patterns.