Home › Rust › Rust CLI CLAUDE.md

Rust CLI CLAUDE.md

CLAUDE.md for Rust command-line tools built with clap, anyhow and thiserror.

Claude Code (CLAUDE.md)Rust

How to use

Save this as CLAUDE.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

CLAUDE.mdDownload  
# CLAUDE.md — Rust CLI

## Commands
- `cargo build` · `cargo test` · `cargo clippy --all-targets -- -D warnings` · `cargo fmt`

## Conventions
- CLI args with `clap` derive. Binary in `src/main.rs` stays tiny; logic in `src/lib.rs` modules so it's testable.
- Errors: `thiserror` for library error enums, `anyhow` with `.context("...")` in the binary.
- No `unwrap()`/`expect()` outside tests and truly impossible cases (comment why).
- Prefer borrowing (`&str`, `&[T]`) in function params; clone only when ownership is needed.
- Output for humans on stdout, diagnostics on stderr; support `--json` for machine output.
- Integration tests in `tests/` using `assert_cmd`.

## Before finishing
- fmt + clippy clean with zero warnings, tests green.

Related rules

AWS CDK (TypeScript) CLAUDE.md

CLAUDE.md for AWS CDK v2 apps in TypeScript: constructs, least-privilege grants, snapshot tests, and safe deploys.

Claude Code (CLAUDE.md)AWS CDK

Bun runtime CLAUDE.md

CLAUDE.md for TypeScript projects on Bun 1.2+: bun test, Bun.serve, built-in SQLite/Postgres, and bundling.

Claude Code (CLAUDE.md)Bun

Claude Agent SDK CLAUDE.md

CLAUDE.md for building agents with the Claude Agent SDK (Python/TypeScript): options, tools, permissions, and hooks.

Claude Code (CLAUDE.md)LLM apps & agents

Code reviewer subagent (Claude Code)

A Claude Code subagent definition that reviews the current diff for bugs, security, and tests, reporting by severity.

Claude Code (CLAUDE.md)Agent workflows

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.