Skip to main content
rulesSource-backedReview first Safety · Privacy

Rust Expert - CLAUDE.md Rules for Claude Code

Transform Claude into a Rust specialist with deep knowledge of ownership, borrowing, error handling, async, and production systems patterns.

by jaso0n0818·added 2026-06-16·
HarnessClaude Code
Review first review before installing

Open the source and read safety notes before installing.

Privacy notes

  • Rules reference API keys and database credentials; store them in environment variables or a secrets manager, never in committed source files.

Schema details

Install type
copy
Reading time
4 min
Difficulty score
85
Troubleshooting
Yes
Breaking changes
No
Full copyable content
You are an expert Rust developer with deep knowledge of ownership, borrowing,
traits, and safe systems programming.

## Core Philosophy

- Let the borrow checker guide API design; prefer owned values at boundaries
- Use `Result` and `Option` explicitly; avoid `unwrap` in production paths
- Model invariants with types (`enum`, newtypes) instead of comments alone
- Keep `unsafe` tiny, documented, and reviewed — default to safe Rust

## Ownership & Borrowing

```rust
pub fn summarize_titles(books: &[Book]) -> Vec<String> {
    books.iter().map(|b| b.title.clone()).collect()
}
```

- Prefer `&str` over `String` in arguments when borrowing suffices
- Return owned data (`String`, `Vec`) when callers need to store it
- Use lifetimes only when the compiler cannot infer relationships

## Error Handling

- Library code returns `Result<T, E>`; applications may log and exit at the top
- Use `thiserror` for library errors, `anyhow` sparingly at app boundaries
- Propagate with `?`; add context with `.context("...")` where it helps operators

## Traits & APIs

- Implement `Debug`, `Clone`, `PartialEq` deliberately — not by default
- Prefer trait bounds (`impl Trait`, `T: Trait`) over trait objects unless dynamic dispatch is required
- Keep public APIs minimal; use modules to hide internals

## Concurrency

- Share state with `Arc<Mutex<_>>` or channels; avoid unbounded shared mutation
- Use `tokio` for async I/O; do not block the runtime on CPU or sync I/O
- Prefer structured tasks with cancellation tokens for long-running work

## Testing

- Unit tests in `#[cfg(test)]` modules beside the code they cover
- Integration tests in `tests/` for public API behavior
- Property tests (`proptest`) for parsers and invariants when helpful

About this resource

Usage

Add this rule set to your project's CLAUDE.md to configure Claude as a Rust expert. It covers ownership, error handling, traits, and async patterns — grounded in the The Rust Programming Language and standard library documentation.

Sources

Source citations

Add this badge to your README

Show that Rust Expert - CLAUDE.md Rules for Claude Code is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/rules/rust-expert.svg)](https://heyclau.de/entry/rules/rust-expert)

How it compares

Rust Expert - CLAUDE.md Rules for Claude Code side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

FieldRust Expert - CLAUDE.md Rules for Claude Code

Transform Claude into a Rust specialist with deep knowledge of ownership, borrowing, error handling, async, and production systems patterns.

Open dossier
.NET and C# Expert - CLAUDE.md Rules for Claude Code

A CLAUDE.md rule set that turns Claude into a senior .NET reviewer aligned with current Microsoft guidance across ASP.NET Core, Entity Framework Core, asynchronous programming, typed options, and automated testing.

Open dossier
Django Expert - CLAUDE.md Rules for Claude Code

Transform Claude into a Django specialist with deep knowledge of models, views, DRF serializers, migrations, middleware, and production deployment patterns.

Open dossier
Go Golang Expert - CLAUDE.md Rules for Claude Code

Transform Claude into a Go language expert with deep knowledge of concurrency, performance optimization, and idiomatic Go

Open dossier
Trust
Install riskReview firstReview firstReview firstReview first
Notes Safety · Privacy Safety · Privacy Safety · Privacy Safety · Privacy ·
Categoryrulesrulesrulesrules
Sourcesource-backedsource-backedsource-backedsource-backed
Authorjaso0n0818jaso0n0818jaso0n0818JSONbored
Added2026-06-162026-06-132026-06-142025-09-16
Platforms
Claude Code
Claude Code
Claude Code
Claude Code
Source repo
Safety notes— missing— missing— missing— missing
Privacy notesRules reference API keys and database credentials; store them in environment variables or a secrets manager, never in committed source files.Rules reference dotnet user-secrets and Azure Key Vault for credential storage; secrets must never be committed to source control or hard-coded in application settings files.Rules reference SECRET_KEY, database credentials, and API tokens; store them in environment variables, never in settings.py committed to git.— missing
Prerequisites— none listed— none listed— none listed— none listed
Install
Config
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.