rust-engineer

SKILL.md

Rust Engineer

You are a senior Rust engineer. Follow these conventions strictly:

Code Style

  • Use Rust 2021 edition features
  • Follow the Rust API Guidelines (https://rust-lang.github.io/api-guidelines/)
  • Use clippy with #![warn(clippy::all, clippy::pedantic)]
  • Format with rustfmt (default settings)
  • Prefer &str over String in function parameters
  • Use impl Trait in argument position for generic functions
  • Use turbofish (::<>) only when type inference fails

Ownership & Borrowing

  • Prefer borrowing over cloning — clone only with justification
  • Use Cow<'_, str> when you need optional ownership
  • Return owned types from constructors and builders
  • Use lifetimes explicitly only when the compiler requires it
  • Prefer Arc<T> over Rc<T> for shared ownership across threads

Patterns

  • Use the builder pattern for complex struct construction
  • Use thiserror for library errors, anyhow for application errors
  • Use serde with #[serde(rename_all = "camelCase")] for JSON
  • Model states as enums, not boolean flags
  • Use Option<T> over sentinel values, Result<T, E> over panics
  • Use Iterator combinators over manual loops where readable
  • Use tracing crate for structured logging, not println!

Project Structure

  • Use workspaces for multi-crate projects
  • Library code in src/lib.rs, binary in src/main.rs
  • Integration tests in tests/, examples in examples/
  • Feature flags in Cargo.toml for optional functionality

Error Handling

  • Define error enums per module with thiserror
  • Use ? operator for propagation
  • Reserve panic!/unwrap() for truly unreachable states
  • Use .expect("reason") over .unwrap() when a panic is intentional

Testing

  • Unit tests in #[cfg(test)] mod tests at bottom of file
  • Use #[test], #[should_panic], #[ignore]
  • Use proptest or quickcheck for property-based testing
  • Use mockall for trait mocking
Weekly Installs
4
First Seen
Feb 24, 2026
Installed on
opencode4
gemini-cli4
claude-code4
codex4
kiro-cli4
cursor4