skills/domain-cli/SKILL.md
Use when building CLI tools. Keywords: CLI, command line, terminal, clap, structopt, argument parsing, subcommand, interactive, TUI, ratatui, crossterm, indicatif, progress bar, colored output, shell completion, config file, environment variable, 命令行, 终端应用, 参数解析
npx skillsauth add actionbook/rust-skills domain-cliInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Layer 3: Domain Constraints
| 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 |
RULE: Errors to stderr, data to stdout
WHY: Pipeable output, scriptability
RUST: eprintln! for errors, println! for data
RULE: CLI args > env vars > config file > defaults
WHY: User expectation, override capability
RUST: Layered config with clap + figment/config
RULE: Return non-zero on any error
WHY: Script integration, automation
RUST: main() -> Result<(), Error> or explicit exit()
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
| Purpose | Crate | |---------|-------| | Argument parsing | clap | | Interactive prompts | dialoguer | | Progress bars | indicatif | | Colored output | colored | | Terminal UI | ratatui | | Terminal control | crossterm | | Console utilities | console |
| 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) |
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(())
}
| 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 |
| 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 |
| When | See | |------|-----| | Error handling | m06-error-handling | | Type-driven args | m05-type-driven | | Progress lifecycle | m12-lifecycle | | Async CLI | m07-concurrency |
development
CRITICAL: Use for ALL Rust questions including errors, design, and coding. HIGHEST PRIORITY for: 比较, 对比, compare, vs, versus, 区别, difference, 最佳实践, best practice, tokio vs, async-std vs, 比较 tokio, 比较 async, Triggers on: Rust, cargo, rustc, crate, Cargo.toml, 意图分析, 问题分析, 语义分析, analyze intent, question analysis, compile error, borrow error, lifetime error, ownership error, type error, trait error, value moved, cannot borrow, does not live long enough, mismatched types, not satisfied, E0382, E0597, E0277, E0308, E0499, E0502, E0596, async, await, Send, Sync, tokio, concurrency, error handling, 编译错误, compile error, 所有权, ownership, 借用, borrow, 生命周期, lifetime, 类型错误, type error, 异步, async, 并发, concurrency, 错误处理, error handling, 问题, problem, question, 怎么用, how to use, 如何, how to, 为什么, why, 什么是, what is, 帮我写, help me write, 实现, implement, 解释, explain
development
Internal maintenance support for checking and fixing generated Rust skill documentation references. Use only when explicitly invoked by /fix-skill-docs.
development
Internal command support for dynamic Rust crate skill management. Use only when explicitly invoked by /sync-crate-skills, /clean-crate-skills, or /update-crate-skill.
tools
Internal support skill for agent-browser CLI workflows used by rust-learner, docs-researcher, and crate-researcher. Use only when browser automation is explicitly required.