rust-review
Review existing Rust code for idiom, API design, error handling, safety, and maintainability, and produce a prioritized report where every finding cites the…
от morganlinton★ 2 188 звёзд на GitHub
Установить rust-review в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Rust review
Review Rust code against the same rules the rust-best-practices skill uses for writing
it, and report what to change. The output is a review, not a rewrite: the reader decides
what to fix. Only rewrite code when the user asks for that.
1. Decide the scope
- What to read. Review exactly what the user pointed at: a file, a module, a crate, or a diff. For a diff, review the changed lines and anything they break, not the whole file.
- Library or application. Check for a
lib.rs,pubitems used by other crates, or a publishedCargo.toml. Library code is held to the API-design rules strictly. Application code gets the simplicity rules instead: concrete types,anyhow-style errors, and no speculative generality. Say which you assumed at the top of the report. - The edition and MSRV, from
Cargo.toml, so you don't recommend features the project can't use. - Frameworks. If the crate depends on
bevyorbevy_ecs, read the Bevy digest (bevy.md) in therust-best-practicesskill's references first. It lists the Bevy conventions to leave alone (by-value system parameters, the prelude, plain-data components) and the ECS bugs to look for.
2. Run the tools first, if you can
If a Rust toolchain is available, run these from the crate root and fold the results into the report. They catch the mechanical issues, which leaves you free for design.
cargo fmt --check
cargo clippy --all-targets --all-features -- -W clippy::pedantic
cargo test
Don't paste raw clippy output. Group repeated warnings into one finding, and skip pedantic lints that don't matter for this code. If the tools aren't available, say so in the report and review by reading.
3. What to look for, in priority order
Work through these in order. The first two categories are where real bugs live.
Correctness and soundness
- Undefined behavior: an
unsafeblock without a// SAFETY:comment,transmuteto cast enums or extend lifetimes,unsafe impl Send/Syncused to silence the compiler, or a safe function that can cause UB through safe calls (unsound). - Panics on reachable paths:
unwrap(),expect(), indexing,ascasts that wrap, or integer overflow, wherever input from outside can reach them. - Trait contracts: a hand-written
Ordwith a derivedPartialEq, orHashthat disagrees withEq. These silently corruptBTreeMap,HashMap,sort, anddedup. - Lock hazards: a
MutexGuardheld across.awaitor returned to a caller, user closures called under a lock, or a poisoned lock recovered withinto_inner. - ECS bugs in Bevy code: two queries that can reach the same component mutably (a
B0001 panic on the first frame), systems that read each other's results with no
order between them, and deferred
Commandsread back before they apply. - Destructors that panic, block, or can fail.
Error handling
- Errors that callers can't use:
(),String, orBox<dyn Error>as a library's public error type, an error enum withoutDisplayandstd::error::Error, oranyhow::Errorin a library's public API. - Errors that lose information:
map_err(|_| ...), nosource(), or messages without the path, line, or value that failed. - Panics used for expected failures, or
catch_unwindused as control flow.
API design (strict for libraries)
- Parameters:
&String,&Vec<T>, or&Box<T>instead of&str,&[T], or&T; aboolparameter in a public signature; ownership taken and then cloned, or a borrow cloned internally to get ownership;impl Into<T>in application code, or on a library function too rarely called to justify a copy per argument type. - Return types: a library function that collects into a
Veconly to return it, when an iterator would do. Owned results are fine when callers need ownership or random access, or when building the collection is the function's job. - Visibility: public fields that should be private,
Rc,RefCell, orArcin public signatures, or third-party types leaking into the API. - Missing standard traits:
Debugon public types,Displayon errors,Defaultnext to a zero-argumentnew(), andFromStrinstead of an ad-hocfrom_strmethod. - Naming:
get_prefixes on getters,as_/to_/into_that don't match their cost and ownership, andManager/Service/Utilnames. - Evolution: public enums or structs that should be
#[non_exhaustive], or traits that should be sealed.
Idiom and clarity
- Clones that exist only to satisfy the borrow checker.
- Check-then-unwrap (
if x.is_some() { x.unwrap() }), andmatchwhere a combinator is clearer, or the reverse. - String building with
+, hand loops that are clearer as iterators, or iterator chains long enough to need a loop. HashMapiteration order leaking into output or tests.#![deny(warnings)]in source,#[allow]without a reason, and glob imports of external crates (a framewor
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- evals/review-bevy-arena/case.yaml
- evals/review-bevy-arena/files/Cargo.lock
- evals/review-bevy-arena/files/Cargo.toml
- evals/review-bevy-arena/files/src/lib.rs
- evals/review-bevy-arena/graders/01-flags-query-conflict.md
- evals/review-bevy-arena/graders/02-flags-deferred-wave-ordering.md
- evals/review-bevy-arena/graders/03-flags-single-unwrap.md
- evals/review-bevy-arena/graders/04-flags-bool-parameter.md
- evals/review-bevy-arena/graders/05-keeps-system-params-by-value.md
- evals/review-bevy-arena/graders/06-accepts-bevy-prelude.md
- evals/review-bevy-arena/graders/07-passive-components-keep-pub-fields.md
- evals/review-bevy-arena/graders/08-type-complexity-handled-as-ecs.md
- evals/review-bevy-arena/graders/09-findings-cite-locations-and-rules.md
- evals/review-bevy-arena/graders/10-fixes-shown-as-code.md
- evals/review-bevy-arena/graders/11-code-left-unchanged.md
- evals/review-bevy-arena/place-files.sh
- evals/review-bevy-arena/prompt.md
- evals/review-inventory-module/case.yaml
- evals/review-inventory-module/files/inventory.rs
- evals/review-inventory-module/graders/01-flags-panics-as-top-priority.md
- evals/review-inventory-module/graders/02-flags-rc-refcell-api.md
- evals/review-inventory-module/graders/03-flags-borrowed-param-types.md
- evals/review-inventory-module/graders/04-flags-error-type.md
- evals/review-inventory-module/graders/05-flags-bool-parameter.md
- evals/review-inventory-module/graders/06-flags-nondeterministic-output.md
- evals/review-inventory-module/graders/07-flags-deny-warnings.md
- evals/review-inventory-module/graders/08-findings-cite-locations.md
- evals/review-inventory-module/graders/09-findings-cite-named-rules.md
- evals/review-inventory-module/graders/10-fixes-shown-as-code.md
- evals/review-inventory-module/graders/11-says-what-is-good.md
- evals/review-inventory-module/graders/12-code-left-unchanged.md
- evals/review-inventory-module/place-files.sh
- evals/review-inventory-module/prompt.md
FAQ
Что делает скилл rust-review?
Review existing Rust code for idiom, API design, error handling, safety, and maintainability, and produce a prioritized report where every finding cites the rule it breaks and gives a concrete fix. Use this whenever the user asks to review, audit, critique, grade, or "check" Rust code, a crate, a module, a .rs file, a diff, or a pull request, or asks what is wrong with their Rust or how to make it more idiomatic, even if they don't say "review". Pairs with the rust-best-practices skill, which covers writing new code.
Как установить скилл rust-review?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл rust-review запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
docx
AnthropicUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
xlsx
AnthropicUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
pptx
AnthropicUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…