rust-patterns
Skill2 starsChanged 3 months agoMITView on GitHub
USE FOR: Rust implementation recipes for new Rust 2024 services, libraries, CLIs, and workspace scaffolds - Cargo setup, error types, async patterns, serde/config, gRPC/Protobuf, HTTP/axum, OpenTelemetry/tracing, testing, quality gates, API design, production readiness, and security/supply-chain checks. Pairs with `rust.instructions.md` and `rust-tests.instructions.md`. Load this skill when Copilot needs working Rust code patterns or configuration guidance.
22 other projects use a version of this.
Adopted by
Most recently taken up by
- Rojios/everything-claude-codetheir own version, first seen Nov 8, 2026
- talayash/agentriumtheir own version, first seen Oct 25, 2026
- troskater/flowdeck-claudetheir own version, first seen Oct 25, 2026
- renepf/claude-skillstheir own version, first seen Oct 25, 2026
- davidanthonyn/claude-skillstheir own version, first seen Oct 20, 2026
- gongyijie85/dsh-ecctheir own version, first seen Oct 13, 2026
Used with
Projects with it also use nuxt4-patterns, pytorch-patterns and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
loulanyueSkillnuxt4-patterns
Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.
Also in 6 projects that use this
Yog-SothoSkillpytorch-patterns
PyTorch deep learning patterns and best practices for building robust, efficient, and reproducible training pipelines, model architectures, and data loading. Always activate when the user is writing PyTorch models or training scripts, reviewing deep learning code, debugging training loops or data pipelines, optimizing GPU memory or training speed, setting up reproducible experiments, implementing transfer learning or fine-tuning, or asks anything about nn.Module, DataLoader, autograd, AMP, or torch.compile.
Also in 7 projects that use this
loulanyueSkillsanta-method
Multi-agent adversarial verification with convergence loop. Two independent review agents must both pass before output ships.
Also in 4 projects that use this
RojiosSkilldefi-amm-security
Security checklist for Solidity AMM contracts, liquidity pools, and swap flows. Covers reentrancy, CEI ordering, donation or inflation attacks, oracle manipulation, slippage, admin controls, and integer math.
Also in 3 projects that use this
RojiosSkillllm-trading-agent-security
Security patterns for autonomous trading agents with wallet or transaction authority. Covers prompt injection, spend limits, pre-send simulation, circuit breakers, MEV protection, and key handling.
Also in 3 projects that use this
Exploration-labsSkilltoken-budget-advisor
Proactive token budget assessment and task chunking strategy. Use this skill when queries involve multiple large file uploads, requests for comprehensive multi-document analysis, complex multi-step workflows with heavy research (10+ tool calls), phrases like "complete analysis", "full audit", "thorough review", "deep dive", or tasks combining extensive research with large output artifacts. This skill helps assess token consumption risk early and recommend chunking strategies before beginning work.
Also in 3 projects that use this
- +3 more from loulanyue
Other versions22 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 22
- loulanyue/awesome-claude-notes★ 272same name
- FlorianBruniaux/ccboard★ 94same name
- Fmarzochi/EGC★ 61same name
- talayash/agentrium★ 48same name
- Bitslix/BLXCode★ 15same name
- gongyijie85/dsh-ecc★ 8same name
- peopleforrester/claude-dotfiles★ 3same name
- aphrody-code/bxc★ 2same name
- idexal/idexal-skills★ 2same name
- ronmkr/PromptBook★ 2same name
12 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository13 other files it gives its agents.
- agent-governance-toolkitSkill
- aks-cluster-architectureSkill
- azure-sre-agentSkill
- container-supply-chainSkill
- dependabot-configurationSkill
- drasiSkill
- hitl-design-patternsSkill
- identity-managed-identitySkill
- kedaSkill
- owasp-agenticSkill
- tauri-desktop-ui-patternsSkill
- tauri-developmentSkill
- typespec-api-designSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. 0 are common, 12 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 20 edited versions we read keep these.
12
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 35
Treat all examples as Rust 2024-first unless the user explicitly asks for older edition compatibility.
- Very specific: line 36
Verify crate APIs and versions before generating code.
- Distinctive: line 37
Do not assume fast-moving crate APIs are stable across versions.
- Distinctive: line 38
Prefer the standard library and native Rust capabilities before adding dependencies.
- Distinctive: line 40
Never hide risky defaults.
- Distinctive: line 44
Use this baseline for greenfield projects unless the user provides stronger constraints:
- Very specific: line 96
Use panic = "abort" only when the application does not need unwinding, panic hooks, or recovery semantics.
- Distinctive: line 184
When supply-chain tooling is present, also recommend:
- Distinctive: line 195
If the project uses a pinned toolchain, run the same commands through that toolchain.
- Distinctive: line 201
Keep dependencies minimal and feature-gated.
- Distinctive: line 202
Use bounded queues, explicit timeouts, and cancellation-aware tasks.
- Distinctive: line 204
Use typed configuration and typed domain identifiers instead of loose strings or booleans.
- Distinctive: line 205
Document errors, panics, and safety invariants.
- Distinctive: line 219
Do not mark work complete until:
- Very specific: line 230
Before writing Rust code that references crate APIs, macro paths, or trait methods, verify the exact symbol name and signature against the …
- Very specific: line 233
Do not assume tokio::spawn or async fn signatures from memory.
- Very specific: line 234
Do not guess crate feature flag names.
- Very specific: line 241
Use // [VERIFY] check docs.rs/<crate>/<version> for exact signature when unverifiable.
“Common” is measured: kept by at least 6 in 10 of the 20 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rust Patterns
Local toolchain ground truth (verified 2026-08-26): cargo/rustc 1.97.1 installed locally; upstream stable is 1.98.0 (released 2026-08-20) — re-check both before relying on either number.
Implementation recipes, configuration examples, and production-ready patterns for new Rust projects. For always-on style and test rules, use rust.instructions.md and rust-tests.instructions.md; this skill is the deeper recipe library.
Use When
| Trigger | Output |
| User asks to create, review, or refactor Rust 2024 service, library, CLI, or workspace code | Edition-aware Rust implementation using this skill's runtime, error, config, and testing patterns |
| User needs Cargo workspace, toolchain, lint, or release-profile setup | Cargo.toml baselines, dependency guidance, and quality-gate commands |
User needs async, serde, gRPC, HTTP, tracing, or Azure-hosted Rust patterns | Focused recipe selection plus version-aware implementation guidance |
Do not use this skill when:
- The task is for another language or a non-Rust build toolchain.
- The work is primarily high-level cloud architecture rather than Rust code, crates, or Cargo structure.
Operating Rules
- Treat all examples as Rust 2024-first unless the user explicitly asks for older edition compatibility.
- Verify crate APIs and versions before generating code. Prefer
context7for crate documentation andmicrosoft.learn.mcpfor Azure SDK for Rust guidance. - Do not assume fast-moving crate APIs are stable across versions. This especially applies to OpenTelemetry, tonic/prost, Azure SDK for Rust, tower, axum, hyper, and rustls.
- Prefer the standard library and native Rust capabilities before adding dependencies. Add third-party crates only when they materially reduce risk or complexity.
- Generate code that can pass formatting, linting, tests, and documentation checks. Include validation commands with substantial changes.
- Never hide risky defaults. Call out panic behavior, blocking operations, unbounded queues, secret handling, retry/idempotency assumptions, and MSRV implications.
Default New-Project Baseline
Use this baseline for greenfield projects unless the user provides stronger constraints:
- Edition:
2024. - Minimum supported Rust version: at least
1.90(conservative ecosystem floor; Rust 2024 edition requires at minimum 1.85, and Cargo itself recommends choosing an explicit MSRV policy rather than a universal number — common community practice lands around stable-minus-3 to stable-minus-6). - Toolchain: use current stable unless reproducibility requires an exact pinned release.
- Cargo resolver: for virtual workspaces, set
resolver = "3"explicitly. - Async runtime:
tokiowith minimal features, notfeatures = ["full"]by default. - Errors:
thiserrorfor libraries and domain modules;anyhowonly at binary/CLI application boundaries. - Serialization/config:
serdewith explicit defaults and redacted secrets. - Observability:
tracingfirst; add OpenTelemetry only when export is required. - Quality gates:
fmt,clippy,test, anddocare mandatory recommendations.
[package]
name = "service-name"
version = "0.1.0"
edition = "2024"
rust-version = "1.90"
license = "MIT OR Apache-2.0"
publish = false
[dependencies]
tokio = { version = "1", features = ["rt-multi-thread", "macros", "signal", "sync", "time"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "2"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt", "json"] }
[lints.rust]
warnings = "deny"
unsafe_code = "forbid"
[lints.clippy]
unwrap_used = "warn"
expect_used = "warn"
panic = "warn"
print_stdout = "warn"
uninlined_format_args = "warn"
missing_errors_doc = "warn"For deployable binary crates only, consider a release profile. Do not blindly apply this to reusable library crates:
[profile.release]
strip = "symbols"
lto = "thin"
codegen-units = 1
panic = "abort"Use panic = "abort" only when the application does not need unwinding, panic hooks, or recovery semantics.
Workspace Baseline
For greenfield multi-crate repositories, prefer a virtual workspace and shared workspace package metadata:
[workspace]
resolver = "3"
members = ["crates/*"]
[workspace.package]
edition = "2024"
rust-version = "1.90"
license = "MIT OR Apache-2.0"
publish = false
[workspace.dependencies]
tokio = { version = "1", features = ["rt-multi-thread", "macros", "signal", "sync", "time"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "2"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt", "json"] }
[workspace.lints.rust]
warnings = "deny"
unsafe_code = "forbid"
[workspace.lints.clippy]
unwrap_used = "warn"
expect_used = "warn"
panic = "warn"
print_stdout = "warn"
uninlined_format_args = "warn"
missing_errors_doc = "warn"Member crates opt in to shared metadata, dependencies, and lints:
[package]
name = "my-core"
version = "0.1.0"
edition.workspace = true
rust-version.workspace = true
license.workspace = true
publish.workspace = true
[dependencies]
serde.workspace = true
thiserror.workspace = true
tracing.workspace = true
[lints]
workspace = trueRecipe Index
Load the smallest recipe file that matches the task. Recipes are composable but not all standalone: unless a recipe says otherwise, it assumes the project already defines the domain error type ServiceError and the crate-level Result<T> alias from recipes/errors.md (and AppConfig from recipes/serde-config.md where shown). Stand-in names such as UserService, Event, or Item are placeholders for your own domain types.
Typical composition order for a new service: cargo-workspace.md → errors.md → serde-config.md → tracing-opentelemetry.md → the transport recipe (http-axum.md or grpc-tonic.md) → async-runtime.md shutdown wiring.
recipes/cargo-workspace.md- new project setup, workspaces, toolchains, lint policy, release profiles.recipes/errors.md-thiserror, application-boundaryanyhow, error documentation, non-exhaustive public errors.recipes/async-runtime.md- Tokio runtime features, cancellation, graceful shutdown, bounded channels, timeouts, retries.recipes/async-traits.md- native async traits, object safety,async-trait, explicit future return types.recipes/serde-config.md- serde defaults, camelCase APIs, config loading, secret redaction.recipes/tracing-opentelemetry.md- structured tracing, JSON logs, OTLP setup, trace propagation, provider shutdown.recipes/grpc-tonic.md- current tonic/prost code generation withtonic-prost-build, server/client shape, interceptors.recipes/http-axum.md- HTTP service APIs, health/readiness, error mapping, timeouts, request tracing.recipes/testing-quality-gates.md- unit/integration tests, test helpers, CI gates, documentation checks.recipes/api-design.md- Rust API Guidelines-inspired public API patterns for libraries.recipes/security-supply-chain.md- dependency hygiene, cargo-audit/deny/vet, secrets, unsafe policy.recipes/azure-service-patterns.md- Azure-hosted Rust service shape, configuration, identity, telemetry, container readiness.
Mandatory Validation Commands
For any non-trivial code generation or refactor, recommend running:
cargo fmt --all --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo test --workspace --all-features
cargo doc --workspace --all-features --no-depsWhen supply-chain tooling is present, also recommend:
cargo audit
cargo deny checkrecipes/security-supply-chain.md additionally recommends cargo tree -d and cargo outdated.
Cargo 1.97+ note: for build-cache-preserving warning enforcement you can use Cargo's native control (CARGO_BUILD_WARNINGS=deny or [build] warnings = "deny" in .cargo/config.toml) instead of RUSTFLAGS=-Dwarnings; keep the clippy -D warnings flag for lint-gating.
If the project uses a pinned toolchain, run the same commands through that toolchain.
Do / Avoid
Do:
- Keep dependencies minimal and feature-gated.
- Use bounded queues, explicit timeouts, and cancellation-aware tasks.
- Preserve caller control in library APIs.
- Use typed configuration and typed domain identifiers instead of loose strings or booleans.
- Document errors, panics, and safety invariants.
- Redact secrets from logs and
Debugoutput.
Avoid:
tokio = { features = ["full"] }unless the code needs most Tokio features.unwrap,expect,panic!,todo!, andunimplemented!in production paths.- Runtime mutation of process environment variables. In Rust 2024, some environment mutation APIs are unsafe; load configuration at startup instead.
- Unbounded channels for normal service traffic.
- Global mutable state unless there is a clear initialization and shutdown model.
- OpenTelemetry examples that do not flush/shut down providers.
Quality Gate
Do not mark work complete until:
cargo fmt,cargo clippy,cargo test, andcargo docpass, or exact commands are provided for the target workspace.- New production paths avoid
unwrap,expect,todo!, unbounded queues, and hidden blocking calls unless explicitly justified. - Runtime, tracing, config, and shutdown behaviour match the verified crate versions and enabled features in use.
- Secrets are redacted from logs and config examples, and no unsafe production shortcuts were introduced.
- Crate names, feature flags, macro paths, and trait methods were verified against installed metadata or official crate documentation.
Anti-Hallucination Rule
Before writing Rust code that references crate APIs, macro paths, or trait methods, verify the exact symbol name and signature against the crate's documentation or cargo doc output.
Forbidden shortcuts (restating Operating Rules 2–3 where they bite hardest):
- Do not assume
tokio::spawnorasync fnsignatures from memory; signatures vary between tokio versions. - Do not guess crate feature flag names; verify in the crate's Cargo.toml documentation.
Asymmetry traps:
std::sync::Mutexvstokio::sync::Mutex- different APIs designed for different contexts.reqwestv0.11 vs v0.12 have differentClient::requestandResponseAPIs.
Safe degraded output:
- Use
// [VERIFY] check docs.rs/<crate>/<version> for exact signaturewhen unverifiable.
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
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.

