Cobra is a library providing a simple interface to create powerful modern CLI interfaces, similar to git or go. Created by Steve Francia, Cobra is the de facto standard for building production-grade command-line tools in Go.
It powers kubectl, Hugo, GitHub CLI, Docker, Helm, etcd, OpenShift, istioctl, Cilium, GoReleaser — the list goes on. If you’ve used a serious Go CLI, you’ve used Cobra.
CLI framework for Go. The library powering kubectl, hugo, gh, docker, helm, etcd, istioctl.
✨ Features
git-style subcommand trees. cli root cmd subcmd flag — natural to grow.
Per-command flags, persistent flags inherited by subcommands. Bound via Viper for config.
Generated --help, generated shell completions for bash, zsh, fish, PowerShell.
PreRun, Run, PostRun lifecycle. Authentication, setup, teardown attached to any command.
cobra-cli scaffolds new commands. Stop typing boilerplate, start writing logic.