一键导入
rust-errors
Use for Rust error design, `Result` shape, panic boundaries, context propagation, library vs binary handling, retryability, and failure classification.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use for Rust error design, `Result` shape, panic boundaries, context propagation, library vs binary handling, retryability, and failure classification.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Migrate a Rust codebase to the Polonius borrow checker (location-sensitive analysis, nightly flag -Zpolonius=next) and evolve owned-value internal APIs into the reference-returning, borrow-centric designs that NLL discouraged. Use this skill whenever the user mentions Polonius, NLL limitations, borrow-checker workarounds, defensive clones, double map lookups, get-or-insert helpers, lending iterators, reducing clone counts, or asks to audit, simplify, de-clone, or redesign Rust APIs around borrowing. Also use it when reviewing Rust code containing clone-to-appease-borrowck patterns, entry() calls with cloned keys, id/index indirection standing in for references, or clone-modify-writeback sequences — even if the user does not name Polonius. Provides two modes (workaround retirement; ownership-model evolution), a pattern catalogue with lifetime-versus-aliasing discriminators, an API evolution playbook, worked examples, and a documentation strategy.
Route Rust work to the smallest useful skill. Use for Rust coding, design, compile errors, API questions, crate layout, async, performance, unsafe, or domain-specific Rust work.
Design and maintain Rust unit tests with clear helper boundaries, rstest fixtures and parameterization, serial_test isolation, fallible setup, and rich assertions with googletest, pretty_assertions, and insta. Use when refactoring assertion helpers, replacing brittle boolean assertions, shaping table tests, or deciding between equality, matcher, and snapshot assertions.
Use for Rust crate boundaries, workspace structure, feature flags, public versus internal APIs, layering, and testable module design.
Capture architectural decisions in Rust projects using the Y-Statement format. Use when a choice is hard to reverse, when the rationale will outlive its author, or when reviewers keep asking "why did we pick this?". Especially relevant for typestate, trait bounds, public API shape, `unsafe` invariants, runtime selection, and verification tooling.
Audit and curate a Rust project's dependency graph. Use for `cargo-vet`, `cargo-audit`, `cargo-deny`, lockfile hygiene, version pinning, and the policy of who is trusted to ship what. Also for SemVer guardrails (`cargo-semver-checks`, `cargo-public-api`) at the publishing boundary.
| name | rust-errors |
| description | Use for Rust error design, `Result` shape, panic boundaries, context propagation, library vs binary handling, retryability, and failure classification. |
| globs | ["**/Cargo.toml","**/*.rs"] |
Use this when the problem is not "how do I return an error" but "what failure shape belongs at this boundary?"
panic!
or .expect().| Boundary | Default move |
|---|---|
| library or reusable crate | typed error enum |
| binary, tool, integration glue | anyhow-style reporting is fine |
| expected invalid input | Result |
| impossible state if invariants hold | panic or debug assertion with care |
| need source preservation | wrap and chain |
| retry policy depends on cause | classify explicitly, do not parse strings |
.unwrap() is used in production paths,.expect() guards network, filesystem, parse, or user-input failures,let _ =, .ok(), or empty Err(_) => {},Box<dyn Error> because design ran out of time.Read library-vs-binary-errors.md and retry-cancel-classification.md if the boundary or policy is still fuzzy.