beta

Rust CLI Tool Rules

Rules

CLAUDE.md for Rust CLI applications with clap, tokio, and error handling patterns.

1903/23/2026
markdown1 file
CLAUDE.md794 B

CLAUDE.md — Rust CLI

Commands

  • cargo build — build
  • cargo test — test
  • cargo clippy — lint
  • cargo fmt — format

Dependencies

  • clap — CLI argument parsing with derive
  • tokio — async runtime
  • anyhow — error handling in applications
  • thiserror — error types in libraries
  • serde + serde_json — serialization
  • tracing — structured logging

Code Style

  • Use anyhow::Result in application code
  • Use thiserror for library error types
  • Prefer iterators over manual loops
  • Use builder pattern for complex structs
  • Document public APIs with doc comments

Error Handling

  • Never use unwrap() in production code
  • Use ? operator for error propagation
  • Provide context with .context() from anyhow
  • Log errors at the boundary, not deep in the stack