
Domain Cli
Apply Rust CLI domain rules—clap parsing, config precedence, exit codes, and stdout/stderr separation—while building terminal tools.
Overview
domain-cli is an agent skill for the Build phase that enforces Rust CLI domain constraints—clap ergonomics, config precedence, and pipe-safe I/O—for solo builders writing terminal tools.
Install
npx skills add https://github.com/zhanghandong/rust-skills --skill domain-cliWhat is this skill?
- Domain constraints table mapping ergonomics, config precedence, and exit codes to Rust patterns
- Critical rules: errors on stderr, data on stdout, and non-zero exit on failure
- Configuration priority CLI > env > file > defaults with clap and figment/config guidance
- Interruptibility and signal-handling expectations for scriptable CLIs
- Layer-3 domain skill that traces down to type-driven argument structs (m05-type-driven)
Adoption & trust: 669 installs on skills.sh; 1.2k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your agent keeps generating Rust CLIs that break pipes, mishandle config overrides, or exit zero on errors.
Who is it for?
Indie devs building Rust CLIs or TUIs who want agent output to match real terminal and scripting expectations.
Skip if: Non-Rust projects, pure library crates with no binary surface, or GUIs where terminal constraints do not apply.
When should I use this skill?
Building or refactoring a Rust CLI or TUI crate and you need domain rules for arguments, config, exits, and user-facing errors.
What do I get? / Deliverables
You get a CLI design that follows stderr/stdout separation, layered config, and proper exit codes ready to implement with clap and Result-based main.
- CLI architecture decisions aligned to domain constraints
- Implementation guidance for clap structs and layered configuration
Recommended Skills
Journey fit
Build is where solo makers implement Rust binaries and TUI/CLI crates; this skill constrains that implementation phase. Backend fits Rust CLI crates and library-style command structure even when the artifact is a user-facing binary.
How it compares
Domain constraint cheat sheet for Rust CLIs, not a full ratatui tutorial or a generic bash scripting skill.
Common Questions / FAQ
Who is domain-cli for?
Solo builders working in Rust on command-line or TUI apps who want agents to respect clap, config layering, and script-friendly I/O rules.
When should I use domain-cli?
During Build while scaffolding argument parsing, config loading, progress UI, or signal handling in a Cargo binary project.
Is domain-cli safe to install?
It is procedural guidance only; check the Security Audits panel on this Prism page before installing skills from external repos into your agent.
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 |