rust-patterns

Refactor Rust code to idiomatic patterns with anyhow and thiserror.

Updated May 9, 2026
One-click install
npx skills add https://github.com/RambleRainbow/jd --skill rust-patterns-ramblerainbow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-patterns
Source: https://github.com/RambleRainbow/jd/tree/main/.claude/skills/rust-patterns
Command: npx skills add https://github.com/RambleRainbow/jd --skill rust-patterns-ramblerainbow

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves the common pain points of writing non-idiomatic Rust code that triggers avoidable borrow checker errors, runtime panics from improper error handling, and unmaintainable module structures, enabling developers to fully leverage Rust's compile-time safety and performance guarantees without steep trial and error.

Core Features & Use Cases

  • Idiomatic Pattern Library: Provides vetted, community-aligned templates for ownership and borrowing, error handling with anyhow and thiserror, enum state modeling, trait-based abstraction, and safe concurrency.
  • Code Quality Guardrails: Includes explicit anti-pattern examples, tooling guidance (cargo clippy, fmt, audit), and unsafe code usage rules to prevent common bugs and security vulnerabilities.
  • Use Case: When onboarding a new developer to a Rust codebase or refactoring legacy Rust code with frequent panic points and messy domain organization, use this Skill to standardize error handling, restructure modules by business domain, and eliminate unnecessary clones and unwrap() calls.

Quick Start

Use the rust-patterns skill to refactor your existing Rust application's error handling to replace all unwrap() calls with proper Result propagation using anyhow, and restructure your src directory to organize modules by business domain instead of file type.

Frequently Asked Questions about rust-patterns

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

FAQPage Schema
How do I fix avoidable borrow checker errors in Rust?

Fix borrow checker errors by applying idiomatic Rust ownership and borrowing rules to restructure data access. This eliminates non-idiomatic patterns, ensuring compile-time safety guarantees without unnecessary clones.

What is the best way to handle errors in Rust without causing runtime panics?

The best way to handle errors is replacing unwrap() calls with structured Result propagation using anyhow and thiserror. This eliminates runtime panics by enforcing safe error handling patterns.

How do I refactor a legacy Rust codebase to organize modules by business domain?

Refactor legacy Rust code by restructuring the src directory to organize modules by business domain instead of file type. This eliminates unmaintainable module structures and standardizes domain organization.

When do I need safe concurrency primitives in Rust?

You need safe concurrency primitives when implementing parallel execution to prevent data races. Utilizing vetted community-aligned templates ensures safe concurrent operations without triggering runtime panics.

Does this approach support exhaustive enum pattern matching in Rust?

Yes, exhaustive enum pattern matching is fully supported for robust state modeling. It enforces compile-time checks to handle all possible enum variants, preventing unhandled state bugs.

What are the limitations of using unsafe code in idiomatic Rust?

Using unsafe code bypasses compile-time safety guarantees, so it requires strict usage rules to prevent security vulnerabilities. Explicit anti-pattern guidance and tooling like cargo clippy must be applied.