Catalogue / rust
rust
MITSignedWrite and review Rust code. Use when a task touches a `.rs` file or a Cargo manifest.--- name: rust description: >- Write and review Rust code. Use when a task touches a `.rs` file or a Cargo manifest. ---
Rust
Lints and safety
- Suppressions: when a lint exception is justified, use
#[expect(lint, reason = "...")]so an obsolete exception produces a warning. State why the code triggers the lint today. - Unsafe code: follow the workspace's unsafe policy. Design unsafe abstractions around safety invariants, including state maintained by surrounding safe code. Document ownership, lifetime, and buffer constraints and any caller safety obligations.
- Discarded values: write
_ = exprfor an intentionally discarded value.
Errors
- Contracts: keep errors structured when callers rely on their variants, methods, or stable public type.
thiserror::Errorsupports structs as well as enums. - Context: in application code already using
anyhow, use.context()to identify the failed operation. Preserve the error boundaries callers already consume. - Panics: reserve
expect()for invariant failures, and state the invariant in its message. - Log events: keep each
tracingmessage constant and pass variable data as fields. Record ananyhowchain aserror = %format_args!("{e:#}")and anotherDisplayvalue asname = %value.
Visibility
Choose the narrowest visibility that serves supported callers. Use scoped visibility to express module boundaries, and preserve supported public library APIs even when no workspace crate calls them.
Modules and imports
- Module files: put a module with children in
foo.rsbeside itsfoo/directory. - Import groups: group
usestatements as std, external crates, workspace crates when present, then internal paths, with a blank line between groups. - Traits: import a trait as
Trait as _when only its methods are used, and by name when code names the trait, such as in a bound.
Data
- Optional fields: omit
#[serde(default)]on an ordinaryOptionfield, since derivedDeserializereads a missing key asNone. A field usingwithordeserialize_withmay need an explicit default.
Strings
- Raw literals: use a raw string when its content would otherwise need escaping, with the fewest
#delimiters that work. - Multiline text: when the project uses
indoc, useindoc!for literals,formatdoc!for formatted text, andwritedoc!with a writer to keep the content indented with its code. - Output lines: in these macros, keep each output line on one source line, since reindenting a source continuation can change the de-indented text. A closing quote on its own line adds a final newline.
- Captures: capture format values inline by name, as in
{name}. Bind an expression to a local named for its placeholder when it is not a plain identifier, so the template reads on its own.
Dependencies
- Workspace: in a Cargo workspace, declare dependency versions once under the root manifest's
[workspace.dependencies]and reference them from member crates withdep.workspace = true. - Platform: declare a platform-specific dependency under the narrowest
[target.'cfg(...)'.dependencies]table that covers its uses.
| File | Size | SHA-256 |
|---|---|---|
| SKILL.md | 3.2 kB | b9717624d904 |
| SKILVAULT_SOURCE.json | 1.2 kB | 4c1dd3f78f77 |
| THIRD_PARTY_NOTICES.md | 1.1 kB | 0d928389ea10 |
| agents/openai.yaml | 195 B | 294c03b1f016 |
Published verbatim from the pinned commit. Nothing is rewritten.
| Version | Pinned commit | Signed | |
|---|---|---|---|
| 0.1.0 Current | a04feb174531 | 29 Nov 2026 |
Locking a skill to one version needs Pro.