# spf13/cobra

A Commander for modern Go CLI interactions

Repository: https://github.com/spf13/cobra
Canonical: https://ross.abutalabs.com/products/cobra
Homepage: https://cobra.dev
Language: Go
License: Apache-2.0
License Family: permissive
Topics: cobra, cobra-library, cobra-generator, posix-compliant-flags, command-cobra, cli-app, command-line, commandline, command, cli, go, golang, golang-library, golang-application, subcommands, posix
Last push: 2026-07-11T00:43:07+00:00

## Health v2 (maintenance only)
Score: 77/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 91, release rhythm 47, longevity 100
- inputs: {"age_days": 4747, "days_push": 54, "days_rel": 273, "gap_med": 47.0, "n_releases_24m": 5}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 44514, forks 3221 (observed 2026-08-28T04:12:09.318688+00:00)

## What it is
Cobra is a Go library for building powerful, modern command-line applications with nested subcommands, POSIX-compliant flags, and automatic help generation. It is the de facto standard CLI framework in the Go ecosystem, powering Kubernetes, Docker, Hugo, and GitHub CLI.

## Use cases
- build a cli tool in go with subcommands
- add posix-compliant flag parsing to a go app
- generate shell autocomplete for bash zsh fish powershell
- generate man pages for a command-line tool
- scaffold a new go cli project structure
- add command aliases and intelligent typo suggestions to a cli
- integrate cli flags with viper configuration management

## When to choose
- you are writing a multi-command CLI in Go similar to git or kubectl
- you want automatic help text, shell completion, and man page generation
- you need battle-tested, widely adopted tooling with a large ecosystem
- you want optional viper integration for 12-factor configuration

## When to avoid
- you are building a CLI in a language other than Go
- you need only a simple single-command script with minimal dependencies
- you want a declarative or annotation-based CLI framework rather than imperative command structs

## Facets
- artifact type: library
- maturity: stable
- function: cli, developer-tools, middleware
- domain: developer-tools, apis
- platform: go, cross-platform, cli
- tags: cli-framework, subcommands, flag-parsing, shell-completion, cobra-cli, posix-flags, man-pages, viper-integration, command-line

## Member repositories
- spf13/cobra (main) score 77

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:12:09.318688+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T16:22:00.498497+00:00, confidence not recorded.
  - readme: https://github.com/spf13/cobra (fetched 2026-08-28T04:12:09.318688+00:00, sha 242afefd8aa2)
  - homepage: https://cobra.dev (fetched 2026-08-29T07:46:07.608524+00:00, sha ce890b4a9952)
  - site_page: https://cobra.dev/docs/how-to-guides/context-and-tracing (fetched 2026-08-29T07:46:07.625707+00:00, sha 6e16c9c50a4f)
  - site_page: https://cobra.dev/docs/explanations/enterprise-guide (fetched 2026-08-29T07:46:07.628206+00:00, sha 94981417d847)
  - site_page: https://cobra.dev/docs/how-to-guides/clis-for-llms (fetched 2026-08-29T07:46:07.623307+00:00, sha 240013d38009)
  - site_page: https://cobra.dev/docs (fetched 2026-08-29T07:46:07.618405+00:00, sha 94d2c55406b1)
  - site_page: https://cobra.dev/docs/tutorials/first-cli (fetched 2026-08-29T07:46:07.620540+00:00, sha 48bb1c115c8b)
  - site_page: https://cobra.dev/docs/examples (fetched 2026-08-29T07:46:07.630812+00:00, sha 1be70ee3c531)
  - site_page: https://cobra.dev/docs/tutorials/getting-started (fetched 2026-08-29T07:46:07.633216+00:00, sha b7df3d662190)
  - site_page: https://cobra.dev/docs/how-to-guides (fetched 2026-08-29T07:46:07.635572+00:00, sha 51a1d455f3b6)
- Data as of 2026-08-30T08:39:29.467469+00:00.
