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

Django CLAUDE.md

CLAUDE.md for Django 5 projects with DRF, pytest-django and PostgreSQL.

Claude Code (CLAUDE.md)Django

Go backend CLAUDE.md

CLAUDE.md for idiomatic Go HTTP services using the standard library, sqlc and table-driven tests.

Claude Code (CLAUDE.md)Go

Next.js CLAUDE.md

A CLAUDE.md for Claude Code working in a Next.js + Prisma + Tailwind codebase.

Claude Code (CLAUDE.md)Next.js

Python data & ML CLAUDE.md

CLAUDE.md for data science / ML repos using pandas or polars, notebooks, and reproducible pipelines.

Claude Code (CLAUDE.md)Python Data & ML

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.