
rust-ecosystem
by takeokunn
takeokunn's nixos-configuration
SKILL.md
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
<concept name="borrowing">
<description>Immutable and mutable references with strict rules</description>
<rules priority="critical">
<rule>&T allows multiple simultaneous borrows</rule>
<rule>&mut T allows exactly one mutable borrow</rule>
<rule>Cannot have &mut T while &T exists</rule>
</rules>
</concept>
<concept name="lifetimes">
<description>Lifetime annotations for reference validity</description>
<pattern name="elision">
<description>Compiler infers lifetimes in common patterns</description>
</pattern>
<pattern name="explicit">
<description>Explicit lifetime annotations for complex cases</description>
<example>
fn foo<'a>(x: &'a str) -> &'a str {
x
}
</example>
</pattern>
<pattern name="static">
<description>'static for values that live entire program</description>
</pattern>
</concept>
</ownership_borrowing>
<pattern name="derive">
<description>Automatically implement common traits</description>
<example>
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
struct MyType {
field1: String,
field2: i32,
}
</example>
</pattern>
<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>
<pattern name="Option">
<description>Optional values with Option with T type parameter</description>
<operators>? for early return on None</operators>
<combinators>map, and_then, unwrap_or, unwrap_or_default</combinators>
</pattern>
<pattern name="custom_error">
<description>Define custom error types with thiserror or anyhow</description>
<example>
#[derive(Debug, thiserror::Error)]
enum MyError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Parse error: {msg}")]
Parse { msg: String },
}
</example>
</pattern>
</error_handling>
<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>
<pattern name="newtype">
<description>Wrapper type for type safety</description>
<example>
struct UserId(u64);
</example>
</pattern>
<pattern name="type_state">
<description>Encode state in type system</description>
<use_case>Prevent invalid state transitions at compile time</use_case>
</pattern>
</common_patterns>
<anti_patterns> Using unwrap() in library code Use ? or proper error handling instead
<avoid name="clone_abuse">
<description>Cloning values unnecessarily</description>
<instead>Prefer borrowing when possible</instead>
</avoid>
<avoid name="string_for_everything">
<description>Using String for all domain values</description>
<instead>Use enums, newtypes for domain modeling</instead>
</avoid>
<avoid name="arc_mutex_overuse">
<description>Defaulting to Arc with Mutex with T for concurrency</description>
<instead>Consider channels or ownership patterns first</instead>
</avoid>
</anti_patterns> </rust_language>
<module_organization>
<pattern name="mod_rs">
<description>src/module/mod.rs with submodules</description>
</pattern>
<pattern name="file_module">
<description>src/module.rs (preferred for simple modules)</description>
</pattern>
</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">
<question>Do you have multiple related crates in one repository?</question>
<if_yes>Use workspace to share dependencies and build configuration</if_yes>
<if_no>Single crate project without workspace structure</if_no>
</decision_tree>
<configuration>
<file_reference>In Cargo.toml</file_reference>
[lints.clippy]
pedantic = "warn"
nursery = "warn"
unwrap_used = "deny"
expect_used = "deny"
<file_reference>Or in clippy.toml</file_reference>
msrv = "1.70"
cognitive-complexity-threshold = 25
</configuration>
<common_lints>
<lint name="clippy::unwrap_used">Prefer ? or proper error handling</lint>
<lint name="clippy::expect_used">Prefer ? or proper error handling</lint>
<lint name="clippy::pedantic">Stricter lints for cleaner code</lint>
<lint name="clippy::nursery">Experimental but useful lints</lint>
</common_lints>
<configuration>
<file_reference>rustfmt.toml</file_reference>
edition = "2021"
max_width = 100
use_small_heuristics = "Max"
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
reorder_imports = true
</configuration>
<cargo_nextest> Next-generation test runner with better output and parallelism cargo nextest run
<features>
<feature>Parallel test execution</feature>
<feature>Better failure output</feature>
<feature>JUnit XML output for CI</feature>
<feature>Test retries</feature>
</features>
<configuration>
<file_reference>.config/nextest.toml</file_reference>
[profile.default]
retries = 2
slow-timeout = { period = "60s", terminate-after = 2 }
fail-fast = false
</configuration>
</cargo_nextest>
<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"
<pattern name="cargo_configuration">
<step>get-library-docs context7CompatibleLibraryID="/rust-lang/cargo.git" topic="workspace"</step>
</pattern>
<pattern name="clippy_lints">
<step>get-library-docs context7CompatibleLibraryID="/rust-lang/rust-clippy" topic="lints configuration"</step>
</pattern>
</usage_patterns> </context7_integration>
<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_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>
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
1ヶ月以内に更新
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon


