beta

Rust CLI Development CLAUDE.md

Rules

Agent rules for Rust CLI applications with clap, tokio, and error handling patterns.

1903/26/2026

Version 1

Published

Initial version

Created 3/26/2026

Initial version — no previous version to compare

CLAUDE.md
# CLAUDE.md

## Project Context
Rust CLI application using clap for argument parsing, tokio for async, and anyhow for error handling.

## Code Style
- Use thiserror for library errors, anyhow for application errors
- Prefer Result<T, anyhow::Error> in application code
- Use clap derive macros for CLI arguments
- Follow Rust API Guidelines: https://rust-lang.github.io/api-guidelines/

## Patterns
- Builder pattern for complex structs
- From/Into implementations for type conversions
- Use tracing for structured logging (not println!)
- Prefer iterators over manual loops

## Error Handling
- Never use .unwrap() in library code
- Use .context("description") with anyhow
- Custom error types with thiserror for public APIs

## Testing
- cargo test before committing
- Integration tests in tests/ directory
- Use assert_cmd + predicates for CLI testing
- Snapshot testing with insta

## Dependencies
- cargo clippy -- -W clippy::all before committing
- cargo fmt always
- Minimize dependency count