🎯

domain-cli

🎯Skill

from actionbook/rust-skills

VibeIndex|
What it does

Builds robust, user-friendly command-line interfaces with argument parsing, configuration management, and interactive terminal experiences in Rust.

πŸ“¦

Part of

actionbook/rust-skills(35 items)

domain-cli

Installation

Quick InstallInstall with npx
npx skills add ZhangHanDong/rust-skills
CargoRun with Cargo (Rust)
cargo install cowork
git cloneClone repository
git clone https://github.com/ZhangHanDong/rust-skills.git
Add MarketplaceAdd marketplace to Claude Code
/plugin marketplace add ZhangHanDong/rust-skills
πŸ“– Extracted from docs: actionbook/rust-skills
11Installs
-
AddedFeb 4, 2026

Skill Details

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, ε‘½δ»€θ‘Œ, η»ˆη«―εΊ”η”¨, ε‚ζ•°θ§£ζž"

Overview

# 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,

},

}

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 |

More from this repository10

πŸͺ
actionbook-rust-skillsπŸͺMarketplace

Comprehensive Rust development assistant with meta-question routing, coding guidelines, version queries, and ecosystem support

🎯
coding-guidelines🎯Skill

Provides comprehensive Rust coding guidelines covering naming conventions, best practices, error handling, memory management, concurrency, and code style recommendations.

🎯
rust-refactor-helper🎯Skill

Performs safe Rust refactoring by analyzing symbol references, dependencies, and potential impacts using Language Server Protocol (LSP) operations.

🎯
m09-domain🎯Skill

Guides domain modeling in Rust by helping identify entities, value objects, aggregates, and their ownership patterns with domain-driven design principles.

🎯
m05-type-driven🎯Skill

Enforces compile-time type safety by preventing invalid states through type-level design techniques like newtypes, type states, and phantom types.

🎯
m13-domain-error🎯Skill

Designs comprehensive domain error handling strategies with categorization, recovery mechanisms, and contextual error management for different audiences.

🎯
rust-learner🎯Skill

Retrieves and provides comprehensive Rust and crate information, including versions, features, documentation, and changelogs from authoritative sources.

🎯
m11-ecosystem🎯Skill

Guides Rust developers in selecting, integrating, and managing ecosystem dependencies with best practices and strategic decision-making.

🎯
m02-resource🎯Skill

Guides developers in selecting the right smart pointer and resource management strategy based on ownership, thread safety, and design constraints.

🎯
rust-call-graph🎯Skill

Generates and visualizes Rust function call graphs using LSP, revealing function relationships and call hierarchies.