urfave/cli

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

Framework
Go
vv1.22.17
24,284 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
93 /100 Excellent
Development Activity 100
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
33%
Apache 2.0

CubeSandbox

AI Agents · Developer Tools · Security

12,859

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
84
Repo Health
88
Technical
63
Dependency
Built with
Go 33%
Rust 26%
C 22%
Updated today
Go
33%
Apache 2.0

CubeSandbox

AI Agents · Developer Tools · Security

12,859

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
84
Repo Health
88
Technical
63
Dependency
Built with
Go 33%
Rust 26%
C 22%
Updated today
Go
38%
MIT

ezBookkeeping

Invoicing Finance

5,743

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
71
Dependency
Built with
Go 38%
Vue 33%
TypeScript 25%
Updated yesterday
Go
51%
MIT

Fathom Lite

Analytics

8,020

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
Go 51%
JavaScript 31%
CSS 15%
Updated 6 months ago
Go
83%
MIT

Gitea

Developer Tools · Devops · Project Management

58,399

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
Go 83%
Updated yesterday
Go
68%
MIT

Gogs

Developer Tools

47,862

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
84
Repo Health
79
Technical
71
Dependency
Built with
Go 68%
Go Template 16%
Updated 4 weeks ago
TypeScript
48%
AGPL 3.0

Grafana

Analytics · Monitoring

77,212

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
TypeScript 48%
Go 47%
Updated today
TypeScript
71%
Other

highlight.io

Analytics · Developer Tools · Monitoring

9,384

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
71
Repo Health
78
Technical
65
Dependency
Built with
TypeScript 71%
Go 16%
Updated 1 weeks ago
Go
73%
Apache 2.0

ntfy

Developer Tools · Marketing

34,718

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
90
Repo Health
89
Technical
75
Dependency
Built with
Go 73%
JavaScript 26%
Updated yesterday

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