SKILL37.2K installs3.7K

Golang Spf13 Cobra

Golang CLI command tree library using spf13/cobra — cobra.Command, RunE vs Run, PersistentPreRunE hook chain, Args validators (NoArgs, ExactArgs, MatchAll, custom), persistent vs local flags, command groups, ValidArgsFunction, RegisterFlagCompletionFunc, ShellCompDirective, usage/help template customization, man-page and markdown doc generation, and testing with SetArgs/SetOut/SetErr. Apply when using or adopting spf13/cobra, or when the codebase imports `github.com/spf13/cobra`. For configuration layering alongside cobra, see the `samber/cc-skills-golang@golang-spf13-viper` skill. For general CLI architecture (project layout, exit codes, signal handling, I/O patterns), see `samber/cc-skills-golang@golang-cli`.

Type
Skill
Author
samber
Category
Backend
GitHub stars
3.7K
Installs
37.2K
Last updated
November 1, 2026

Install

npx skills add https://github.com/samber/cc-skills-golang --skill golang-spf13-cobra

Use cases


Frequently Asked Questions

When should I reach for this skill?

When you are using or adopting spf13/cobra, or when your codebase imports github.com/spf13/cobra.

How do I test cobra commands?

The skill covers testing with SetArgs, SetOut, and SetErr.

Where do I go for configuration layering alongside cobra?

See the samber/cc-skills-golang@golang-spf13-viper skill for viper configuration, and golang-cli for general CLI architecture.


About this skill

Covers the spf13/cobra CLI command tree library for Go, including cobra.Command, RunE vs Run, the PersistentPreRunE hook chain, Args validators, persistent vs local flags, command groups, completion functions, help template customization, and doc generation. Use when adopting cobra or when a codebase imports github.com/spf13/cobra. Related skills cover viper configuration and general CLI architecture.

Summary written with AI assistance from the project's public description.


Categories


More from samber


Similar Skills