rust-coding

Guides writing idiomatic Rust code with data modeling, traits, macros, and build-speed practices.

1|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/cjthompson/claude-code-config --skill rust-coding-cjthompson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-coding
Source: https://github.com/cjthompson/claude-code-config/tree/main/plugins/rust-coding/skills/rust-coding
Command: npx skills add https://github.com/cjthompson/claude-code-config --skill rust-coding-cjthompson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Rust that is idiomatic, safe, and maintainable requires deep knowledge of ownership, lifetimes, trait design, and project structure. This Skill provides structured guidance so Rust code follows community best practices from the start instead of requiring later refactors. ## Core Features & Use Cases - Data Modeling Guidance: Choose between structs, enums, and newtypes, model invariants with types like NonZeroU32, and use enums for state machines instead of boolean flags. - Idiomatic Implementation Patterns: Organize impl blocks, use trait implementations (Display, From, TryFrom), return Result instead of panicking, and apply derive macros to reduce boilerplate. - Build-Speed Optimization: Configure the mold linker, sccache caching, cargo check workflows, and workspace splitting to keep iteration fast. - Use Case: When designing a new Rust module for a web service, use this Skill to model domain state as enums, structure impl blocks with clear constructors, and set up sccache so incremental builds stay fast. ## Quick Start Ask the assistant to design an idiomatic Rust data model with proper error handling for your current .rs file or Cargo project.

Frequently Asked Questions about rust-coding

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

FAQPage Schema
How do I write idiomatic Rust code?

Idiomatic Rust uses enums for state machines instead of boolean flags, returns Result instead of panicking, places impl blocks directly below their types, and leverages trait implementations like Display, From, and TryFrom. Run cargo fmt and cargo clippy to enforce consistency.

How to speed up Rust compile times?

Speed up Rust builds by using the mold linker on Linux, caching artifacts with sccache, running cargo check instead of cargo build during iteration, minimizing dependencies, and splitting code into lightweight workspace crates.

When should I use enum vs struct in Rust?

Use an enum when a value can be one of several variants, such as states in a state machine, and a struct when modeling a single entity with multiple fields. Enums make invalid states unrepresentable, while newtypes wrap primitives to encode invariants.

Should Rust functions return Result or panic?

Rust functions should return Result<T, E> for recoverable errors so callers can handle failures explicitly. Panics are reserved for unrecoverable bugs or violated invariants, keeping APIs predictable and ergonomic.

When should I use Arc vs channels in Rust?

Use Arc<T> when multiple threads need shared read access to the same data, and message-passing channels when ownership should transfer between threads. The choice depends on whether you need shared state or isolated ownership with communication.