Menu

Post image 1
Post image 2
1 / 2
0

CLAUDE.md for Rust: 13 Rules That Make AI Write Safe, Idiomatic Systems Code

DEV Community·Olivia Craft·26 days ago
#Y4uZEJkC
#rust#claudemd#ai#claudeai#fullscreen#error
Reading 0:00
15s threshold

Ask Claude Code to "add a small async cache to this crate" and the default output looks fine: a tokio::spawn , an Arc<Mutex<HashMap<...>>> , a .unwrap() on the lock, a ? that flattens five error types into Box<dyn Error> . It compiles. It passes cargo test . Then it deadlocks across .await , panics on the first miss in prod, and the error reads Custom { kind: Other, error: "..." } . The borrow checker stops a lot, but it doesn't stop unwrap() , fire-and-forget tasks, or unsafe blocks with no // SAFETY: comment. A CLAUDE.md next to Cargo.toml is the cheapest leverage you have on a Rust codebase. Get the full CLAUDE.md Rules Pack — oliviacraftlat.gumroad.com/l/skdgt . The 13 rules below are a free preview. 1. Own at the API boundary, borrow inside The most common AI mistake in Rust public APIs is leaking lifetimes: pub fn parse<'a>(s: &'a str) -> Doc<'a> when the caller wants an owned Doc .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More