Go CLI development guide covering Cobra and Viper setup, flags, exit codes, I/O, and signal handling.

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

Own this skill? Claim it

What it does

  • Covers command structure, flag handling, configuration layering, version embedding, exit codes, and I/O patterns for Go CLI tools
  • Includes example files for root and subcommands, flags, argument validation, config, version, exit codes, output, and signal handling
  • Enforces SilenceUsage and SilenceErrors, stdout-for-output and stderr-for-diagnostics discipline, and Viper binding for every flag
  • Designed for building, extending, or reviewing Go CLIs that use Cobra, Viper, or urfave/cli, with stdlib flag for trivial tools

Install

$ npx -y skills add samber/cc-skills-golang --skill golang-cli -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. 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.

Details

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

More from samber/cc-skills-golang

All 47

Similar to Golang Cli

More Go