From 2b520ec483420bddd040ba4dda91be17ef306572 Mon Sep 17 00:00:00 2001 From: alexion Date: Thu, 17 Sep 2026 01:28:43 -0400 Subject: [PATCH] feat(skills): add rust style skill --- .pi/prompts/review-rust.md | 31 +++++++++++++++++++++++++ .pi/skills/rust-style | 1 + src/skills/rust-style/RULE-FORMAT.md | 17 ++++++++++++++ src/skills/rust-style/SKILL.md | 34 ++++++++++++++++++++++++++++ src/skills/rust-style/rules/bazel.md | 13 +++++++++++ src/skills/rust-style/rules/tests.md | 13 +++++++++++ 6 files changed, 109 insertions(+) create mode 100644 .pi/prompts/review-rust.md create mode 120000 .pi/skills/rust-style create mode 100644 src/skills/rust-style/RULE-FORMAT.md create mode 100644 src/skills/rust-style/SKILL.md create mode 100644 src/skills/rust-style/rules/bazel.md create mode 100644 src/skills/rust-style/rules/tests.md diff --git a/.pi/prompts/review-rust.md b/.pi/prompts/review-rust.md new file mode 100644 index 0000000..112930b --- /dev/null +++ b/.pi/prompts/review-rust.md @@ -0,0 +1,31 @@ +--- +description: Review Rust changes against repository Rust style rules +argument-hint: "[target]" +--- + +Use the `rust-style` skill. +Audit ${ARGUMENTS:-the staged diff} for violations of the repository Rust style rules. + +Report only actionable findings. +Order findings by severity. +Do not report preferences unless a loaded rule states them. + +Use this format for each finding: + +```text +`code-path:line` +> `smallest reviewed-code excerpt that shows the violation` + +`rule-file:line`: Finding title. +Summary: why the code breaks the rule +Fix: suggested fix +``` + +Keep the code excerpt to one to three lines when possible. +Use a longer excerpt only when the violation needs surrounding context. +Use `...` to omit unrelated lines from a multi-line excerpt. +Use a skill-relative rule citation, such as `tests.md:7`. +Make the fix direct. +Do not include alternatives when one fix best follows the cited rule. + +It is acceptable to report no findings when the reviewed Rust already follows the loaded rules. diff --git a/.pi/skills/rust-style b/.pi/skills/rust-style new file mode 120000 index 0000000..37ed939 --- /dev/null +++ b/.pi/skills/rust-style @@ -0,0 +1 @@ +../../src/skills/rust-style \ No newline at end of file diff --git a/src/skills/rust-style/RULE-FORMAT.md b/src/skills/rust-style/RULE-FORMAT.md new file mode 100644 index 0000000..8abe570 --- /dev/null +++ b/src/skills/rust-style/RULE-FORMAT.md @@ -0,0 +1,17 @@ +# Rule format + +Use this structure for each rule: + +```md +## Rule title + +### Rule + +State enforceable instructions. + +### Rationale + +Explain why the rule exists. +``` + +Add `### Examples` only when examples clarify the rule. diff --git a/src/skills/rust-style/SKILL.md b/src/skills/rust-style/SKILL.md new file mode 100644 index 0000000..694e787 --- /dev/null +++ b/src/skills/rust-style/SKILL.md @@ -0,0 +1,34 @@ +--- +name: rust-style +description: Use when creating, editing, or reviewing Rust files in this repository. +--- + +# rust-style + +Use this skill as the source of truth for repository Rust conventions. + +## Load rules + +Read every Markdown file directly under [`rules/`](rules/) before applying this skill. +Resolve [`rules/`](rules/) relative to this `SKILL.md`. + +Finish when all discovered rule files have been read. + +## Apply rules + +Apply the loaded rules when editing or reviewing Rust files. +When loaded rules conflict, follow the most specific rule. + +After editing Rust files, run: + +```bash +nix run .#fix +``` + +Finish when `nix run .#fix` succeeds and the Rust change follows the loaded rules. +If the command fails, report the failure. + +## Maintain rules + +When adding or changing files under [`rules/`](rules/), read [`RULE-FORMAT.md`](RULE-FORMAT.md) first. +Finish when the changed rule files follow that format. diff --git a/src/skills/rust-style/rules/bazel.md b/src/skills/rust-style/rules/bazel.md new file mode 100644 index 0000000..b75b3a3 --- /dev/null +++ b/src/skills/rust-style/rules/bazel.md @@ -0,0 +1,13 @@ +# Bazel rules + +## Use one source input style per `rust_test` + +### Rule + +Do not set both `crate` and `srcs` on a `rust_test` target. +Use exactly one input style for each Rust test target. + +### Rationale + +`rules_rust` rejects `rust_test` targets that set both `crate` and `srcs`. +Keeping one input style per target makes the test declaration valid and unambiguous. diff --git a/src/skills/rust-style/rules/tests.md b/src/skills/rust-style/rules/tests.md new file mode 100644 index 0000000..cd38d5c --- /dev/null +++ b/src/skills/rust-style/rules/tests.md @@ -0,0 +1,13 @@ +# Test rules + +## Keep Rust tests in separate files + +### Rule + +Put Rust tests in separate `*_test.rs` files. +Do not add inline `#[cfg(test)]` modules. +Declare each test file in the nearest Bazel `BUILD` file with a `rust_test` target. + +### Rationale + +Separate test files keep production modules focused and match the repository's Bazel test layout.