rust

Guides production-grade Rust development with idiomatic design, error handling, and concurrency practices.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing production Rust involves many decisions—editions, MSRV, error handling, async patterns, unsafe contracts, and verification matrices—that are easy to get wrong. This Skill provides structured, opinionated guidance so Rust code changes follow idiomatic conventions and repository-consistent practices. ## Core Features & Use Cases - Idiomatic Rust Guidance: Enforces naming conventions, module organization, trait design, and domain newtypes across applications, libraries, CLIs, and services. - Error Handling & Safety Rules: Defines when to use thiserror vs anyhow, how to handle panics and assertions, and how to document unsafe and FFI contracts. - Async & Backend Stack Support: Covers Tokio task lifecycle, cancellation safety, and provides a dedicated reference for Axum, Tower, and SQLx service development. - Use Case: When adding a new endpoint to an Axum service backed by SQLx, the Skill directs you to keep handlers thin, let the application operation own the transaction, use parameterized queries, and verify with the repository's fmt, Clippy, and test matrix. ## Quick Start Ask the assistant to review or implement a change in your Rust project, for example: "Add a paginated list endpoint to my Axum service following production Rust practices."

Frequently Asked Questions about rust

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

FAQPage Schema
How do I structure error handling in a Rust application?

Use typed errors derived with thiserror where callers need to inspect or recover from failures, and anyhow with context at I/O boundaries in executables. Never use unwrap or expect for recoverable conditions in request paths, and convert infrastructure errors before they cross transport boundaries.

What is a good default stack for a new Rust backend service?

A common starter stack is Axum with Tower for HTTP, Tokio as the single async runtime, SQLx for SQL-first database access, serde for DTOs, and tracing for structured logging. Prefer the repository's existing choices like Actix, Diesel, or SeaORM when they are already in use.

How do I handle Tokio task cancellation safely?

Treat cancellation as possible at every .await point and give long-lived tasks an explicit owner and lifecycle policy. Dropping a JoinHandle detaches rather than cancels the task, so retain handles, propagate shutdown signals, and verify that dropping a future in select! or timeout is safe.

When should I use unsafe in Rust and how do I document it?

Use unsafe only with a concrete payoff, minimize and encapsulate it, and document public unsafe APIs with a # Safety contract plus a local // SAFETY: comment per block. A safe API must check preconditions in every build since debug_assert cannot uphold memory-safety contracts.

Should I commit Cargo.lock for my Rust project?

Commit Cargo.lock for applications and shipped workspace artifacts; reusable libraries may commit it for CI reproducibility or omit it since downstream consumers ignore it. Use --locked where a committed lockfile defines the build.

How do I verify Rust changes before merging?

Format touched files with the repository's cargo fmt setup, run affected tests and CI-equivalent Clippy checks, and run doctests when documented behavior changes. For public API or MSRV changes, derive the full matrix from CI including feature combinations, targets, and the declared rust-version.