rust
Use when writing, reviewing, scaffolding, releasing, or measuring coverage on Rust code — routes to references for style, project layout, testing, Dockerfile, and release
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 10
- Forks
- 0
01 前言 Front Matter
- name
- rust
- description
- Use when writing, reviewing, scaffolding, releasing, or measuring coverage on Rust code — routes to references for style, project layout, testing, Dockerfile, and release
02 资源文件 10
- 参考文档binary.md6.5 KB
- 参考文档coverage.md10.4 KB
- 脚本coverage.sh2.4 KB
- 参考文档dockerfile.md6.0 KB
- 参考文档mutation-testing.md3.8 KB
- 参考文档property-testing.md4.8 KB
- 参考文档scaffolding.md7.4 KB
- 参考文档server.md7.0 KB
- 参考文档style.md15.0 KB
- 参考文档versioning.md1.4 KB
03 SKILL.md 正文
Rust
Preferences for writing and shipping Rust. The actual guidance lives in references — this file routes by task and lists the cross-cutting principles that apply everywhere.
This is a self-improving skill. If you used it and it came up short — a missing command, flag, gotcha, or workflow — invoke the self-improving-skills skill and follow it before you finish.
When to read which reference
| Task | Read |
|---|---|
| Writing or reviewing Rust code | style.md |
| Scaffolding a new project | scaffolding.md + binary.md (CLI) or server.md (server) |
| Setting up a Dockerfile for a server | dockerfile.md |
| Debugging coverage gaps | coverage.md |
| Adding property tests | property-testing.md |
| Adding mutation testing | mutation-testing.md |
Wiring <NAME>_VERSION into a binary |
versioning.md |
| Releasing a CLI binary | binary.md (release section) |
| Deploying a server | server.md (deploy section) + dockerfile.md |
Cross-cutting principles
These apply to every Rust project regardless of shape.
Edition
edition = "2024" for new projects. Bump existing projects when
upstream dependencies require it, not preemptively.
Project structure
Single crate with both library and binary targets. All domain logic
lives in the library; the binary is a thin shell that parses input,
calls the library, and renders output. scaffolding.md covers the
layout in detail.
Errors
Library errors derive thiserror::Error and miette::Diagnostic.
The diagnostic codes and help text live on the variant itself, so
errors carry their own labels and source spans through tests, other
binaries, and HTTP handlers. Binaries return miette::Result<()> from
main and call miette::set_panic_hook() early.
Logging
Use tracing and tracing-subscriber with EnvFilter. Never
println! for diagnostic output — println! belongs to user-facing
program output only.
Filesystem
Use fs-err instead of std::fs. Bare std::fs errors omit the
path that failed. The Clippy configuration in style.md enforces
this.
Cargo.lock
Commit Cargo.lock for binaries (CLIs and servers both). Builds
stay reproducible even though dependency versions in Cargo.toml
are unpinned ("*"). cargo update upgrades to the latest
compatible release without editing Cargo.toml.
Task runner
Use just. The justfile template is in scaffolding.md.
CI
GitHub Actions, with every uses: pinned to a commit SHA and a
version comment (@<sha> # v4). Never pin to a moving tag.
Async runtime
tokio with features = ["full"] for both CLIs and servers.
Single-threaded runtimes are an opt-in micro-optimization, not a
default.
04 同仓库更多 Skills
zoekt
Use when searching code across repositories — prefer zoekt over grep/ripgrep for indexed code search. Covers indexing repos, search syntax, and query patterns.
writing-for-accessibility
Use when writing documentation, alt text, diagrams, or any content that should be accessible to people with disabilities. Covers alt text, color contrast, inclusive language, and accessible visuals. Also use when reviewing documents for accessibility.
writing-error-messages
Use when writing, reviewing, or improving error messages in code, CLI tools, APIs, or UIs. Covers identifying the cause, explaining the fix, and setting the right tone. Also use when error messages are vague, unactionable, or confusing.
working-in-the-open
Use when making design decisions during implementation — routes rationale to the right venue (commits, task comments, code comments, or documentation) based on how durable the context needs to be
web-standards
Use when writing or reviewing HTML, CSS, or browser JavaScript — covers semantic markup, native platform features over libraries, Baseline browser support, accessibility and APCA contrast, and optional validation with vnu, axe, and Lighthouse
web-design
Use when designing or building web UI, frontends, or styling — covers personal web design preferences, fluid layout, and Alpine.js