Rust Skills logo

Rust Skills

Community
leonardomso
rust-skills

Comprehensive Rust coding guidelines with 265 rules across 26 categories. Use when writing, reviewing, or refactoring Rust code. Covers ownership, error handling, async patterns, concurrency, unsafe code, API design, memory optimization, performance, numeric safety, conversions, serde, pattern matching, macros, closures, observability, testing, and common anti-patterns. Invoke with /rust-skills.

Overview

Publisherleonardomso
Repositoryrust-skills
Skill namerust-skills
Stars
552
Forks
63
Bundled files
279
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 279 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by leonardomso on GitHub. Read the source before you install it.

Installation

Install the Rust Skills AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/leonardomso/rust-skills/tree/master
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/leonardomso/rust-skills.git \
  .claude/skills/rust-skills
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Rust Skills in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Rust Skills on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Rust Skills is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Rust Best Practices

Comprehensive guide for writing high-quality, idiomatic, and highly optimized Rust code. Contains 265 rules across 26 categories, prioritized by impact to guide LLMs in code generation and refactoring. Current for Rust 1.96 (2024 edition).

When to Apply

Reference these guidelines when:

  • Writing new Rust functions, structs, or modules
  • Implementing error handling or async code
  • Writing concurrent, parallel, or unsafe code
  • Designing public APIs for libraries
  • Reviewing code for ownership/borrowing issues
  • Optimizing memory usage or reducing allocations
  • Tuning performance for hot paths
  • Refactoring existing Rust code

Rule Categories by Priority

PriorityCategoryImpactPrefixRules
1Ownership & BorrowingCRITICALown-12
2Error HandlingCRITICALerr-12
3Memory OptimizationCRITICALmem-17
4Unsafe CodeCRITICALunsafe-7
5API DesignHIGHapi-17
6Async/AwaitHIGHasync-18
7ConcurrencyHIGHconc-4
8Compiler OptimizationHIGHopt-12
9Numeric & Arithmetic SafetyHIGHnum-5
10Type SafetyMEDIUMtype-13
11Trait & Generics DesignMEDIUMtrait-6
12ConversionsMEDIUMconv-3
13Const & Compile-TimeMEDIUMconst-4
14SerdeMEDIUMserde-8
15Pattern MatchingMEDIUMpat-5
16MacrosMEDIUMmacro-8
17ClosuresMEDIUMclosure-5
18CollectionsMEDIUMcoll-4
19Naming ConventionsMEDIUMname-16
20TestingMEDIUMtest-15
21DocumentationMEDIUMdoc-12
22ObservabilityMEDIUMobs-7
23Performance PatternsMEDIUMperf-13
24Project StructureLOWproj-14
25Clippy & LintingLOWlint-13
26Anti-patternsREFERENCEanti-15

Quick Reference

1. Ownership & Borrowing (CRITICAL)

2. Error Handling (CRITICAL)

3. Memory Optimization (CRITICAL)

4. Unsafe Code (CRITICAL)

  • unsafe-safety-comment - Write a // SAFETY: comment above every unsafe block and a # Safety section in every unsafe fn.
  • unsafe-minimize-scope - Keep unsafe blocks as small as possible — mark only the operation that requires unsafety, not the surrounding safe code.
  • unsafe-miri-ci - Run cargo miri test in CI for every crate that contains unsafe code.
  • unsafe-maybeuninit - Use MaybeUninit<T> for uninitialized memory; never use mem::uninitialized() or mem::zeroed() for types with validity invariants.
  • unsafe-extern-block - In Rust 2024, wrap extern blocks in unsafe extern { } and annotate each item as safe or unsafe.
  • unsafe-send-sync-manual - Document the invariants when manually implementing Send or Sync; prefer letting the compiler derive them automatically.
  • unsafe-no-mangle-unsafe - In Rust 2024, write #[unsafe(no_mangle)], #[unsafe(export_name = "...")], and #[unsafe(link_section = "...")] — not the bare attribute forms.

5. API Design (HIGH)

  • api-builder-pattern - Use Builder pattern for complex construction
  • api-builder-must-use - Mark builder methods with #[must_use] to prevent silent drops
  • api-newtype-safety - Use newtypes to prevent mixing semantically different values
  • api-typestate - Use typestate pattern to encode state machine invariants in the type system
  • api-sealed-trait - Use sealed traits to prevent external implementations while allowing use
  • api-extension-trait - Use extension traits to add methods to external types
  • api-parse-dont-validate - Parse into validated types at boundaries
  • api-impl-into - Accept impl Into<T> for flexible APIs, implement From<T> for conversions
  • api-impl-asref - Use AsRef<T> when you only need to borrow the inner data
  • api-must-use - Mark types and functions with #[must_use] when ignoring results is likely a bug
  • api-non-exhaustive - Use #[non_exhaustive] on public enums and structs for forward compatibility
  • api-from-not-into - Implement From<T>, not Into<U> - From gives you Into for free
  • api-default-impl - Implement Default for types with sensible default values
  • api-common-traits - Implement standard traits (Debug, Clone, PartialEq, etc.) for public types
  • api-serde-optional - Make serde a feature flag, not a hard dependency for library crates
  • api-impl-fromiterator - Implement FromIterator and Extend for collection types, and IntoIterator for all three reference forms
  • api-operator-overload - Overload operators only when the semantics are natural and unsurprising

6. Async/Await (HIGH)

7. Concurrency (HIGH)

8. Compiler Optimization (HIGH)

9. Numeric & Arithmetic Safety (HIGH)

  • num-overflow-explicit - Handle integer overflow explicitly: checked_/saturating_/wrapping_/overflowing_
  • num-cast-try-from - Avoid as for narrowing casts; use From for widening and TryFrom for narrowing
  • num-float-compare - Don't compare floats with ==; use a tolerance, and total_cmp for ordering
  • num-saturating-clamp - Bound values with clamp and saturating arithmetic
  • num-nonzero - Use NonZero* types to forbid zero and unlock the niche optimization

10. Type Safety (MEDIUM)

11. Trait & Generics Design (MEDIUM)

  • trait-associated-type-vs-generic - Use an associated type when each impl has exactly one output type; use a generic parameter when a type can implement the trait for many input types
  • trait-blanket-impl - Use a blanket impl impl<T: Bound> Trait for T to give behaviour to every type that satisfies a bound
  • trait-coherence-newtype - Respect the orphan rule; wrap a foreign type in a newtype to implement a foreign trait on it
  • trait-default-methods - Define a trait in terms of a few required methods plus defaulted ones built on top of them
  • trait-dyn-vs-generic - Choose static dispatch (generics / impl Trait) vs dynamic dispatch (dyn Trait) deliberately
  • trait-object-safety - Keep a trait dyn-compatible (object-safe) when you need dyn Trait

12. Conversions (MEDIUM)

  • conv-tryfrom-fallible - Implement TryFrom for fallible conversions instead of ad-hoc conversion functions
  • conv-fromstr-parsing - Implement FromStr to enable str::parse for string-to-type conversions
  • conv-asmut-mutable - Accept impl AsMut<T> for flexible mutable borrowed inputs instead of concrete mutable references

13. Const & Compile-Time (MEDIUM)

  • const-block - Use inline const { } blocks for compile-time evaluation and assertions
  • const-fn - Make functions const fn when they can run at compile time
  • const-generics - Parameterize over values with const generics <const N: usize>
  • const-vs-static - Use const for an inlined value and static for a single addressed instance

14. Serde (MEDIUM)

15. Pattern Matching (MEDIUM)

16. Macros (MEDIUM)

17. Closures (MEDIUM)

18. Collections (MEDIUM)

  • coll-binaryheap - Use BinaryHeap for a priority queue or repeated max-extraction
  • coll-map-choice - Pick the map by access pattern: HashMap (fast, unordered), BTreeMap (sorted / range queries), IndexMap (insertion order)
  • coll-seq-choice - Default to Vec; use VecDeque for queue/deque behaviour; avoid LinkedList
  • coll-set-membership - Use HashSet/BTreeSet for membership tests and dedup, not linear Vec::contains

19. Naming Conventions (MEDIUM)

20. Testing (MEDIUM)

21. Documentation (MEDIUM)

22. Observability (MEDIUM)

  • obs-tracing-over-log - Use tracing for structured, span-aware diagnostics instead of println! or bare log
  • obs-library-facade - Libraries emit through the tracing/log facade and never install a subscriber
  • obs-structured-fields - Record structured key-value fields, not values interpolated into the message string
  • obs-instrument-spans - Use #[tracing::instrument] and spans to attach context to async tasks and requests
  • obs-levels-filter - Use log levels meaningfully and filter with EnvFilter / RUST_LOG
  • obs-error-chain - Log errors with their full source chain, and log each error exactly once
  • obs-no-sensitive-data - Never log secrets or PII; redact or skip them

23. Performance Patterns (MEDIUM)

24. Project Structure (LOW)

25. Clippy & Linting (LOW)

26. Anti-patterns (REFERENCE)


Recommended Cargo.toml Settings

toml
[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
panic = "abort"
strip = true

[profile.bench]
inherits = "release"
debug = true
strip = false

[profile.dev]
opt-level = 0
debug = true

[profile.dev.package."*"]
opt-level = 3  # Optimize dependencies in dev

How to Use

This skill provides rule identifiers for quick reference. When generating or reviewing Rust code:

  1. Check relevant category based on task type
  2. Apply rules with matching prefix
  3. Prioritize CRITICAL > HIGH > MEDIUM > LOW
  4. Read rule files in rules/ for detailed examples

Rule Application by Task

TaskPrimary Categories
New functionown-, err-, name-, pat-
New struct/APIapi-, type-, conv-, doc-
Async codeasync-, own-
Concurrency / parallelismconc-, async-, own-
Unsafe codeunsafe-, type-, test-
Error handlingerr-, api-, pat-
Type conversionsconv-, api-
Serialization (serde)serde-, type-, api-
Numeric / arithmeticnum-, type-
Macros / code generationmacro-, anti-
Closures / callbacksclosure-, type-
Logging / observabilityobs-, err-
Memory optimizationmem-, own-, perf-
Performance tuningopt-, mem-, perf-
Code reviewanti-, lint-

Sources & Attribution

This skill is an independent synthesis of official Rust guidance, well-known books, and patterns from widely-used crates. It is not affiliated with or endorsed by the Rust project or any crate author; the text and code examples are original.

Official Rust documentation

Books & guides

Tooling

Real-world codebases studied for idioms

  • ripgrep, tokio, serde, clap, polars, axum, cargo, hyper, bevy, rayon, and dtolnay's crates (thiserror, anyhow, syn)

This project is MIT-licensed. Referenced upstream materials remain under their own licenses (the official Rust docs and API Guidelines are dual MIT / Apache-2.0).

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

and 140 more files.

Frequently asked questions

What does the Rust Skills AI skill do?

Comprehensive Rust coding guidelines with 265 rules across 26 categories. Use when writing, reviewing, or refactoring Rust code. Covers ownership, error handling, async patterns, concurrency, unsafe code, API design, memory optimization, performance, numeric safety, conversions, serde, pattern matching, macros, closures, observability, testing, and common anti-patterns. Invoke with /rust-skills.

Why use Rust Skills on TypingMind?

Because you install it once and use it with any model. Rust Skills is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Rust Skills in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/leonardomso/rust-skills/tree/master. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Rust Skills?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Rust Skills?

As many as you like. As long as a model supports skills, you can use Rust Skills with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Rust Skills AI skill free?

Yes. It is published on GitHub by leonardomso under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇