rust-best-practices

Apply idiomatic Rust practices for safety, readability, and performance.

63|2|Updated Mar 23, 2026
One-click install
npx skills add https://github.com/stolinski/s-stack --skill rust-best-practices-stolinski
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-best-practices
Source: https://github.com/stolinski/s-stack/tree/main/skills/rust-best-practices
Command: npx skills add https://github.com/stolinski/s-stack --skill rust-best-practices-stolinski

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Writing Rust code that is safe, readable, and maintainable is hard without a consistent set of idioms. This skill provides a structured guide based on Apollo GraphQL's Rust Best Practices Handbook to help developers adopt proven patterns and reduce common Rust pitfalls.

Core Features & Use Cases

  • Ownership & borrowing guidance: minimize unnecessary clones, prefer references, and apply the Type State pattern where appropriate.
  • Error handling discipline: use Result, minimize panics in library code, and leverage thiserror/anyhow appropriately.
  • Quality tooling & maintenance: linting with Clippy, tests and documentation best practices, and idiomatic generics and dispatch.
  • Use Case: a Rust library that needs safe error propagation and clear public API surfaces, with strong docs and tests.

Quick Start

Review your codebase and start refactoring for idiomatic ownership, robust error handling, and clear documentation.

Frequently Asked Questions about rust-best-practices

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

FAQPage Schema
How do I write idiomatic Rust code for better safety and readability?

Idiomatic Rust code improves safety and readability by applying patterns like minimizing unnecessary clones, preferring references, and using Result for robust error handling. It aligns with Apollo GraphQL's Rust Best Practices Handbook to reduce common pitfalls.

What is the best way to handle errors in Rust library code?

The best way to handle errors in Rust library code is to use Result for safe error propagation and minimize panics. You should leverage thiserror for library APIs and anyhow for application-level error management to ensure robust and clear error handling.

How do I minimize unnecessary cloning when managing ownership in Rust?

Minimize unnecessary cloning in Rust by preferring references over owned types and applying the Type State pattern where appropriate. This ownership and borrowing guidance ensures safe memory management without sacrificing performance.

Can I use Clippy for linting and maintaining Rust 1.70+ projects?

Yes, you can use Clippy for linting Rust 1.70+ projects. Quality tooling and maintenance tasks include running Clippy to enforce idiomatic generics, static dispatch, and best practices for tests and documentation within Cargo workflows.

When should I use thiserror vs anyhow for Rust error handling?

Use thiserror for defining custom error types in library code to ensure clear public API surfaces, and use anyhow for application-level error handling where you need flexible error aggregation. This distinction maintains robust error propagation.