rust-best-practices

Codify idiomatic Rust practices for borrowing, error handling, and testing.

Updated Apr 14, 2026
One-click install
npx skills add https://github.com/novolei/if2Ai --skill rust-best-practices-novolei
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-best-practices
Source: https://github.com/novolei/if2Ai/tree/main/.cursor/skills/rust-best-practices
Command: npx skills add https://github.com/novolei/if2Ai --skill rust-best-practices-novolei

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps Rust developers write idiomatic, safe, and high-performance code by following Apollo GraphQL's Rust Best Practices Handbook.

Core Features & Use Cases

  • Guidance on borrowing and ownership to avoid unnecessary clones and ensure safety.
  • Patterns for robust error handling with Result, thiserror, and anyhow, plus testing and documentation considerations.
  • Performance-minded practices, linting guidance, and maintainable coding standards for Rust projects.
  • Use Case: when starting a new Rust project, performing code reviews, or refactoring existing Rust code to improve quality.

Quick Start

Consult the Rust Best Practices guide while coding to align with idiomatic patterns.

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 borrowing and ownership in Rust to avoid unnecessary clones?

Idiomatic Rust best practices recommend borrowing over cloning by default to ensure safety and high performance, reserving clones for cases where true ownership transfer is required.

How do I structure error handling in Rust using Result, thiserror, and anyhow?

Rust error handling best practices suggest using the Result type to structure robust error management, leveraging thiserror for library-specific custom errors and anyhow for application-level error aggregation across projects.

How do I align my team on consistent Rust coding conventions and linting rules?

To align teams on Rust coding conventions, adopt a best practices handbook that outlines tooling recommendations, Clippy linting configurations, and idiomatic patterns to enforce consistency across all projects and libraries.

What is the best way to refactor existing Rust code to be more idiomatic and efficient?

The best way to refactor Rust code for idiomatic efficiency involves applying established best practices for ownership, Result-based error handling, and Clippy linting to improve code quality and maintainability.

When should I use thiserror versus anyhow for error handling in my Rust project?

Use thiserror to define custom, library-specific error types in Rust, whereas anyhow is best suited for application-level error handling where you need to aggregate and manage multiple error types dynamically across libraries.