agentleFS
FlorianBruniauxFlorianBruniaux/ccboard/.claude/skills/rust-expert/SKILL.md

rust-expert

Skill96 starsChanged 7 months agoMITView on GitHub

Expert Rust idiomatique pour développement CLI/système. Ownership, error handling avec anyhow/thiserror, traits, async Tokio, testing. Utiliser pour coder, reviewer ou refactorer du Rust.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Prefer &str over String for function parameters

    line 16
  2. Very specific:

    Use slices (&[T]) over Vec<T> when ownership not needed

    line 17
  3. Very specific:

    Context: Always use .context("operation description") with ?

    line 25
  4. Very specific:

    No unwrap: Use ? operator or expect() with justification

    line 26
  5. Very specific:

    Use trait objects (dyn Trait) for runtime polymorphism

    line 31
  6. Very specific:

    Use #[should_panic] for expected panics

    line 52
  7. Very specific:

    Linker: Use mold or lld for faster linking

    line 57
  8. Distinctive:

    Keep functions focused and small

    line 73
  9. Distinctive:

    Avoid deep nesting (max 3-4 levels)

    line 74

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Rust Expert Skill

Expert in idiomatic Rust 1.75+ development with focus on CLI/system tools, ownership patterns, error handling, traits, async programming, and testing.

Core Competencies

1. Ownership & Borrowing Mastery

  • Prefer &str over String for function parameters
  • Use slices (&[T]) over Vec<T> when ownership not needed
  • Leverage Cow<str> for conditionally owned strings
  • Apply Arc<T> and Arc<Mutex<T>> for thread-safe sharing
  • Design lifetimes explicitly when necessary

2. Error Handling Excellence

  • Default: anyhow::Result<T> for applications
  • Libraries: thiserror for custom error types
  • Context: Always use .context("operation description") with ?
  • No unwrap: Use ? operator or expect() with justification
  • Recovery: Provide actionable error messages

3. Trait-Driven Design

  • Implement standard traits: Debug, Clone, Default, Display
  • Use trait objects (dyn Trait) for runtime polymorphism
  • Leverage trait bounds for generic constraints
  • Organize impl blocks immediately after type definitions
  • Apply async traits (native in Rust 1.75+)

4. Async Programming Patterns

  • Runtime: Tokio for production async
  • Patterns: async fn, tokio::spawn, tokio::select macro (with !)
  • Streams: tokio_stream for async iteration
  • Rate limiting: governor crate for API throttling
  • Retries: Exponential backoff with tokio::time::sleep

5. CLI Development Best Practices

  • Argument parsing: clap with derive macros
  • Config: serde + toml/yaml for structured config
  • Output: indicatif for progress, colored for styling
  • Terminal: Handle SIGINT gracefully, cleanup on exit

6. Testing Strategy

  • Embedded tests: #[cfg(test)] mod tests { use super::*; }
  • Unit tests alongside code, integration tests in tests/
  • Use #[should_panic] for expected panics
  • Mock external dependencies with traits
  • Property-based testing with proptest or quickcheck

7. Build Optimization

  • Linker: Use mold or lld for faster linking
  • Cache: sccache for incremental builds
  • Profile: cargo build --release with LTO
  • Dependencies: Minimize with feature flags
  • Workspace: Organize large projects with workspace

8. Code Quality Standards

  • Before commit: cargo fmt, cargo clippy, cargo test
  • Clippy: Zero warnings policy
  • Documentation: /// for public APIs, // with ! for modules
  • Examples: Provide runnable examples in docs

9. Project Structure Patterns

  • Flat module hierarchy when possible (rtk style)
  • src/main.rs for binaries, src/lib.rs for libraries
  • Group related functionality in modules
  • Keep functions focused and small
  • Avoid deep nesting (max 3-4 levels)

Reference Files

This skill includes detailed patterns and checklists:

  • Patterns:
    • patterns/error-handling.md - anyhow, thiserror, Result patterns
    • patterns/ownership.md - &str vs String, Cow, Arc, lifetimes
    • patterns/async-patterns.md - Tokio, futures, async traits
    • patterns/traits-impl.md - Trait implementation organization
    • patterns/testing.md - Test organization and assertions
    • patterns/cli-patterns.md - clap derive, subcommands
  • Checklists:
    • checklists/code-review.md - Pre-commit review checklist
    • checklists/performance.md - Build optimization checklist
  • Anti-Patterns:
    • anti-patterns/common-mistakes.md - Frequent Rust mistakes
    • anti-patterns/memory-pitfalls.md - Ownership pitfalls
  • Examples:
    • examples/rtk-patterns.md - Real-world patterns from rtk project

When to Use This Skill

✅ Use for:

  • Writing new Rust code (CLI tools, libraries, async services)
  • Code review of Rust PRs
  • Refactoring to idiomatic patterns
  • Performance optimization
  • Error handling improvements
  • Test organization

❌ Don't use for:

  • Simple syntax questions (use native knowledge)
  • Non-Rust languages
  • Project setup without coding

Integration with SuperClaude Framework

  • Works with: backend-architect (system design), TDD (test-first), code-reviewer
  • Flags: Responds to --think for architectural analysis
  • Mode: Compatible with --uc token efficiency mode
  • Language: English for shareability, French instructions supported

Quick Reference

Error Handling

use anyhow::{Context, Result};

fn process_file(path: &str) -> Result<()> {
    let content = std::fs::read_to_string(path)
        .context("Failed to read file")?;
    Ok(())
}

Ownership Patterns

// Prefer borrowing
fn print_name(name: &str) { println!("{}", name); }

// Conditionally owned
use std::borrow::Cow;
fn maybe_modify(input: &str, modify: bool) -> Cow<str> {
    if modify {
        Cow::Owned(input.to_uppercase())
    } else {
        Cow::Borrowed(input)
    }
}

Async Patterns

#[tokio::main]
async fn main() -> Result<()> {
    let result = tokio::time::timeout(
        Duration::from_secs(5),
        fetch_data()
    ).await??;
    Ok(())
}

Testing

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_calculation() {
        assert_eq!(calculate(2, 3), 5);
    }
}

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.