rust-coding-skill

167
173
Source

Guides Claude in writing idiomatic, efficient, well-structured Rust code using proper data modeling, traits, impl organization, macros, and build-speed best practices.

Install

mkdir -p .claude/skills/rust-coding-skill && curl -L -o skill.zip "https://mcp.directory/api/skills/download/313" && unzip -o skill.zip -d .claude/skills/rust-coding-skill && rm skill.zip

Installs to .claude/skills/rust-coding-skill

About this skill

Rust Coding Skill

Instructions

  1. Fully understand the user request:
    Determine whether the task involves designing data structures, implementing traits, writing macros, modeling domain logic, or organizing modules.
    Identify key constraints such as mutability needs, ownership flow, async context, interior mutability, or concurrency boundaries.

  2. Plan data structures with precision:

    • Choose between struct, enum, or newtype based on domain needs.
    • Consider ownership of each field:
      • Use &str vs String, slices vs vectors, Arc<T> when sharing, or Cow<'a, T> for flexible ownership.
    • Model invariants explicitly using types (e.g., NonZeroU32, Duration, custom enums).
    • Prefer enum for state machines instead of boolean flags or loosely related fields.
  3. Write idiomatic Rust implementations:

    • Place impl blocks immediately below the struct/enum they modify.
    • Group related methods together: constructors, getters, mutation methods, domain logic, helpers.
    • Provide clear constructors (new, with_capacity, builders) where appropriate.
    • Use trait implementations (Display, Debug, From, Into, TryFrom) to simplify conversions.
    • Prefer returning Result<T, E> instead of panicking.
    • Keep functions short to help lifetime inference and clarity.
  4. Apply rigorous documentation and code-style best practices:

    • Use /// doc comments for structs, enums, fields, and methods.
    • Use //! for module-level documentation when explaining design or architecture.
    • Include examples in docs where valuable.
    • Run cargo fmt and cargo clippy --all-targets --all-features to maintain consistency.
    • Reserve blank lines between logically separate methods and sections.
  5. Use macros effectively but responsibly:

    • Apply derive macros (Debug, Clone, Serialize, Deserialize, etc.) to reduce boilerplate.
    • Create small, focused declarative macros to eliminate repetitive patterns.
    • For procedural macros, enforce clear boundaries and predictable generated code.
  6. Optimize build speed when relevant:

    • On Linux, configure .cargo/config.toml to use the mold linker when appropriate.
    • Use sccache to cache compiled artifacts during development.
    • Minimize unnecessary dependencies and feature flags.
    • Prefer cargo check during rapid iteration over cargo build.
    • Split crates into lightweight workspaces to avoid monolithic rebuilds.
    • Use cargo profile settings for tuned dev/release defaults.
  7. Encourage maintainable module and project structure:

    • Organize code into modules reflecting ownership and domain boundaries.
    • Use pub(crate) instead of pub when possible; expose only what needs exposing.
    • Keep APIs small and expressive; avoid leaking internal types.
    • Use meaningful file and module names aligned with functionality.
  8. Provide explanations and alternatives:
    For every code design, explain why a certain pattern is chosen and propose alternatives when relevant, such as:

    • builder pattern vs simple constructor
    • enum-based state machine vs multiple booleans
    • shared ownership via Arc<T> vs message passing channels
    • slice-based APIs for performance vs owned collections for convenience
    • deriving traits vs manual implementations for custom logic
  9. Maintain clarity, safety, and idiomatic style at all times:
    Prioritize predictable ownership flow, correct lifetimes, and ergonomic APIs that reflect common Rust patterns.

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

294790

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

213415

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

213296

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

222234

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

174201

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

146170

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.