rust-patterns

Teach production-grade Rust patterns for ownership, Tokio, Axum, SQLx, and error handling.

Updated Mar 5, 2026
One-click install
npx skills add https://github.com/yoogoc/xcraw --skill rust-patterns-yoogoc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-patterns
Source: https://github.com/yoogoc/xcraw/tree/main/.opencode/skills/rust-patterns
Command: npx skills add https://github.com/yoogoc/xcraw --skill rust-patterns-yoogoc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Production-grade Rust patterns are challenging to assemble correctly; this guide consolidates patterns and mental models to improve reliability and maintainability.

Core Features & Use Cases

  • Ownership and borrowing mental models for safe code
  • Tokio-based async patterns and runtime best practices
  • Axum web server patterns, routing, and state management
  • Database access patterns with SQLx, Diesel, and SeaORM
  • Error handling with thiserror and anyhow
  • CLI tooling patterns with Clap v4 derive API
  • WebAssembly and Python bindings via PyO3

Quick Start

Apply these patterns in your Rust project to improve ownership, error handling, and async design.

Frequently Asked Questions about rust-patterns

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

FAQPage Schema
How do I handle errors in Rust production code using thiserror and anyhow?

Rust error handling in production code uses thiserror for custom library errors and anyhow for application-level error aggregation. This pattern provides structured error propagation, improving reliability and maintainability across async systems and web services.

What's the best way to structure Axum web server routing and state management in Rust?

Axum web server patterns structure routing and state management by sharing application state through extractors. This approach ensures type-safe request handling and maintainable endpoint definitions for production-grade Rust web services.

How does ownership and borrowing work when building reliable Rust systems?

Ownership and borrowing in Rust systems enforce memory safety without garbage collection by binding value lifetimes to scopes. Mastering this mental model prevents data races and ensures safe concurrent access in complex async applications.

Can I use SQLx and Tokio together for async database access in Rust?

Yes, SQLx and Tokio work together for async database access in Rust. SQLx executes queries on the Tokio runtime, providing non-blocking database operations that integrate seamlessly with Axum web services and other async Rust patterns.

Does this guide cover building Python bindings for Rust code using PyO3?

Yes, this guide covers building Python bindings for Rust code using PyO3. It provides practical usage examples and structured patterns for exposing Rust libraries to Python, extending Rust's reliable performance into Python ecosystems.

When should I use Clap v4 derive API for Rust CLI tooling patterns?

Use Clap v4 derive API for Rust CLI tooling when you need type-safe argument parsing with automatic help generation. This pattern structures command-line interfaces declaratively, reducing boilerplate and improving user experience for production CLI tools.