standards-rust

Review Rust code for ownership, trait design, and error handling.

2|Updated Apr 10, 2024
One-click install
npx skills add https://github.com/gdurandvadas/dotfiles --skill standards-rust
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: standards-rust
Source: https://github.com/gdurandvadas/dotfiles/tree/main/config/opencode/skills/standards-rust
Command: npx skills add https://github.com/gdurandvadas/dotfiles --skill standards-rust

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Ensures Rust code and crate APIs are safe, idiomatic, and maintainable by providing concrete guidance on ownership, borrowing, trait design, error handling, generics, and project structure so that invalid states are prevented at compile time.

Core Features & Use Cases

  • Provides idiomatic patterns for ownership and borrowing, lifetime annotations, and smart pointer selection.
  • Recommends trait and generic design, static vs dynamic dispatch, and object safety considerations.
  • Defines error-handling strategies for libraries and applications with structured errors and propagation best practices.
  • Prescribes formatting, linting, and CI checks including rustfmt and clippy to enforce code quality.
  • Use cases: code reviews, API/crate design decisions, onboarding contributors, and preparing crates for publication.

Quick Start

Run a review of the provided Rust code and produce safety-first, idiomatic recommendations focused on ownership, lifetimes, trait design, error handling, and formatting.

Frequently Asked Questions about standards-rust

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

FAQPage Schema
How do I write idiomatic Rust code for safe and ergonomic APIs?

Idiomatic Rust code for safe APIs requires correct ownership, lifetime annotations, and strategic smart pointer selection to prevent invalid states at compile time. Concrete guidance on trait design and borrowing ensures maintainable, ergonomic library interfaces.

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

Error handling in a Rust library crate requires structured error types and propagation best practices using Result. Defining application versus library error strategies ensures errors are handled idiomatically without panicking.

How do I design traits and generics for static vs dynamic dispatch in Rust?

Trait and generic design in Rust involves choosing between static and dynamic dispatch while considering object safety. Proper trait bounds and ergonomic generics prevent invalid states and maintain compile-time safety.

Does this Rust code review guidance include rustfmt and clippy CI checks?

Rust code review guidance includes prescribing rustfmt formatting, clippy linting, and CI verification steps to enforce code quality. These checks ensure formatting and linting standards are met before crate publication.

When do I need lifetime annotations for ownership and borrowing in Rust?

Lifetime annotations for ownership and borrowing are needed when references have complex relationships that the compiler cannot infer automatically. Idiomatic patterns guide smart pointer selection and borrow correctness for safe code.

Can I use this for Rust crate design and onboarding contributors?

Rust crate design guidance applies to structuring library and application crates, defining APIs, and onboarding contributors. It provides concrete recommendations for project structure and preparing crates for publication.