본문으로 건너뛰기
cccskills
무료GitHub에 공개

clap-scaffolder

Generate Clap-based Rust CLI applications with derive macros, subcommands, and modern Rust patterns. Creates production-ready Rust CLI with proper cargo structure.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md6.1 KB
  • README.md2.0 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Clap Scaffolder

Generate a complete Clap CLI application with Rust, derive macros, and best practices.

Capabilities

  • Generate Rust-based Clap CLI projects using derive macros
  • Create subcommand hierarchies with nested enums
  • Set up argument parsing with type validation
  • Configure shell completion generation
  • Implement colored output with anyhow error handling
  • Set up cargo workspace and build configurations

Usage

Invoke this skill when you need to:

  • Bootstrap a new CLI application using Clap
  • Create a Rust CLI with type-safe argument parsing
  • Leverage derive macros for declarative command definitions
  • Build fast, native cross-platform binaries

Inputs

ParameterTypeRequiredDescription
projectNamestringYesName of the CLI project (kebab-case)
descriptionstringYesShort description of the CLI
commandsarrayNoList of commands to scaffold
deriveFeaturesarrayNoClap derive features to enable
colorOutputbooleanNoEnable colored output (default: true)

Command Structure

{
  "commands": [
    {
      "name": "run",
      "description": "Run the application",
      "args": [
        { "name": "target", "help": "Target to run", "required": true }
      ],
      "options": [
        { "long": "watch", "short": "w", "help": "Watch for changes" },
        { "long": "port", "short": "p", "value_name": "PORT", "default": "3000" }
      ]
    }
  ]
}

Output Structure

<projectName>/
├── Cargo.toml
├── Cargo.lock
├── README.md
├── .gitignore
├── src/
│   ├── main.rs              # Entry point
│   ├── cli.rs               # Clap definitions
│   ├── commands/
│   │   ├── mod.rs           # Command exports
│   │   └── <command>.rs     # Individual commands
│   ├── config.rs            # Configuration
│   └── error.rs             # Error types
├── tests/
│   └── cli.rs               # CLI integration tests
└── completions/
    ├── _<projectName>       # Zsh completions
    ├── <projectName>.bash   # Bash completions
    └── <projectName>.fish   # Fish completions

Generated Code Patterns

CLI Definition (src/cli.rs)

use clap::{Parser, Subcommand, Args};

#[derive(Parser)]
#[command(name = "<projectName>")]
#[command(author, version, about, long_about = None)]
pub struct Cli {
    /// Enable verbose output
    #[arg(short, long, global = true)]
    pub verbose: bool,

    /// Configuration file path
    #[arg(short, long, global = true)]
    pub config: Option<PathBuf>,

    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand)]
pub enum Commands {
    /// Run the application
    Run(RunArgs),
    /// Build the project
    Build(BuildArgs),
    /// Generate shell completions
    Completions {
        /// Shell to generate completions for
        #[arg(value_enum)]
        shell: clap_complete::Shell,
    },
}

#[derive(Args)]
pub struct RunArgs {
    /// Target to run
    pub target: String,

    /// Watch for changes
    #[arg(short, long)]
    pub watch: bool,

    /// Port to use
    #[arg(short, long, default_value = "3000")]
    pub port: u16,
}

Main Entry (src/main.rs)

use anyhow::Result;
use clap::Parser;
use colored::Colorize;

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

use cli::{Cli, Commands};

fn main() -> Result<()> {
    let cli = Cli::parse();

    // Setup logging based on verbosity
    if cli.verbose {
        env_logger::Builder::from_env(
            env_logger::Env::default().default_filter_or("debug")
        ).init();
    }

    match cli.command {
        Commands::Run(args) => commands::run::execute(args)?,
        Commands::Build(args) => commands::build::execute(args)?,
        Commands::Completions { shell } => {
            generate_completions(shell);
        }
    }

    Ok(())
}

Command Implementation

use anyhow::Result;
use colored::Colorize;

use crate::cli::RunArgs;

pub fn execute(args: RunArgs) -> Result<()> {
    println!("{} Running target: {}", "→".blue(), args.target.green());

    if args.watch {
        println!("{} Watch mode enabled", "!".yellow());
    }

    println!("{} Listening on port {}", "✓".green(), args.port);

    Ok(())
}

Dependencies

[package]
name = "<projectName>"
version = "0.1.0"
edition = "2021"

[dependencies]
clap = { version = "4.4", features = ["derive", "env"] }
clap_complete = "4.4"
anyhow = "1.0"
thiserror = "1.0"
colored = "2.0"
env_logger = "0.10"
log = "0.4"

[dev-dependencies]
assert_cmd = "2.0"
predicates = "3.0"

Workflow

  1. Validate inputs - Check project name, commands structure
  2. Create directory structure - Set up Rust project layout
  3. Generate Cargo.toml - Configure dependencies and metadata
  4. Create CLI definition - Clap derive structs
  5. Generate commands - Individual command modules
  6. Create utilities - Config, error handling
  7. Generate completions - Shell completion scripts
  8. Set up tests - CLI integration tests

Best Practices Applied

  • Derive macros for declarative definitions
  • Anyhow for error handling
  • Colored output for user feedback
  • Environment variable support
  • Built-in completion generation
  • Cross-platform compatible

References

Target Processes

  • cli-application-bootstrap
  • argument-parser-setup
  • shell-completion-scripts

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Provide implementations of advanced data structures

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a5c-ai/babysitter1.9천2026년 9월 17일 업데이트

Fresh adversarial code review with binary PASS/FAIL verdicts, evidence citations, and anchoring bias prevention via fresh reviewer spawning.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a5c-ai/babysitter1.9천2026년 9월 17일 업데이트

WASM-based instant code transforms for simple tasks, achieving 352x speedup over LLM inference with zero cost.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a5c-ai/babysitter1.9천2026년 9월 17일 업데이트

Coordinate Crew (persistent) and Polecat (transient) agents using Gas Town's hook-based work distribution and GUPP principle.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a5c-ai/babysitter1.9천2026년 9월 17일 업데이트

Generate visual representations of algorithm execution

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a5c-ai/babysitter1.9천2026년 9월 17일 업데이트

Hierarchical coordination and drift detection with frequent checkpoints, shared memory coherence validation, role specialization enforcement, and short task cycles.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a5c-ai/babysitter1.9천2026년 9월 17일 업데이트

a5c-ai의 스킬 모두 보기

이 스킬의 문제 신고