
Golang Cli
This is a comprehensive reference for building production-grade Go CLIs with Cobra and Viper. It covers the full lifecycle: bootstrapping new tools with proper project structure, extending existing ones with subcommands and flags, and reviewing for common mistakes like leaking usage text on errors or mixing stdout and stderr. The exit code table, signal handling with context propagation, and the flags-to-Viper binding patterns are especially solid. Worth invoking whenever you're wiring up command trees, handling configuration layering, or need to remember whether `SilenceUsage` should be true (it should). Built by samber, who maintains a bunch of Go utilities, so the opinions here come from real CLI work.
- skills.sh installs
- 41.1K
- GitHub stars
- 3.8K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add samber/cc-skills-golang --skill golang-cli --agent claude-codeInstalls into .claude/skills of the current project.
Files
Persona: You are a Go CLI engineer. You build tools that feel native to the Unix shell — composable, scriptable, and predictable under automation.
Modes:
- Build — creating a new CLI from scratch: follow the project structure, root command setup, flag binding, and version embedding 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 for correctness: check the Common Mistakes table, verify
SilenceUsage/SilenceErrors, flag-to-Viper binding, exit codes, and stdout/stderr discipline.
Go CLI Best Practices
Use Cobra + Viper as the default stack for Go CLI applications. Cobra provides the command/subcommand/flag structure and Viper handles configuration from files, environment variables, and flags with automatic layering. This combination powers kubectl, docker, gh, hugo, and most production Go CLIs.
When using Cobra or Viper, refer to the library's official documentation and code examples for current API signatures.
Sponsors
Details
- Repository
- github.com/samber/cc-skills-golang
- Categories
- Testing & QA, AI & Agent Building, Release Management, Go, CLI & Terminal
- First seen
- Apr 16, 2026
More from samber/cc-skills-golang
All 47- Golang Benchmark41K
- Golang Dependency Injection41K
- Golang Popular Libraries41K
- Golang Stretchr Testify40.9K
- Golang Continuous Integration40.9K
- Golang Grpc40.7K
- Golang Samber Lo40K
- Golang Stay Updated40K
- Golang Samber Do39.8K
- Golang Samber Slog39.8K
- Golang Samber Oops39.7K
- Golang Samber Mo39.7K
- Golang Samber Hot39.7K
- Golang Samber Ro39.6K
- Golang Spf13 Cobra38.6K
- Golang Swagger38.6K
- Golang Graphql38.5K
- Golang Google Wire38.3K
- Golang Spf13 Viper38.3K
- Golang Uber Fx38.1K
- Golang Uber Dig38K
- Golang How To37.9K
- Golang Linter26.5K
- Golang Pkg Go Dev13.3K