beta

Rust CLI Tool Rules

Rules

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

2003/23/2026

Version 1

Published

Initial version

Created 3/23/2026

Initial version — no previous version to compare

CLAUDE.md
# 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