rust

Enforces formatting, linting, and testing rules for Rust workspace development.

Updated Dec 7, 2025
One-click install
npx skills add https://github.com/harlanljones/dotfiles --skill rust-harlanljones
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rust
Source: https://github.com/harlanljones/dotfiles/tree/main/dot_hermes/skills/software-development/rust
Command: npx skills add https://github.com/harlanljones/dotfiles --skill rust-harlanljones

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Rust projects with Cargo workspaces often accumulate inconsistent formatting, clippy warnings, fragile error handling, and parsers that break when external formats change. This Skill provides always-on rules that keep Rust code structured, lint-clean, and resilient across library and binary crates. ## Core Features & Use Cases - Quality Gates: Requires cargo fmt, zero-warning clippy across all targets, and green cargo test runs before any change is considered done. - Workspace Conventions: Centralizes dependencies in the root Cargo.toml with workspace inheritance and shared lint configuration forbidding unsafe code. - Robust Patterns: Prescribes thiserror for libraries, anyhow for binaries, serde defaults for evolving external formats, and RefCell-based accumulation for git2 diff callbacks. - Use Case: When building a CLI tool that parses JSONL transcripts and inspects git repositories, apply these rules to keep parsing tolerant of upstream format changes and avoid borrow-checker pitfalls in libgit2 callbacks. ## Quick Start Use the rust skill to review my Cargo workspace crate and make it pass fmt, clippy, and tests.

Frequently Asked Questions about rust

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure dependencies in a Rust Cargo workspace?▼

Declare all dependencies in the root Cargo.toml under [workspace.dependencies] and reference them in member crates with name.workspace = true. Never pin versions inside member crates, and put test-only crates like serde_json under [dev-dependencies].

Should I use thiserror or anyhow for Rust error handling?▼

Use thiserror with typed error enums and #[from] conversions in libraries, and anyhow::Result with the ? operator in binaries. Never expose anyhow in a library's public API or hand-roll a bespoke error enum in main.

How do I fix E0499 borrow errors in git2 diff callbacks?▼

git2's diff.foreach takes four closures that share mutable state, causing E0499 with plain captures. Wrap the shared accumulator in a RefCell, call borrow_mut() inside each closure, and extract the result with into_inner() afterward.

How do I make serde parsing tolerant of format changes?▼

Derive Serialize and Deserialize on every boundary struct and add #[serde(default)] to optional numeric fields. Skip unknown input rather than erroring, and pin exact expected values in fixture-based tests to catch format drift.

Why does clippy warn on if let Some with from_utf8?▼

Writing std::str::from_utf8(...).ok() inside if let Some triggers the clippy match_result_ok lint. Match the Result directly with if let Ok(x) = from_utf8(...) instead to keep clippy at zero warnings.