# Rust Expert

> Rust domain expertise for Cargo builds, borrow checker errors, lifetimes, ownership, traits, generics, Result/error handling, async/concurrency, message passing, testing, mocks through traits, and idiomatic review. Use for Rust implementation, debugging, testing, build resolution, performance-sensitive refactoring, and ownership design tasks. Use when this capability is needed.

- Skill: `tomevault-io/rust-expert-3` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/rust-expert-3`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/rust-expert-3/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/rust-expert-3

---


# Rust Expert Skill

You have invoked the Rust Expert Skill. This skill contains actionable checklists and constraints for Rust software engineering tasks.

## Quick Actions & Checklists

### Build & Borrow Checker Resolution
- **Rule 1:** DO NOT use `.clone()` as a first resort to fix borrow checker errors.
- **Rule 2:** Analyze lifetime bounds. If `&'a` is missing, trace the struct instantiation.
- **Rule 3:** If the compiler suggests a trait bound (e.g., `T: Default`), evaluate if the bound makes architectural sense before blindly applying it.
- **Rule 4:** Use `cargo check` incrementally to verify fixes without paying the full `cargo build` cost.

### Coding Patterns
- **Error Handling:** Use the `?` operator and `Result` universally. Prefer libraries like `anyhow` for applications or `thiserror` for libraries.
- **Enums over Booleans:** Use `enum` for state machines instead of multiple boolean flags.
- **Concurrency:** Prefer message passing (`mpsc`) or `RwLock` over `Mutex` where applicable.
> **Need Deep Knowledge?** Read `$SKILL_DIR/references/rust-patterns.md`.

### Testing & Verification
- **Unit Tests:** Keep them in the same file inside a `#[cfg(test)]` module.
- **Integration Tests:** Place them in the `tests/` directory at the project root.
- **Mocks:** Use traits for dependency injection to allow mocking in tests.
> **Need Deep Knowledge?** Read `$SKILL_DIR/references/rust-testing.md`.

## Instructions for the Agent
1. Based on the arguments provided (e.g., "build", "testing", "review"), apply the relevant checklist above.
2. For deeper Rust patterns or testing guidance, use the `Read` tool to fetch the relevant reference document from `$SKILL_DIR/references/`.

---
> Source: [Rianico/harness-zkx](https://github.com/Rianico/harness-zkx) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-23 -->

