Clap

The most widely used command-line argument parser for Rust, with both derive and builder APIs.

Library
Cargo
v4.6.6
16,645stars
MIT OR Apache-2.0

Repository Health

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

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
90/100Excellent
Architecture90
Code Quality88
Innovation93
Learning Curve95

Clap (Command Line Argument Parser) is the de facto standard library for parsing command-line arguments in Rust, used across hundreds of millions of downloads by projects ranging from small utilities to widely used tools like ripgrep, fd, and bat. It gives developers two equally supported ways to define a CLI: a declarative #[derive(Parser)] macro that turns a plain struct into a full parser, and an imperative builder API (Command/Arg) for CLIs that need to be constructed dynamically at runtime.

Beyond parsing, clap automatically generates colored, terminal-width-aware --help and usage text, produces structured errors with typo-correcting suggestions, and — via the companion clap_complete, clap_complete_nushell, and clap_mangen crates — generates shell completions and man pages straight from the same argument definitions, so documentation and behavior never drift apart.

What You Get

  • A declarative derive macro (Parser, Args, Subcommand, ValueEnum) that turns a plain Rust struct into a fully working CLI parser.
  • A lower-level builder API (Command, Arg, ArgGroup) for constructing CLIs dynamically at runtime.
  • Automatic --help/-h and --version/-V generation with colored, terminal-width-aware formatting.
  • Structured, typo-correcting error messages (e.g. suggesting the right subcommand when one is misspelled).
  • Companion crates for shell completions (clap_complete, clap_complete_nushell) and man-page generation (clap_mangen).

Common Use Cases

  • Parsing flags, options, and positional arguments for a Rust CLI binary.
  • Building multi-level subcommand trees (e.g. git-style tool remote add).
  • Validating and converting argument values (paths, enums, numbers) via typed value parsers.
  • Generating shell completion scripts and man pages as part of a release pipeline.

Under The Hood

Architecture: The public clap crate (src/lib.rs, 110 lines) is a thin facade that re-exports everything from clap_builder and, behind the derive feature flag, re-exports the Parser/Args/Subcommand/ValueEnum proc-macros from clap_derive. The real engine lives in clap_builder/src, organized into four layers: builder/ (Command, Arg, ArgGroup, ArgAction, ValueParser — the user-facing construction API, with command.rs and arg.rs each around 5,300 lines), parser/ (parser.rs at 1,685 lines plus validator.rs and matches/ — walks argv against the built Command tree and produces ArgMatches), output/ (help.rs, help_template.rs, usage.rs — renders --help/usage strings from the same Command definition), and error/ (kind.rs, context.rs, format.rs — structured, typed errors with contextual suggestions). Two supporting workspace members, clap_lex (a low-level argv tokenizer) and clap_derive (the proc-macro crate), sit alongside clap_complete/clap_complete_nushell (shell-completion generators) and clap_mangen (man-page generation), all consuming the same Command metadata so completions and docs never drift from the parser itself.

Tech Stack: Pure Rust, workspace-based ([workspace] members in Cargo.toml), MSRV 1.85 on the 2024 edition. The core dependency chain is clap -> clap_builder (default-features = false, version-pinned with =) -> optionally clap_derive behind the derive feature; clap_derive in turn depends on proc-macro2, syn, and quote for macro expansion. Dev-dependencies favor snapshot/golden testing (trycmd, snapbox with the term-svg feature) plus trybuild for compile-fail tests and automod for auto-registering test modules. The workspace Cargo.toml also carries an unusually large, individually-toggled [workspace.lints.clippy] block.

Code Quality: 135 Rust files under tests/ cover both the builder and derive APIs, backed by trycmd/snapbox snapshot tests that assert exact --help and error output byte-for-byte. clap_builder/src/builder/debug_asserts.rs runs invariant checks (e.g. conflicting arg definitions) in debug builds only, surfacing misconfigured CLIs immediately without adding runtime cost in release builds. The crate is #![forbid(unsafe_code)] and #![warn(missing_docs)]; roughly 183 .unwrap() calls remain in non-test builder source, which is reasonable given most guard internal invariants already covered by debug_asserts, but worth flagging for anyone auditing panic surface in a public library.

API Design: clap ships two parallel, equally-supported entry points — a #[derive(Parser)] macro for the common case (a plain struct becomes a full CLI with zero manual wiring) and a Command/Arg builder for dynamic/runtime-constructed CLIs — both funnelling into the same engine so behavior never diverges between them. Documentation is unusually thorough for a Rust crate: src/lib.rs embeds a live, always-current example via include_str!("../examples/demo.rs"), and dedicated _tutorial, _derive::_tutorial, _cookbook, _concepts, and _faq doc modules (gated behind an unstable-doc feature) ship a full manual alongside the API reference on docs.rs.

Used by 49 apps in this directory

Rust
86%
Other

Arroyo

Data Engineering · Analytics

5,005

A distributed stream processing engine written in Rust that lets you write SQL to run stateful, real-time computations over data streams with subsecond results.

View details
86
Repo Health
74
Technical
62
Dependency
Built with
Rust86%
Updated 1 weeks ago
TypeScript
49%
AGPL 3.0

BrowserOS

Browser · AI Assistants

13,248

The open-source agentic Chromium browser with native AI agents, MCP server, and visual workflow automation — your data never leaves your machine.

View details
87
Repo Health
82
Technical
69
Dependency
Built with
TypeScript49%
Rust22%
Python16%
Updated today
Rust
54%
Other

Cameleer

AI Agents

23

A local-first desktop workspace for managing AI agents in an enterprise-style workflow — agent directory, Kanban task tracking, workspace chat, and a full runtime/audit log of agent actions and tool approvals.

View details
48
Repo Health
65
Technical
76
Dependency
Built with
Rust54%
JavaScript24%
TypeScript15%
Updated 4 weeks ago
TypeScript
55%
Other

Cap

Team Chat · Video Conferencing

20,986

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
65
Dependency
Built with
TypeScript55%
Rust40%
Updated yesterday
Rust
95%
MIT

claw-code

AI Agents · AI Code Assistants

195,087

A Rust-built CLI agent harness for Claude AI with persistent sessions, MCP tool integration, plugin hooks, and multi-provider support — designed to run autonomous coding workflows without human babysitting.

View details
71
Repo Health
71
Technical
77
Dependency
Built with
Rust95%
Updated 3 days ago
C++
69%
Apache 2.0

ClickHouse

Databases · Analytics · Data Engineering

49,325

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
68
Dependency
Built with
C++69%
Python13%
Updated today
Swift
64%
GPL 3.0

cmux

Developer Tools · AI Development

26,221

A native, Ghostty-based macOS terminal with vertical tabs, agent-aware notifications, and a scriptable browser built for running many parallel AI coding agent sessions instead of juggling tmux panes.

View details
84
Repo Health
81
Technical
72
Dependency
Built with
Swift64%
Rust14%
Updated today
Go
32%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

11,247

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
Go32%
Rust31%
C21%
Updated today
TypeScript
75%
Apache 2.0

Fern

Developer Tools

3,761

Fern turns a single OpenAPI, AsyncAPI, or Protobuf definition into type-safe SDKs for nine languages and a hosted API documentation site, all from one CLI and one source of truth.

View details
90
Repo Health
86
Technical
67
Dependency
Built with
TypeScript75%
Updated today

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