with one click
rust-style
Rust style rules for any .rs change.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Rust style rules for any .rs change.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Use whenever adding an e2e compiler-output test (our JS vs the reference compiler) — a new cluster case under `tasks/compiler_tests/`.
🧩 PARITY · Turn one divergence from the Original into a test per affected case (does not fix).
Use when starting any compiler task or session before touching parser/analyze/transform/ast/codegen/css/diagnostics code, before proposing a design or writing code, and when the task grows into a new layer and you need its PRD invariants.
🔪 SDT · verdict-directed review of backend codegen/transform. Use when auditing codegen/transform for smart-analyzer / dumb-codegen violations, or when porting a transform/codegen visitor from the Original.
The required unit-test format for `crates/**/src/**` — use when writing or reviewing a Rust `#[test]`, a test helper, or an `assert_*`. Not for `tasks/compiler_tests/` (use add-test) or `tasks/diagnostic_tests/` (use add-diagnostic-test).
PRD editorial standard for docs/. Use when writing a new PRD, extending one, or reviewing changes under docs/ — and when another skill needs the PRD rules.
| name | rust-style |
| description | Rust style rules for any .rs change. |
| paths | ["**/*.rs"] |
Non-negotiable. Worked ❌/✅ pairs for each rule: EXAMPLES.md.
Handle the exceptional/empty case first and return (or ?/continue/break) immediately. Keep the happy path at the lowest indentation level. Never wrap the main logic in else. Tools: ?, ok_or, let ... else { return }, early continue/break in loops.
Use Result instead of panic!, unwrap, expect, unreachable!, unimplemented!, todo!, or any other panicking construct. Propagate errors with ?. This is absolute — even a branch you can prove unreachable returns an error, never unreachable!. Scope is production code; under #[cfg(test)] / tests.rs, assert!/assert_eq! and fixture unwrap are the expected mechanism (see write-unit-test).
Match every variant explicitly instead of falling back to _. A wildcard arm silently swallows new variants — when the enum grows, the compiler stays quiet and you get a bug. Spelling out each arm forces every call site to be revisited. This applies to domain enums you own (e.g. BindingSemantics — cover every branch). It does not apply to huge foreign enums where listing all arms is noise rather than safety — oxc::Expression has 30+ variants, there a _ is fine.
matches! has the same trap — anything not listed silently becomes false, so a new variant never lights up. For domain enums, prefer an exhaustive match returning bool.
elseif !cond { a } else { b } makes the reader mentally flip the test to see which branch runs when. When both branches exist, lead with the positive condition. A lone negated guard with no else — if !ok { return } — is fine; that's the early-return pattern.
Prefer an explicit loop with named steps over a crammed iterator chain — no code-golf one-liners.
The early-return move from above, applied to boolean logic. A long ||/&& chain is hard to read — worse with a multi-statement .any() closure spliced in. Give it a bool function and write one guard clause per condition; iterate with a plain for that returns early.