
Domain Cli
Ship a pipeable Rust CLI with clap-derived args, layered config precedence, and script-friendly exit codes.
Overview
domain-cli is an agent skill for the Build phase that encodes Rust CLI domain rules—I/O separation, config precedence, exit codes, and signals—for clap-based command-line tools.
Install
npx skills add https://github.com/actionbook/rust-skills --skill domain-cliWhat is this skill?
- Maps five CLI domain rules to explicit Rust design constraints (help/errors, config precedence, exit codes, stdout/stder
- Enforces stderr for errors and stdout for data so scripts and pipes stay reliable
- Documents CLI args > env > config file > defaults with clap plus figment/config-style layering
- Recommends main() -> Result<(), Error> or explicit non-zero exits for automation
- Targets Cargo.toml / Rust CLI stacks (clap, structopt, ratatui, indicatif)
- 5 domain rules mapped to Rust design constraints
Adoption & trust: 864 installs on skills.sh; 1.2k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are building a Rust CLI and the agent keeps mixing errors into stdout, wrong config overrides, or success exit codes on failure.
Who is it for?
Indie builders shipping Rust CLIs, internal tools, or TUIs who want agent edits to respect clap and automation conventions.
Skip if: Non-Rust CLIs, one-off shell scripts without a Cargo project, or teams that only need marketing copy without terminal ergonomics.
When should I use this skill?
Building CLI tools in Rust when Cargo.toml or CLI keywords (clap, structopt, TUI, argument parsing) appear in context.
What do I get? / Deliverables
After applying domain-cli, the agent structures the CLI around stderr/stdout rules, layered config, and non-zero exits consistent with script integration.
- CLI code aligned with stdout/stderr and exit-code rules
- Layered config loading pattern
- Signal/interrupt handling notes where required
Recommended Skills
Journey fit
CLI binaries are core product surface during the Build phase—constraints here shape how the tool is structured before Ship review. Backend-oriented Rust crates and binaries fit the backend shelf better than generic agent-tooling or docs-only work.
How it compares
Domain constraint cheat sheet for Rust CLIs—not a full project scaffold generator or generic debugging playbook.
Common Questions / FAQ
Who is domain-cli for?
Solo and indie developers using AI coding agents on Rust repositories with CLI or TUI crates who need consistent terminal UX and exit semantics.
When should I use domain-cli?
During Build when parsing arguments, loading config, handling errors, or adding progress/UI to a Rust binary—especially before Ship testing of script integrations.
Is domain-cli safe to install?
It is guidance-only procedural knowledge with no shell or network requirements by itself; review the Security Audits panel on this Prism page before installing any skill from the repo.
SKILL.md
READMESKILL.md - Domain Cli
# CLI Domain > **Layer 3: Domain Constraints** ## Domain Constraints → Design Implications | Domain Rule | Design Constraint | Rust Implication | |-------------|-------------------|------------------| | User ergonomics | Clear help, errors | clap derive macros | | Config precedence | CLI > env > file | Layered config loading | | Exit codes | Non-zero on error | Proper Result handling | | Stdout/stderr | Data vs errors | eprintln! for errors | | Interruptible | Handle Ctrl+C | Signal handling | --- ## Critical Constraints ### User Communication ``` RULE: Errors to stderr, data to stdout WHY: Pipeable output, scriptability RUST: eprintln! for errors, println! for data ``` ### Configuration Priority ``` RULE: CLI args > env vars > config file > defaults WHY: User expectation, override capability RUST: Layered config with clap + figment/config ``` ### Exit Codes ``` RULE: Return non-zero on any error WHY: Script integration, automation RUST: main() -> Result<(), Error> or explicit exit() ``` --- ## Trace Down ↓ From constraints to design (Layer 2): ``` "Need argument parsing" ↓ m05-type-driven: Derive structs for args ↓ clap: #[derive(Parser)] "Need config layering" ↓ m09-domain: Config as domain object ↓ figment/config: Layer sources "Need progress display" ↓ m12-lifecycle: Progress bar as RAII ↓ indicatif: ProgressBar ``` --- ## Key Crates | Purpose | Crate | |---------|-------| | Argument parsing | clap | | Interactive prompts | dialoguer | | Progress bars | indicatif | | Colored output | colored | | Terminal UI | ratatui | | Terminal control | crossterm | | Console utilities | console | ## Design Patterns | Pattern | Purpose | Implementation | |---------|---------|----------------| | Args struct | Type-safe args | `#[derive(Parser)]` | | Subcommands | Command hierarchy | `#[derive(Subcommand)]` | | Config layers | Override precedence | CLI > env > file | | Progress | User feedback | `ProgressBar::new(len)` | ## Code Pattern: CLI Structure ```rust use clap::{Parser, Subcommand}; #[derive(Parser)] #[command(name = "myapp", about = "My CLI tool")] struct Cli { /// Enable verbose output #[arg(short, long)] verbose: bool, #[command(subcommand)] command: Commands, } #[derive(Subcommand)] enum Commands { /// Initialize a new project Init { name: String }, /// Run the application Run { #[arg(short, long)] port: Option<u16>, }, } fn main() -> anyhow::Result<()> { let cli = Cli::parse(); match cli.command { Commands::Init { name } => init_project(&name)?, Commands::Run { port } => run_server(port.unwrap_or(8080))?, } Ok(()) } ``` --- ## Common Mistakes | Mistake | Domain Violation | Fix | |---------|-----------------|-----| | Errors to stdout | Breaks piping | eprintln! | | No help text | Poor UX | #[arg(help = "...")] | | Panic on error | Bad exit code | Result + proper handling | | No progress for long ops | User uncertainty | indicatif | --- ## Trace to Layer 1 | Constraint | Layer 2 Pattern | Layer 1 Implementation | |------------|-----------------|------------------------| | Type-safe args | Derive macros | clap Parser | | Error handling | Result propagation | anyhow + exit codes | | User feedback | Progress RAII | indicatif ProgressBar | | Config precedence | Builder pattern | Layered sources | --- ## Related Skills | When | See | |------|-----| | Error handling | m06-error-handling | | Type-driven args | m05-type-driven | | Progress lifecycle | m12-lifecycle | | Async CLI | m07-concurrency |