Skip to content
Development
Command

/scaffold-rust-cli

Generate production-ready Rust CLI application with modern architecture and comprehensive scaffolding

From plugin
claude-cmd
313180 skills180 commands

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/scaffold-rust-cli

Context preview

What this command does when you run it.

Generate production-ready Rust CLI application with modern architecture and comprehensive scaffolding

Command definition

scaffold-rust-cli.md
allowed-tools: Bash(cargo:*), Write, Read, Bash(mkdir:*), Bash(fd:*), Bash(rg:*), Bash(gdate:*)
name: "Scaffold Rust Cli"
description: "Generate production-ready Rust CLI application with modern architecture and comprehensive scaffolding"
author: "wcygan"
tags: ["scaffold","rust"]
version: "1.0.0"
created_at: "2025-07-14T00:00:00Z"
updated_at: "2025-07-14T00:00:00Z"

Context

  • Session ID: !`gdate +%s%N 2>/dev/null || date +%s%N 2>/dev/null || echo "$(date +%s)$(jot -r 1 100000 999999 2>/dev/null || shuf -i 100000-999999 -n 1 2>/dev/null || echo $RANDOM$RANDOM)"`
  • Target CLI name: $ARGUMENTS
  • Current directory: !`pwd`
  • Rust toolchain: !`rustc --version 2>/dev/null || echo "Rust not found - will provide installation guidance"`
  • Cargo version: !`cargo --version 2>/dev/null || echo "Cargo not found"`
  • Available disk space: !`df -h . | tail -1 | awk '{print $4}' 2>/dev/null || echo "Unknown"`
  • Git repository status: !`git status --porcelain 2>/dev/null | wc -l | tr -d ' ' || echo "0"` uncommitted changes

Your task

STEP 1: Initialize project structure and validate environment

TRY:

  • VERIFY Rust toolchain availability
  • CREATE new Cargo project: `cargo new $ARGUMENTS --bin`
  • INITIALIZE session state for tracking progress
  • VALIDATE project name follows Rust naming conventions
# Create session state file
echo '{
  "sessionId": "'$SESSION_ID'",
  "projectName": "'$ARGUMENTS'",
  "status": "initializing",
  "completedSteps": [],
  "dependencies": [],
  "features": []
}' > /tmp/scaffold-rust-cli-$SESSION_ID.json

IF Rust not available:

  • PROVIDE installation instructions for platform
  • SUGGEST rustup installation: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
  • EXIT with guidance for setup

STEP 2: Configure modern Cargo.toml with production-ready dependencies

**Core Dependencies Configuration:**

[package]
name = "$ARGUMENTS"
version = "0.1.0"
edition = "2021"
authors = ["Your Name <your.email@example.com>"]
description = "A modern CLI application"
license = "MIT OR Apache-2.0"
repository = "https://github.com/username/$ARGUMENTS"
readme = "README.md"
keywords = ["cli", "terminal", "command-line"]
categories = ["command-line-utilities"]

[dependencies]
# Core CLI framework with derive features
clap = { version = "4.5", features = ["derive", "env", "color", "suggestions"] }

# Error handling and logging
anyhow = "1.0"
thiserror = "1.0"
env_logger = "0.11"
log = "0.4"

# Terminal UI and styling
colored = "2.1"
indicatif = "0.17"
dialoguer = "0.11"
console = "0.15"

# Signal handling and graceful shutdown
ctrlc = "3.4"
signal-hook = "0.3"
tokio = { version = "1.37", features = ["full"] }

# Serialization and configuration
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.8"

# Filesystem and path utilities
dirs = "5.0"
walkdir = "2.5"

# User experience improvements
human-panic = "2.0"
is-terminal = "0.4"

[dev-dependencies]
# Testing framework
assert_cmd = "2.0"
predicates = "3.1"
tempfile = "3.10"
tokio-test = "0.4"

[[bin]]
name = "$ARGUMENTS"
path = "src/main.rs"

STEP 3: Create comprehensive project directory structure

# Navigate to project directory
cd $ARGUMENTS

# Create organized source structure
mkdir -p src/{cli,commands,config,error,utils}
mkdir -p tests/{integration,fixtures}
mkdir -p docs/examples
mkdir -p .github/workflows

# Create essential files
touch src/{main.rs,cli.rs,lib.rs}
touch src/commands/{mod.rs,init.rs,status.rs}
touch src/{config.rs,error.rs}
touch src/utils/{mod.rs,logging.rs,signals.rs}
touch tests/integration/{cli_tests.rs,command_tests.rs}
touch README.md CHANGELOG.md LICENSE

STEP 4: Implement main.rs with robust architecture

**Core Application Structure:**

use anyhow::Result;
use clap::Parser;
use std::process;

mod cli;
mod commands;
mod config;
mod error;
mod utils;

use cli::Cli;
use utils::{logging, signals};

#[tokio::main]
async fn main() {
    // Set up human-readable panic messages in production
    human_panic::setup_panic!();
    
    // Initialize logging early
    logging::init();
    
    // Set up graceful shutdown handling
    let shutdown_handler = signals::setup_shutdown_handler();
    
    // Parse CLI arguments
    let cli = Cli::parse();
    
    // Execute main application logic
    let result = tokio::select! {
        result = run_app(cli) => result,
        _ = shutdown_handler => {
            log::info!("Received shutdown signal, cleaning up...");
            Ok(())
        }
    };
    
    if let Err(err) = result {
        log::error!("Application error: {:?}", err);
        eprintln!("Error: {}", err);
        process::exit(1);
    }
}

async fn run_app(cli: Cli) -> Result<()> {
    log::debug!("Starting application with args: {:?}", cli);
    
    match cli.command {
        commands::Commands::Init(args) => commands::init::execute(args).await,
        commands::Commands::Status(args) => commands::status::execute(args).await,
    }
}

STEP 5: Implement CLI structure with clap derive patterns

**CLI Argument Parsing (src/cli.rs):**

use clap::{Parser, Subcommand};
use std::path::PathBuf;

#[derive(Parser)]
#[command(name = "$ARGUMENTS")]
#[command(about = "A modern CLI application", long_about = None)]
#[command(version, author)]
pub struct Cli {
    /// Enable verbose output (-v, -vv, -vvv)
    #[arg(short, long, action = clap::ArgAction::Count)]
    pub verbose: u8,
    
    /// Configuration file path
    #[arg(short, long, value_name = "FILE")]
    pub config: Option<PathBuf>,
    
    /// Disable colored output
    #[arg(long)]
    pub no_color: bool,
    
    /// Output format
    #[arg(long, value_enum, default_value_t = OutputFormat::Human)]
    pub format: OutputFormat,
    
    #[command(subcommand)]
    pub command: crate::commands::Commands,
}

#[derive(clap::ValueEnum, Clone, Debug)]
pub enum OutputFormat {
    Human,
    Json,
    Yaml,
}

STEP 6: Create modular command structure wit

Read more
Ships withclaude-cmd

A lightweight (~46kB) and comprehensive CLI tool for managing Claude commands, configurations, and workflows.

Get the whole plugin