rust
Instructions for working in Rust codebases
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Instructions for working in Rust codebases
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
ask questions until shared understanding is reached
summarize the current session into a concise, well-structured document for the purpose of persisting important information across agent sessions
use for working with jj (jujutsu) version control system
invoked by the user to identify refactoring opportunities in the codebase
| name | rust |
| description | Instructions for working in Rust codebases |
Choose from these libraries if you need any of this functionality:
Prefer small functions, if a function is more than a screen height, try to split it up. If match arms get big, extract them into functions.
Unless there is a clear benefit, performance or otherwise, always prefer immutable variables.
Prefer organizing the code such that any structs have a new() -> Result<Self> method that takes any necessary arguments for construction and returns either Ok(self) or an error (thiserror custom error, or an anyhow error depending on where it is). Avoid interior mutability if possible.
If possible, always use iterators, maps and filters instead of for loops. Also for working with Options and Results.
Prefer &str and Cow<str> over String, .to_string(). Use references over calling clone if possible.
Always prefer proper error handling or at least an .expect() with a good description.
If a component needs to be shared or needs multiple implementations, create a trait with the public methods, then for each implementation create a struct with it's config and internal state, but then for impl Trait for Struct implement the methods such that they call a free-standing module-internal fn that just takes the minimum parameters and can be tested in isolation.
After any major code interventions, always run the following:
cargo fmt
cargo clippy --all-targets