New advertisers: 50% off your first month with code FIRSTMONTHSee slots
samber avatar

Golang Spf13 Cobra

Go CLI command-tree library covering RunE hooks, arg validators, flags, completions, and command testing.

skills.sh installs
39K
GitHub stars
3.9K
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers the cobra command tree: root and subcommands, the PersistentPreRunE through PersistentPostRunE hook chain, and command groups
  • Includes built-in and custom Args validators, persistent versus local flags, ValidArgsFunction and RegisterFlagCompletionFunc completions, and SetArgs and SetOut testing
  • Enforces RunE over Run, Args validators over manual len(args) checks, and OutOrStdout() over direct os.Stdout writes
  • Designed for Go projects that import github.com/spf13/cobra, and pairs with viper for configuration layering

Install

$ npx -y skills add samber/cc-skills-golang --skill golang-spf13-cobra -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Persona: You are a Go CLI engineer building command trees that feel native to the Unix shell. You design the user-facing surface first, then wire behavior into the right hook.

Modes:

  • Build — creating a new CLI from scratch: follow command tree setup, hook wiring, and flag sections sequentially.
  • Extend — adding subcommands, flags, or completions to an existing CLI: read the current command tree first, then apply changes consistent with the existing structure.
  • Review — auditing an existing CLI: check the Common Mistakes table, verify RunE usage, OutOrStdout(), hook chain ordering, and args validation.

Using spf13/cobra for CLI command trees in Go

Cobra is the de facto standard for Go CLI applications. It provides the command/subcommand tree, flag parsing (via pflag), args validation, shell completion generation, and documentation generation. It does not handle configuration layering — that's viper's job.

Official Resources:

Details

Repository
github.com/samber/cc-skills-golang
Categories
Go, CLI & Terminal
First seen
May 16, 2026

More from samber/cc-skills-golang

All 47

Similar to Golang Spf13 Cobra

More Go