rust-best-practices

Codify idiomatic Rust best practices from Apollo GraphQL's handbook.

5|1|Updated Feb 11, 2026
One-click install
npx skills add https://github.com/Tristan578/project-forge --skill rust-best-practices-tristan578
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-best-practices
Source: https://github.com/Tristan578/project-forge/tree/main/.agents/skills/rust-best-practices
Command: npx skills add https://github.com/Tristan578/project-forge --skill rust-best-practices-tristan578

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a consolidated, practical guide to writing idiomatic Rust code by synthesizing best practices from Apollo GraphQL's Rust Best Practices Handbook, helping teams improve safety, readability, and performance.

Core Features & Use Cases

  • Borrowing vs cloning guidance to reduce unnecessary allocations and improve clarity.
  • Robust error handling patterns with Result and error propagation strategies.
  • Performance-focused tips, linting hygiene, testing strategies, and thorough documentation practices.
  • Real-world guidance for building reliable Rust libraries and binaries, including testing and code review workflows.

Quick Start

Review the Rust Best Practices guide and apply its rules to write and review idiomatic Rust code.

Frequently Asked Questions about rust-best-practices

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

FAQPage Schema
What are the best practices for deciding between borrowing and cloning in Rust?

Idiomatic Rust borrowing reduces unnecessary allocations by using references instead of cloning data, improving clarity and performance. Clone only when ownership is explicitly required, preventing ambiguous lifetimes and ensuring safe memory management.

How do I handle errors properly in Rust using Result?

Robust error handling in Rust uses the Result type for explicit error propagation. Returning Result instead of panicking ensures safe error management, allowing failures to bubble up cleanly to the caller for reliable, maintainable code.

How do I configure Clippy lints for idiomatic Rust code reviews?

Idiomatic Rust linting hygiene uses Clippy to enforce performance and readability rules during code reviews. Applying Clippy lints identifies common anti-patterns, ensuring your codebase follows established conventions and maintains strict quality control.

What is the best way to structure Rust tests and documentation?

Idiomatic Rust testing and documentation strategies involve writing thorough tests and documenting public APIs to improve reliability. Structuring tests alongside code and providing clear documentation ensures maintainable Rust libraries and binaries.

Can I apply these Rust best practices to refactor existing projects?

Yes, idiomatic Rust best practices apply directly to refactoring existing Rust projects. Applying rules for ownership, borrowing, and error handling during refactors improves code safety, readability, and overall performance without requiring a rewrite.