clap-rust-cli-organization

Installation
SKILL.md

Organize a Rust CLI app with clap

Use when designing or refactoring the structure of a Rust CLI application built with clap.

Mental model

  • Treat the CLI surface as an interface layer over application logic, not as the place where all behavior lives.
  • Keep argument parsing, command dispatch, and business logic separate so the CLI remains readable and testable.
  • Design for growth: a simple one-command binary can live in one file, but subcommands and shared config should move into clear modules before the crate becomes hard to navigate.

Project shape

  • Keep main.rs small: startup, tracing/logging init, command parsing, and top-level error handling only.
  • Put the clap parser definitions in a dedicated cli module once the binary has more than a few flags or subcommands.
  • Put command execution in per-command modules so adding a subcommand does not turn one file into a giant match block.
  • Keep domain logic in library-style modules that do not depend on clap types directly.

clap structure

Installs
1
First Seen
Apr 12, 2026
clap-rust-cli-organization — alexandretrotel/skills