developing-cli-apps
Installation
SKILL.md
CLI Application Development
Standards for building CLI applications in Go. Currently uses Cobra for command structure and Huh for interactive UI.
Interactive UI patterns: See Interactive UI Reference
Command Organization
- One file per command in
cmd/, file name matches command name (camelCase) - All commands registered in their own
init()function viarootCmd.AddCommand() - See
cmd/root.gofor the root command structure and initialization chain - See any existing command file (e.g.,
cmd/version.go) for a minimal example
Adding a New Command
- Create a new file in
cmd/(camelCase name matching the command) - Define a
cobra.Commandvariable withUseandShortfields - In
init(): register withrootCmd.AddCommand(), define flags, bind to Viper - Suppress the init lint:
//nolint:gochecknoinits // Cobra requires an init function to set up the command structure.