| name | rust-guidelines |
| description | Enforce Microsoft Rust guidelines (design) and community Rust patterns (rust-unofficial + 22 GoF from refactoring.guru) for all Rust code generation and edits. Rules must be applied while writing code, not only in review. Triggers on any task that writes, edits, or refactors Rust code. Mechanical / style / correctness checks are left to rustc + clippy — this skill covers design decisions only. |
Rust Development Guidelines
Every rule in guidelines.txt and patterns.md is a hard constraint. Apply
them while writing code, not only during review. Mechanical correctness,
formatting, and style are enforced by rustc and clippy — this skill adds
the design layer those tools cannot cover.
Sources:
Reading protocol
Load files in this order; stop when the task's scope is satisfied.
- Always:
guidelines.txt — Microsoft Pragmatic Rust Guidelines
(~50 M-* design rules: API shape, errors, docs, FFI, safety, perf,
crates, logging, construction, typestate).
- Always:
patterns.md — Rust idioms, design patterns, anti-patterns,
and functional patterns from rust-unofficial; plus all 22 Gang-of-Four
patterns adapted to Rust from refactoring.guru. Load before choosing
among architectural alternatives (RAII guards vs Drop impl, newtype vs
alias, builder vs params struct, fold vs visitor, etc.).
Compliance marker
After producing compliant code (only when the user has explicitly asked for
a compliance check), append:
// Rust guideline compliant (Microsoft + rust-unofficial)
Hard rules
- Never ship a diff containing a design-level violation.
- Do not silently lower standards. If a rule must be violated, surface it
explicitly with a one-line rationale.
- When refactoring touched code, fix violations in-flight rather than
preserving legacy patterns.
- Prefer idiomatic Rust — a pattern from rust-unofficial's idioms section
is the canonical default unless the design guideline overrides it.
- Do not duplicate what
rustc and clippy already enforce. This skill
exists to layer design guidance on top of those tools, not replace them.