Rust Ecosystem
This skill should be used when working with Rust projects, "Cargo.toml", "rustc", "cargo build/test/run", "clippy", "rustfmt", or Rust language patterns. Provides comprehensive Rust ecosystem patterns and best practices.
$ インストール
git clone https://github.com/takeokunn/nixos-configuration /tmp/nixos-configuration && cp -r /tmp/nixos-configuration/home-manager/programs/claude-code/skills/rust-ecosystem ~/.claude/skills/nixos-configuration// tip: Run this command in your terminal to install the skill
name: Rust Ecosystem description: This skill should be used when working with Rust projects, "Cargo.toml", "rustc", "cargo build/test/run", "clippy", "rustfmt", or Rust language patterns. Provides comprehensive Rust ecosystem patterns and best practices.
<rust_language> <ownership_borrowing> Each value has exactly one owner. When owner goes out of scope, value is dropped. Use move semantics by default; explicit Clone when needed
<error_handling> Recoverable errors with Result with T and E type parameters ? for early return on Err map, and_then, unwrap_or, unwrap_or_else <decision_tree name="when_to_use"> Is this a recoverable error that callers should handle? <if_yes>Return Result type with appropriate error variant</if_yes> <if_no>Use panic only for unrecoverable programming errors</if_no> </decision_tree>
<common_patterns> Fluent API for complex object construction MyStruct::builder() .field1(value1) .field2(value2) .build() <decision_tree name="when_to_use"> Does the struct have many optional fields or complex construction logic? <if_yes>Implement builder pattern for ergonomic construction</if_yes> <if_no>Use simple constructor function or Default trait</if_no> </decision_tree>
<anti_patterns> Using unwrap() in library code Use ? or proper error handling instead
<module_organization> src/module/mod.rs with submodules src/module.rs (preferred for simple modules) </module_organization> </project_structure>
<cargo_toml> <basic_structure> [package] name = "my-crate" version = "0.1.0" edition = "2021" # Current edition; edition 2024 (upcoming/future) rust-version = "1.83" # Current stable as of Dec 2025
[dependencies] serde = { version = "1.0", features = ["derive"] }
[dev-dependencies] tokio-test = "0.4"
[build-dependencies] cc = "1.0" </basic_structure>
<feature_flags> [features] default = ["std"] std = [] async = ["tokio"] full = ["std", "async"] </feature_flags>
<profile_optimization> [profile.release] lto = true codegen-units = 1 panic = "abort" strip = true
[profile.dev] opt-level = 0 debug = true </profile_optimization> </cargo_toml>
[workspace.package] version = "0.1.0" edition = "2021" license = "MIT"
[workspace.dependencies] serde = "1.0" tokio = { version = "1", features = ["full"] } </root_cargo_toml>
<member_inheritance> [package] name = "crate-a" version.workspace = true edition.workspace = true
[dependencies] serde.workspace = true </member_inheritance>
<decision_tree name="when_to_use"> Do you have multiple related crates in one repository? <if_yes>Use workspace to share dependencies and build configuration</if_yes> <if_no>Single crate project without workspace structure</if_no> </decision_tree>
<file_reference>Or in clippy.toml</file_reference>
msrv = "1.70" cognitive-complexity-threshold = 25
<common_lints> Prefer ? or proper error handling Prefer ? or proper error handling Stricter lints for cleaner code Experimental but useful lints </common_lints>
<cargo_nextest> Next-generation test runner with better output and parallelism cargo nextest run
<other_tools> Security vulnerability scanning Dependency license and security checks Check for outdated dependencies Auto-rebuild on file changes Macro expansion debugging </other_tools>
<context7_integration> Use Context7 MCP for up-to-date Rust documentation
<rust_libraries> </rust_libraries>
<usage_patterns> resolve-library-id libraryName="rust lang" get-library-docs context7CompatibleLibraryID="/rust-lang/book" topic="ownership"
<best_practices> Use cargo check for fast iteration during development Run cargo clippy before committing Format with cargo fmt for consistent style Use workspace for multi-crate projects Prefer &str over String for function parameters Use impl Trait for return types when possible Document public API with /// doc comments Write unit tests alongside code in same file Use integration tests in tests/ for API testing Set rust-version in Cargo.toml for MSRV </best_practices>
<error_escalation> Clippy warning about style Fix warning, maintain idiomatic code Borrow checker error Redesign ownership, avoid unsafe unless necessary Breaking change in public API Stop, present migration options to user Unsafe code without proper justification Block operation, require safe alternatives </error_escalation>
<related_agents> Ownership architecture, trait design, and type system modeling Rust implementation with proper lifetime management and error handling Run cargo clippy, cargo fmt, and enforce Rust idioms </related_agents>
<related_skills> Navigate trait implementations and module hierarchies Fetch Rust book, cargo, and clippy documentation Debug borrow checker errors, lifetime issues, and performance bottlenecks </related_skills>
Repository
