rust-patterns

Enforce idiomatic Rust conventions for ownership, error handling, and concurrency.

1|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/xxih/ai-harness-zh --skill rust-patterns-xxih
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-patterns
Source: https://github.com/xxih/ai-harness-zh/tree/main/references/translations/everything-claude-code/docs/zh-CN/skills/rust-patterns
Command: npx skills add https://github.com/xxih/ai-harness-zh --skill rust-patterns-xxih

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Many developers struggle with Rust’s unique ownership model, error handling, and concurrency patterns, leading to unsafe code, bugs, and sub‑optimal performance.

Core Features & Use Cases

  • Ownership & Borrowing Guidance – Shows when to pass references versus taking ownership.
  • Error‑Handling Standards – Recommends thiserror for libraries and anyhow for applications.
  • Concurrency Best Practices – Demonstrates safe async patterns with Tokio, channels, and Arc<Mutex<T>>.
  • Module & Crate Organization – Offers a domain‑driven layout to keep public APIs minimal.
  • Use Cases – Ideal for code reviews, refactoring existing crates, and designing new Rust projects.

Quick Start

Ask the rust‑patterns skill to analyze a Rust code snippet and provide idiomatic improvement suggestions.

Frequently Asked Questions about rust-patterns

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

FAQPage Schema
What is the best way to handle errors in a Rust library versus an application?

The best way to handle Rust errors is using `thiserror` for libraries to define custom error types and `anyhow` for applications to manage dynamic error contexts simply.

How do I structure Rust modules and crates for a minimal public API?

Structure Rust crates using a domain-driven layout to keep public APIs minimal, organizing modules by business domain to encapsulate internal implementation details safely.

When should I pass references versus taking ownership in Rust?

Pass references in Rust when the function only needs to read data without taking ownership, and take ownership when the value must be moved or consumed for safe memory management.

How do I write safe async Rust code with Tokio and Arc Mutex?

Write safe async Rust code by using `Tokio` for runtime scheduling, channels for message passing, and `Arc<Mutex<T>>` to safely share mutable state across concurrent threads.

Can I use this tool to review and refactor existing Rust code snippets?

Yes, you can use it to analyze Rust code snippets during code reviews and refactoring, providing concrete examples and idiomatic improvement suggestions to prevent unsafe patterns.