urfave/cli

A declarative, dependency-free Go package for building fast, friendly command-line tools.

Framework
Go
vv1.22.17
24,312 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
92 /100 Excellent
Development Activity 96
Maintenance 96
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
88 /100 Excellent
Architecture 85
Code Quality 90
Innovation 80
Learning Curve 95

urfave/cli is a declarative Go package for building command-line applications, offering commands, subcommands, and flags defined directly as Go structs rather than through builder chains or code generation. It ships with zero dependencies outside the Go standard library and covers most of what a CLI tool needs out of the box: alias- and prefix-matched subcommands, typed flags for simple types, slices, durations, and timestamps, compound short-flag parsing, and a permissive help system with typo suggestions.

Originally created for Docker’s CLI and now maintained by a volunteer team, the project has matured through three major versions (v1 through v3) while keeping the same declarative philosophy. Companion modules (urfave/cli-altsrc for config-file input, urfave/cli-docs for man/Markdown generation) let teams add functionality without bloating the core package, and built-in shell-completion generation covers bash, zsh, fish, and PowerShell.

What You Get

  • Declarative Command and Flag structs — describe a CLI as data instead of chaining builder calls
  • Nested subcommands with alias and prefix matching
  • Typed flags for strings, numbers, bools, durations, and timestamps, plus slice variants of each, via a generic FlagBase implementation
  • Automatic, permissive help text generation with “did you mean” suggestions for mistyped commands and flags
  • Built-in shell completion generation for bash, zsh, fish, and PowerShell
  • Zero runtime dependencies outside the Go standard library

Common Use Cases

  • Building an internal developer CLI with multiple subcommands and shared flags
  • Wrapping an API or service behind a friendly command-line client
  • Adding config-file, environment-variable, or plain-text-file input sources via the urfave/cli-altsrc module
  • Generating man pages and Markdown docs for a CLI via the urfave/cli-docs module

Under The Hood

Architecture

A Command struct is both the application root and every node beneath it — the same type carries flags, an Action, lifecycle hooks, and a slice of child Commands, so parsing is naturally recursive: command_setup.go prepares a command’s flags and defaults, command_parse.go walks argv against the active flag set, and command_run.go dispatches through the ArgValidator/Before/Action/After sequence before descending into a matched subcommand. Help and shell completion (help.go, completion.go, template.go) sit alongside this tree and read the same Command/Flag metadata, so no separate registration step is needed to keep help text or completions in sync with the actual command definitions.

Tech Stack

The library targets Go 1.22+ and depends on nothing beyond the standard library at runtime; its only declared dependency, stretchr/testify (plus an indirect YAML parser it pulls in), is used solely by the test suite. Generics do the heavy lifting for flags: flag_impl.go defines a single FlagBase[T, C, VC] type that the concrete String, Int, Bool, Duration, Timestamp, and slice-of-each flags are generated from, avoiding hand-duplicated parsing logic per type. The project’s documentation site (docs/, built with mkdocs) is published via a dedicated GitHub Actions workflow, separate from the Go module itself.

Code Quality

The repository carries an extensive suite of table-driven tests across roughly two dozen _test.go files covering flags, commands, help output, shell completion, and error paths, using testify for assertions. A staticcheck configuration and dedicated lint and test GitHub Actions workflows run on every change, and errors are handled as explicit typed values (errors.go defines a composite error type for aggregating multiple failures) rather than silently swallowed.

What Makes It Unique

Where many Go CLI libraries push users toward imperative builder APIs or external code generation, urfave/cli stays purely declarative — the whole application is describable as literal struct values. Its generic flag implementation gives type-safe custom flag types without codegen, its help system proactively suggests corrections for typos instead of just failing, and it deliberately keeps the core package dependency-free while offloading optional concerns (structured config sources, doc generation) to separate companion modules maintained under the same organization.

Used by 20 apps in this directory

Go
79%
Apache 2.0

OpenMeter

Developer Tools · Invoicing Finance

2,439

Open-source metering and billing engine for AI, agentic, and DevTool monetization — ingest usage events in real time and turn them into accurate invoices automatically.

View details
87
Repo Health
81
Technical
66
Dependency
Built with
Go 79%
TypeScript 16%
Updated 1 weeks ago
Go
82%
AGPL 3.0

PeerDB

Data Engineering · Databases

3,315

Postgres-native ETL that streams change data capture in real time to Snowflake, BigQuery, ClickHouse, S3, and Kafka — up to 10x faster than general-purpose pipelines, managed through a familiar Postgres SQL interface.

View details
89
Repo Health
76
Technical
66
Dependency
Built with
Go 82%
TypeScript 11%
Updated 1 weeks ago
Go
98%
Apache 2.0

Space Cloud

Authentication · Devops

4,001

Kubernetes-native serverless platform that generates instant GraphQL and REST APIs for any database with built-in auth and real-time subscriptions

View details
50
Repo Health
74
Technical
63
Dependency
Built with
Go 98%
Updated 2 years ago
Go
98%
Apache 2.0

Space Cloud

Authentication · Devops

4,001

Kubernetes-native serverless platform that generates instant GraphQL and REST APIs for any database with built-in auth and real-time subscriptions

View details
50
Repo Health
74
Technical
63
Dependency
Built with
Go 98%
Updated 2 years ago
Go
90%
BSD 3

tau

Devops

5,165

Open-source, Git-native platform-as-a-service for building, deploying, and scaling fullstack apps on your own infrastructure with no DevOps required.

View details
66
Repo Health
82
Technical
65
Dependency
Built with
Go 90%
Updated 2 weeks ago
Go
99%
MIT

temporal

Automation · Devops

24,238

Open-source durable execution platform that keeps mission-critical workflows running through any failure, automatically.

View details
92
Repo Health
85
Technical
68
Dependency
Built with
Go 99%
Updated 1 weeks ago
Go
99%
MIT

temporal

Automation · Devops

24,238

Open-source durable execution platform that keeps mission-critical workflows running through any failure, automatically.

View details
92
Repo Health
85
Technical
68
Dependency
Built with
Go 99%
Updated 1 weeks ago
Go
60%
AGPL 3.0

Unkey

Developer Tools

5,482

An open-source developer platform for API infrastructure — issue and verify API keys, enforce global rate limits, route traffic through a gateway, and get per-key analytics and audit logs.

View details
91
Repo Health
70
Technical
68
Dependency
Built with
Go 60%
TypeScript 39%
Updated 1 weeks ago
Go
54%
AGPL 3.0

Uptrace

Devops · Monitoring

4,311

Unified open-source APM that collects OpenTelemetry traces, metrics, and logs into a single self-hosted platform backed by ClickHouse.

View details
70
Repo Health
70
Technical
65
Dependency
Built with
Go 54%
Vue 34%
Updated 4 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers