urfave/cli

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

Framework
Go
vv1.22.17
24,235stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
93/100Excellent
Development Activity100
Maintenance96
Community76
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
88/100Excellent
Architecture85
Code Quality90
Innovation80
Learning Curve95

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
33%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

12,344

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
83
Repo Health
88
Technical
63
Dependency
Built with
Go33%
Rust26%
C23%
Updated 3 days ago
Go
33%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

12,344

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
83
Repo Health
88
Technical
63
Dependency
Built with
Go33%
Rust26%
C23%
Updated 3 days ago
Go
37%
MIT

ezBookkeeping

Invoicing Finance

5,578

Lightweight self-hosted personal finance manager with AI receipt scanning, multi-currency support, and MCP integration for complete data privacy.

View details
88
Repo Health
80
Technical
72
Dependency
Built with
Go37%
Vue34%
TypeScript25%
Updated 3 days ago
Go
51%
MIT

Fathom Lite

Analytics

8,021

A simple, self-hosted website analytics tool built with Go and Preact that lets you understand your traffic without handing data to third parties.

View details
47
Repo Health
67
Technical
67
Dependency
Built with
Go51%
JavaScript31%
CSS15%
Updated 6 months ago
Go
83%
MIT

Gitea

Devops · Developer Tools · Project Management

57,984

Self-hosted DevOps in a single Go binary — Git hosting, GitHub Actions-compatible CI/CD, and 30+ package registries without any SaaS dependency.

View details
93
Repo Health
79
Technical
64
Dependency
Built with
Go83%
Updated 2 days ago
Go
68%
MIT

Gogs

Developer Tools

47,812

The painless self-hosted Git service that runs on anything from a Raspberry Pi to a $5 cloud droplet, delivering GitHub-like workflows as a single Go binary.

View details
88
Repo Health
79
Technical
71
Dependency
Built with
Go68%
Go Template16%
Updated 5 days ago
TypeScript
48%
AGPL 3.0

Grafana

Monitoring · Analytics

76,758

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
63
Dependency
Built with
TypeScript48%
Go46%
Updated 2 days ago
TypeScript
71%
Other

highlight.io

Developer Tools · Analytics · Monitoring

9,374

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
68
Repo Health
78
Technical
65
Dependency
Built with
TypeScript71%
Go16%
Updated 4 weeks ago
Go
73%
Apache 2.0

ntfy

Developer Tools · Marketing

34,222

Send push notifications to your phone or desktop from any script or service using a single HTTP PUT or POST—no sign-up required.

View details
89
Repo Health
89
Technical
75
Dependency
Built with
Go73%
JavaScript26%
Updated 1 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

Search