rust-impl-clap-cli

Installation
SKILL.md

rust-impl-clap-cli

The clap 4.x CLI parser skill: how to scaffold a command-line interface with the derive macro API, when to drop to the builder API for dynamic CLIs, how to model subcommands and reusable argument groups, how to wire custom value parsers and environment-variable fallbacks, and how to ship shell completions through clap_complete.

Cross-references: [[rust-impl-cargo-project]] (declaring the derive feature in Cargo.toml), [[rust-syntax-traits]] (derive macros, FromStr for custom parsers), [[rust-impl-error-handling]] (returning anyhow::Result from main), [[rust-impl-testing]] (try_parse_from for unit-testable CLI logic).


When to use this skill

  • User runs cargo add clap and asks which features to enable.
  • User writes #[derive(Parser)] on a struct and gets a "trait Parser is not implemented" error.
  • User wants nested subcommands (e.g. git remote add ...) and is unsure whether to use Subcommand, Args, or both.
  • User has a non-String argument type and the parser refuses to compile.
  • User wants --config to fall back to an environment variable, or to a typed default value.
  • User wants to generate Bash, Zsh, Fish, PowerShell, or Elvish completions.
  • User builds a CLI whose argument set is decided at runtime and asks how to skip the derive API.
  • User asks how to unit-test argument parsing without invoking the binary.
Installs
2
GitHub Stars
1
First Seen
May 24, 2026