跳到正文
cccskills
免费在 GitHub 公开

idiomatic-rust

Use when writing, reviewing, or refactoring Rust code. Routes the task to handbook chapters on idioms, lints, errors, testing, generics, and pointers under the edition 2024 and current-stable pins.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(11)

  • SKILL.md5.4 KB
  • agents/openai.yaml122 B
  • references/chapter_01.md25.1 KB
  • references/chapter_02.md5.4 KB
  • references/chapter_03.md8.6 KB
  • references/chapter_04.md6.9 KB
  • references/chapter_05.md14.5 KB
  • references/chapter_06.md6.6 KB
  • references/chapter_07.md8.0 KB
  • references/chapter_08.md10.1 KB
  • references/chapter_09.md9.3 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Idiomatic Rust

Contract

FieldBound contract
TriggerRust code is being written, reviewed, or refactored, or a Rust design choice about borrowing, error handling, dispatch, or testing needs the idiomatic answer.
AuthorityReversible local: writes only the Rust source and project files the invoking task already touches; rollback is version-control restore. No remote mutation.
Side effectRust source files may change under the invoking task; chapter guidance and verification output go to chat.
DoneThe code or review follows the conventions below, the routed chapters were consulted, and the toolchain verification ran clean or its failure is reported.

Inputs

  1. The Rust task (required): code to write, a diff to review, or a design question.
  2. The crate or workspace root (required when it is not the current directory): supplies Cargo.toml, rust-toolchain.toml, and the edition pin.
  3. The toolchain pin (optional): defaults to the grounded pin in step 1.

Procedure

  1. Fix the toolchain baseline. The grounded pin is Rust 1.98.1 stable (released 2026-09-03) on edition 2024. Rust ships a rolling six-week stable train with no LTS channel, so current stable is the maintained target. When the project pins an older toolchain or edition, work inside that pin and note the delta. Done when: the effective toolchain and edition are named.
  2. Route the task to the handbook chapters. Read every chapter the task touches in the same turn; the routing table is under References. Done when: each relevant chapter is loaded.
  3. Apply the core conventions. Done when: the code or review reflects each convention that applies.
    • Borrowing and ownership: prefer &T over .clone() unless ownership must move; take &str over String and &[T] over Vec<T> in parameters; use Cow<'_, T> when ownership is ambiguous.
    • Copy types: passing a small Copy type by value is a heuristic, not a rule. The handbook's threshold is about two to three machine words, roughly 24 bytes on a 64-bit target, because the copy avoids a pointer indirection. The real cutoff depends on the target's register and calling conventions; measure when the path is hot.
    • Error handling: return Result<T, E> for fallible operations; keep panic! for unrecoverable bugs; use thiserror for library error types and anyhow for application binaries; propagate with ?.
    • unwrap() and expect() stay out of production paths; tests and examples may use them.
    • Performance: benchmark with --release; run cargo clippy -- -D clippy::perf for hints; avoid cloning in loops; prefer iterators and avoid intermediate .collect() calls.
    • Dispatch: prefer generics (static dispatch) on hot paths; use dyn Trait for heterogeneous collections; box at API boundaries, not internally.
    • Type state: encode valid states in the type system when invalid transitions must fail at compile time.
    • Documentation: // comments carry why (safety, workarounds, rationale); /// doc comments carry what and how on public API; every TODO names a tracking issue; enable #![deny(missing_docs)] on libraries.
  4. Verify with the toolchain. Run cargo fmt --check, cargo clippy --all-targets --all-features --locked -- -D warnings, and cargo test. A lint that must be suppressed uses #[expect(clippy::lint)] with a justification comment, never a bare #[allow]. Done when: all three commands pass or each failure is reported with its cause.

References

Chapter content is inherited from the pinned handbook sources; the headline Rust 1.98.1 pin does not independently revalidate its per-feature and library assertions.

FileRead when
references/chapter_01.mdBorrowing vs cloning, Copy, Option/Result handling, iterators, comments, when to extract a function
references/chapter_02.mdClippy configuration, key lints, workspace lint setup
references/chapter_03.mdProfiling, redundant clones, stack vs heap, zero-cost abstractions
references/chapter_04.mdResult vs panic, thiserror vs anyhow, error hierarchies
references/chapter_05.mdTest naming, one assertion per test, snapshot testing
references/chapter_06.mdStatic vs dynamic dispatch, trait objects
references/chapter_07.mdCompile-time state safety with the type-state pattern
references/chapter_08.mdWhen to comment, doc comments, rustdoc
references/chapter_09.mdThread safety, Send/Sync, pointer types

Failure and recovery

Failure classBehavior
cargo clippy missingInstall it with rustup component add clippy; clippy ships as a rustup component in lockstep with rustc, not as a separately versioned package.
Clippy false positiveSuppress with #[expect(clippy::lint)] and a justification comment; expect warns once the lint stops firing, so the suppression cannot go stale.
Heuristic conflicts with measurementThe measurement wins; a heuristic states a default, not a law.
Project pins an older toolchainWork inside the project's pin and report which conventions need a newer toolchain.

Output

Rust code or review feedback that follows the conventions above, with the toolchain verification results or the blocking failure named.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Use when explaining System V AMD64, ARM AAPCS, RISC-V psABI, stack frames, variadic calls, or FFI register rules. Not for the Rust FFI binding layer: use rust-ffi.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin372026年9月29日 更新

Use when configuring ADC sampling time, DMA-driven ADC, calibration, or DAC channel setup on bare-metal MCUs. Not for the DMA stream itself: use dma-baremetal.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin372026年9月29日 更新

af-xdp

免费

Use when creating AF_XDP sockets, configuring UMEM and XSK rings, writing an XDP redirect program, or choosing copy versus zero-copy mode. Not for full kernel bypass: use dpdk.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin372026年9月29日 更新

Use when a completed session needs an agent-environment retrospective. Not for an engineering retrospective from telemetry: use engineering-retrospective.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin372026年9月29日 更新

Use when a redacted, trimmed agent transcript must be appended to a GitHub PR or issue body, with human approval and preview. Not for automated or model-initiated insertion.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin372026年9月29日 更新

agents-md

免费

Use when a repo needs agent setup, AGENTS.md added or made lean, CLAUDE.md audited, or agent instructions scored or pruned. Not for remote, credential, publish, deploy, or irreversible changes.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin372026年9月29日 更新

查看 OutlineDriven 的全部技能

报告此技能的问题