power-rust
Power Rust
Five prompt patterns, distilled from a six-month benchmark of LLM-generated Rust (habr.com/ru/articles/1035712), that statistically reduce the bugs models keep producing in Rust code. Apply them when you ask a coding model for Rust, and when you review AI-generated Rust before it lands.
These rules are written for any coding agent — Claude Code, Codex, Cursor, Copilot — and for the humans driving them.
1. Pin crate versions and async runtime in the prompt
Do not write "write an HTTP handler". Instead write:
write an HTTP handler, axum 0.7, tokio 1.35, sqlx 0.7 with postgres
The model knows multiple incompatible APIs for popular crates. Without a version anchor it averages across them, which produces e.g. parking_lot::Mutex held across .await, or sqlx API calls that match no real release. In the source benchmark this single change dropped Mutex-category errors from 46% to 19%.
Always state in the prompt: