rust
When writing, refactoring, testing, or configuring Rust — follow Bryan's toolchain, error-handling, crate, API-design, and structure preferences and the standard verification gate.
SKILL.mdskills/domain/rust/SKILL.md
GitHubRust
Write small, idiomatic, readable Rust for Bryan's projects — clear over clever. Respect the repo's toolchain, and prove changes with the standard gate before calling them done. Each principle below has a reference; load it when a change goes deep in that area, not for routine edits.
Resist: hiding errors with unwrap/expect/panic/assert on user-controlled input,
adding crates that don't cut real complexity, clever code.
- Respect repo
rust-toolchain.toml/rust-toolchainfirst;rustupfor toolchains,cargofor tasks. Scan before edits:rustup show active-toolchain,cargo metadata --no-deps --format-version 1,cargo check; readAGENTS.md, architecture, README. - Errors are typed and surfaced — libraries return
Result<T, Error>with typed errors; apps print a concise top-level error and exit non-zero. A detected programming bug or broken invariant panics; genuinely fallible input returnsResult. Prefersnafu; avoidanyhow/thiserrorunless the project already uses them; hand-implementstd::error::Errorin zero-dep projects. Depth:references/ERRORS.md. - Add a crate only when it reduces meaningful complexity, and say why; avoid broad
frameworks in small CLIs. Preferred picks by task:
references/CRATES.md. - Keep
src/main.rsthin (parse → call lib → print); logic insrc/lib.rs, modules by domain (parser, renderer, cli, error). Use the strongest type as early as possible (&str/PathoverString/PathBuf, newtypes over loose primitives); validate bounds before slicing;*::from_le_bytesfor binary; test malformed input and edge offsets. Idiomatic API, library, and doc design:references/API_DESIGN.md. Forunsafe/FFI:references/SAFETY.md. For hot paths:references/PERFORMANCE.md. - Verify before done:
cargo fmt -- --check,cargo clippy --all-targets -- -D warnings,cargo test,cargo check(addrustfmt/clippycomponents if missing). Recommended lint config and deeper checks (cargo-audit/-hack/-udeps, Miri):references/VERIFICATION.md.
Deliver: the change, why any new crate earned its place, and the verification results.