All skills
lukemurraynz avatar

/rust-patterns

@2cc2455

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.

Use this Skill: https://skilld.dev/gh/lukemurraynz/hve-agent-skills/rust-patterns

This session only. Nothing lands on disk.

recipescargo-workspace.md

≈863 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Cargo and Workspace Patterns

Use this recipe when creating a new Rust project, refactoring into a workspace, or editing Cargo.toml.

New Binary Crate

[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"] }

Use rust-version = "1.90" as this skill's default floor for new projects (see the baseline in SKILL.md). Drop to 1.85 only when bare Rust 2024 compatibility is the explicit MSRV requirement, and prefer a current stable toolchain when no MSRV constraint exists.

rust-toolchain.toml

Use a floating stable channel for normal greenfield development:

[toolchain]
channel = "stable"
components = ["rustfmt", "clippy"]

Use an exact pin only when reproducibility matters more than automatic patch updates:

[toolchain]
channel = "1.95.0"
components = ["rustfmt", "clippy"]

When pinning to a concrete version, verify it is still the intended current or supported version before generating the file.

Virtual Workspace

For repositories with more than one crate:

[workspace]
resolver = "3"
members = ["crates/*"]

[workspace.package]
edition = "2024"
rust-version = "1.90"
license = "MIT OR Apache-2.0"
publish = false

[workspace.dependencies]
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "2"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "signal", "sync", "time"] }
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"

Rust 2024 implies resolver 3 for normal packages, but virtual workspaces should set resolver = "3" explicitly.

Member Crate

[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 = true

Release Profiles

For deployable binary crates:

[profile.release]
strip = "symbols"
lto = "thin"
codegen-units = 1
panic = "abort"

Guidance:

  • Prefer lto = "thin" before full LTO unless maximum size/performance is required.
  • Use panic = "abort" only for binaries where unwinding is not required.
  • Avoid forcing release profile choices in libraries.

Feature Flags

Keep feature names descriptive and additive:

[features]
default = []
otlp = ["dep:opentelemetry", "dep:opentelemetry_sdk", "dep:opentelemetry-otlp", "dep:tracing-opentelemetry"]
azure = ["dep:azure_identity"]  # azure_identity reached GA 1.0.0 on 2026-05-12 (Azure SDK for Rust)

Rules:

  • Features should not silently disable behavior.
  • Prefer optional dependencies behind explicit features for telemetry, cloud SDKs, databases, and transport integrations.
  • Do not expose feature names like use_foo or with_bar; use the capability name.

Source: SKILL.md on GitHub

No alerts8d3 checks · Risk SAFE
  • Gen Agent Trust Hub8d

    The skill provides a comprehensive library of Rust implementation recipes and configuration baselines, emphasizing modern standards (Rust 2024) and security best practices such as secret redaction, dependency hygiene, and structured observability.

  • Socket8d

    No alerts

  • Snyk8d

    Risk: LOW · No issues

Signed by skilld at 2cc2455. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated last month
Other metadata
metadata
{
  "last_verified": "2026-08-26",
  "layer": "scoped",
  "owner": "engineering"
}

README badge

README badge for lukemurraynz/hve-agent-skills/rust-patterns