BeautifulRust Pushes AI Coding Agents to Write Safer Rust by 27%
BeautifulRust bundles three Agent Skills and a tested clippy config that push coding agents toward idiomatic Rust across Claude, Codex, Copilot, Cursor, and Gemini.
Takeaways
- BeautifulRust ships three Agent Skills plus a clippy config for idiomatic Rust.
- Works with Claude Code, Codex, Copilot, Cursor, and Gemini CLI via standard Agent Skills format.
- Skills cover writing new Rust, reviewing existing code with rule citations, and porting from C/C++/Python/Go/JS.
- Benchmark: Codex CLI jumped from 62% to 89%, Claude Code from 85% to 94%.
- Clippy config flags unwrap, undocumented unsafe, bool params, lossy casts, missing Errors/Panics docs.
- MIT licensed; install via
npx skills add morganlinton/BeautifulRust.
BeautifulRust is an open source toolkit that packages three standard Agent Skills with an opinionated Clippy policy. It targets code that compiles but still exposes brittle APIs, undocumented failure modes, avoidable panics, or patterns carried over from another language.
Agent Skills are folders of instructions and supporting files that compatible coding tools can load for specific tasks. BeautifulRust uses that format to guide generation, review, and language ports, while Clippy enforces the machine-checkable rules during local development and CI.
Four layers of Rust guidance
The repository separates its guidance by task, allowing an agent to load the relevant material without placing the entire rule set in every prompt.
| Component | Purpose | Typical trigger |
|---|---|---|
rust-best-practices |
Guides ownership, API design, errors, panics, concurrency, unsafe code, FFI, and performance. | Writing or changing Rust |
rust-review |
Produces a prioritized review with rule citations and targeted fixes. | Auditing an existing crate or patch |
rust-port |
Ports C, C++, Python, Go, or JavaScript around Rust types and APIs. | Cross-language migration |
lints/ |
Configures Clippy to reject selected violations. | Local checks and CI |
A semver example exposes the defaults
The repository demonstrates the effect on a small semantic-version parser. The baseline and skill-assisted outputs both worked, but they made different API, documentation, and panic-safety decisions.
| Decision | Without the skill | With the skill |
|---|---|---|
| Struct fields | Public | Private |
| Failure documentation | No # Errors section |
Failure modes documented |
| Documentation examples | Used unwrap() |
Safe to copy without introducing an avoidable panic |
Private fields preserve room to change internal representation, error sections describe the contract of fallible functions, and panic-aware examples keep unsafe habits out of downstream code. The Rust compiler cannot enforce all of those design choices, which makes them suitable targets for agent instructions and review rules.