rust-cli

Standardize Rust CLI structure with clap derive, anyhow, tracing, and JSON output.

3|1|Updated Jan 24, 2026
One-click install
npx skills add https://github.com/tumf/skills --skill rust-cli
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-cli
Source: https://github.com/tumf/skills/tree/main/rust-cli
Command: npx skills add https://github.com/tumf/skills --skill rust-cli

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Building reliable Rust CLIs requires boilerplate for argument parsing, error handling, logging, output formats, and structured project layouts. This skill provides a proven blueprint to streamline CLI development and ensure consistent, production-grade ergonomics.

Core Features & Use Cases

  • Clap derive-based argument parsing with helpful, English --help texts.
  • Anyhow-based error handling and tracing-based diagnostics with logs directed to stderr.
  • JSON output mode with strict stdout/stderr separation for machine-readable results.
  • XDG-compliant filesystem layout guidance and cross-platform configuration strategies.
  • Pre-commit / pre-push hooks via prek to enforce formatting, linting, and test execution.
  • Integration tests scaffolding to validate CLI behavior across subcommands.

Quick Start

Scaffold a Rust CLI using clap derive, enable JSON output mode, and set up prek-based pre-commit/pre-push hooks.

Frequently Asked Questions about rust-cli

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Rust CLI project for maintainable error handling and logging?

Structure a Rust CLI project by standardizing on clap derive for argument parsing, anyhow for error handling, and tracing for diagnostics directed to stderr, ensuring clean separation from stdout JSON output for maintainable CLI ergonomics.

What is the best way to separate JSON output from logs in a Rust CLI?

The best way to separate JSON output in a Rust CLI is directing structured machine-readable JSON results to stdout via serde_json while routing all tracing-based diagnostic logs to stderr, ensuring strict separation for automated parsing.

How do I set up pre-commit and pre-push hooks for a Rust CLI?

Set up pre-commit and pre-push hooks for a Rust CLI using prek to enforce code formatting, linting, and test execution automatically, ensuring reliable releases and consistent project quality before code integration.

Does this Rust CLI approach support cross-platform configuration strategies?

Yes, this Rust CLI approach supports cross-platform configuration strategies by providing XDG-compliant filesystem layout guidance, ensuring consistent application behavior across different operating systems.

Why do I need strict stdout and stderr separation in CLI applications?

Strict stdout and stderr separation is needed in CLI applications to keep machine-readable JSON output unpolluted by tracing logs, allowing downstream tools to parse stdout safely while reserving stderr for human-readable diagnostics.

How do I scaffold integration tests for Rust CLI subcommands?

Scaffold integration tests for Rust CLI subcommands by validating command behavior across various inputs, ensuring argument parsing via clap derive and error handling via anyhow function reliably across the entire CLI interface.