Agentic Rust
The conventional wisdom says Rust is too hard to be worth it. Agentic coding turns that wisdom inside out.
The compiler is a verifier the agent can iterate against
When an AI writes Python, “does it run?” is a weak signal: plenty of broken programs run fine until they hit the one input that breaks them, in production. When an AI writes Rust, the compiler answers a much stronger question: is this memory-safe, type-correct, and free of data races? It answers before the program ever runs, with a precise explanation of any “no.”
That makes the loop tight and self-correcting:
generate →
cargo check→ read the error → fix → repeat
The borrow checker that frustrated a generation of humans is the ideal collaborator for a machine: it converts “looks right” into “is right,” automatically, every iteration. The agent doesn’t get bored, and the compiler doesn’t get fooled.
Where LLMs slip, and how to catch them
Agents are strong at Rust’s syntax and weak in the same places humans are. Watch for:
- Lifetimes & borrows. Models will sprinkle
.clone()to dodge the borrow checker, or add random lifetime annotations that spiral. The fix is structural: pass&T, restructure ownership, or useRc/Arcdeliberately, not reflexively. unwrap()everywhere. LLMs reach for.unwrap()to make code compile. Deny it:#![deny(clippy::unwrap_used)]forces real error handling with?.- Async pitfalls. Holding a non-
Sendvalue across an.await, or a lock across an await point, produces errors agents struggle to untangle. Give them runnable examples of the pattern you want. - Non-idiomatic code. Syntactically valid but un-Rustlike: manual loops instead of iterators,
matchwhere?belongs. Clippy catches most of it.
Tooling that tightens the loop
Point your agent at these and let them do the verifying:
cargo check: fast type/borrow checking with no codegen; the agent’s primary feedback.clippy: idiom and correctness lints; run with-D warningsto make them load-bearing.rust-analyzer: real-time types and diagnostics for context.- Tests: an executable spec the agent iterates against.
cargo testis the oracle. - Type-driven development: write the signatures first; agents fill bodies well when the types pin down the shape.
The ten-year bet
Here’s the thesis this whole site is built on: as agents get better, a language’s syntactic difficulty stops being a tax and becomes a moat. The hard part of Rust, satisfying a strict compiler, is exactly the part an agent automates. What’s left is what you actually wanted: software that’s fast, correct, and safe by construction.
Easy languages move difficulty downstream, into production bugs that are expensive to find. Rust moves it upstream, into a compiler that an agent can satisfy for free. Over ten years, we’re betting that trade looks better every single year.
A war story from this site’s own build
Everything above is theory until the compiler enforces it on you. While an AI agent was building this very site, the first big deploy failed in CI with an error almost nobody sees coming: queries overflow the depth limit!. The skill-tree page composed dozens of typed Leptos views inside each other, and under the release profile (aggressive optimization plus link-time optimization) rustc’s type-layout machinery blew past its recursion budget computing the page’s hydration future. The debug build had compiled fine all along.
The fix was one idiom, applied at every collection boundary: erase mapped views with .into_any(), which boxes them and flattens the generic depth. Forty boxed list items cost nothing; the lesson cost a failed deploy. It is on this page because it is exactly the loop this site teaches: the compiler said no, the error named the real constraint, and the fix made the design better. The full incident, like every other one, is in the repo’s build log; the commit history is part of the lesson.