Skip to content
Skillpedia
General coding33k Β· #8795

rust-cli-builder

What it does

This skill helps your AI agent build command-line tools in Rust. It is for developers creating a new CLI or extending one with subcommands, config files and clean output.

When to use it

  • βœ“When you want to create a new Rust command-line tool from scratch.
  • βœ“When you need to add subcommands to an existing Rust CLI.
  • βœ“When you want config file loading or colored output in a Rust tool.

Skill link

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/rust-cli-builder/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/rust-cli-builder/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œBuild a Rust CLI that converts CSV files to JSON, with a config file for default options.”

5 new skills a week. 1 minute to read.

How it works

The agent first explores any existing project, then asks questions about commands, input and output formats, and how the tool will be shared. After that it writes the code with clap, error handling and config support.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Rust CLI Tool Builder

When to use

Use this skill when you need to:

  • Scaffold a new Rust CLI tool from scratch with clap
  • Add subcommands to an existing CLI application
  • Implement config file loading (TOML/JSON/YAML)
  • Set up proper error handling with anyhow/thiserror
  • Add colored and formatted terminal output
  • Structure a CLI project for distribution via cargo install or GitHub releases

Phase 1: Explore (Plan Mode)

Enter plan mode. Before writing any code, explore the existing project:

If extending an existing project

  • Find Cargo.toml and check current dependencies (clap version, serde, tokio, etc.)
  • Locate the CLI entry point (src/main.rs or src/cli.rs)
  • Check if clap is using derive macros or builder pattern
  • Identify existing subcommand structure
  • Look for existing error types, config structs, and output formatting
  • Check if there's a src/lib.rs separating library logic from CLI

If starting from scratch

  • Check the workspace for any existing Rust projects or workspace Cargo.toml
  • Look for a .cargo/config.toml with custom settings
  • Check for rust-toolchain.toml to know the target Rust edition

Phase 2: Interview (AskUserQuestion)

Use AskUserQuestion to clarify requirements. Ask in rounds.

Round 1: Tool purpose and commands

Question: "What kind of CLI tool are you building?"
Header: "Tool type"
Options:
  - "Single command (like ripgrep, curl)" β€” One main action with flags and arguments
  - "Multi-command (like git, cargo)" β€” Multiple subcommands under one binary
  - "Interactive REPL (like psql)" β€” Persistent session with a prompt loop
  - "Pipeline tool (like jq, sed)" β€” Reads stdin, transforms, writes stdout

Question: "What will the tool operate on?"
Header: "Input"
Options:
  - "Files/directories" β€” Read, process, or generate files
  - "Network/API" β€” HTTP requests, TCP connections, API calls
  - "System resources" β€” Processes, hardware info, OS config
  - "Data streams (stdin/stdout)" β€” Pipe-friendly text/binary processing

Round 2: Subcommands (if multi-command)

Question: "Describe the subcommands you need (e.g., 'init', 'build', 'deploy')"
Header: "Commands"
Options:
  - "2-3 subcommands (I'll describe them)" β€” Small focused tool
  - "4-8 subcommands with groups" β€” Medium tool, may need command groups
  - "I have a rough list, help me design the API" β€” Collaborative command design

Round 3: Configuration and output

Question: "How should the tool be configured?"
Header: "Config"
Options:
  - "CLI flags only (Recommended)" β€” All config via command-line arguments
  - "Config file (TOML)" β€” Load defaults from ~/.config/toolname/config.toml
  - "Config file + CLI overrides" β€” Config file for defaults, flags override specific values
  - "Environment variables + flags" β€” Env vars for secrets, flags for everything else

Question: "What output format does the tool need?"
Header: "Output"
Options:
  - "Human-readable (colored text)" β€” Pretty terminal output with colors and formatting
  - "Machine-readable (JSON)" β€” Structured output for piping to other tools
  - "Both (--format flag)" β€” Default human, --json or --format=json for machines
  - "Minimal (exit codes only)" β€” Success/failure via exit code, errors to stderr

Round 4: Async and error handling

Question: "Does the tool need async operations?"
Header: "Async"
Options:
  - "No β€” synchronous is fine (Recommended)" β€” File I/O, computation, simple operations
  - "Yes β€” tokio (network I/O)" β€” HTTP requests, concurrent connections, async file I/O
  - "Yes β€” tokio multi-threaded" β€” Heavy parallelism, multiple concurrent tasks

Question: "How should errors be presented to users?"
Header: "Errors"
Options:
  - "Simple messages (anyhow) (Recommended)" β€” Human-readable error chains, good for most CLIs
  - "Typed errors (thiserror)" β€” Custom error enum with specific variants for each failure
  - "Both (thiserror for lib, anyhow for bin)" β€” Library code is typed, CLI wraps with anyhow

Phase 3: Plan (ExitPlanMode)

Write a concrete implementation plan covering:

  1. Project structure β€” Cargo.toml dependencies, src/ file layout
  2. CLI definition β€” clap derive structs for all commands, args, and flags
  3. Config loading β€” config file format and merge strategy with CLI args
  4. Core logic β€” main functions for each subcommand, separated from CLI layer
  5. Error types β€” error enum or anyhow usage, user-facing error messages
  6. Output formatting β€”
FAQ

Does it ask questions before coding?

Yes, the skill plans with you first, covering commands, formats and distribution.

Which argument library does it use?

It uses clap for parsing command-line arguments.

How can the tool be shared?

The skill covers distribution through cargo install or GitHub releases.

Details

Original description by the author

Plan and build production-ready Rust CLI tools using clap for argument parsing, with subcommands, config file support, colored output, and proper error handling. Uses interview-driven planning to clarify commands, input/output formats, and distribution strategy before writing any code.

repo: davila7/claude-code-templates

Popularity

GitHub stars
33k
Ranking position
#8795
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills