From 87916a8e1723ad0dfacbf531ae25991f8e30ae5d Mon Sep 17 00:00:00 2001 From: alexion Date: Thu, 17 Sep 2026 12:45:29 -0400 Subject: [PATCH] docs(skills): add build style skill --- .pi/prompts/review.md | 6 +-- .pi/skills/build-style | 1 + src/skills/style/build/SKILL.md | 9 +++++ src/skills/style/build/rules/dependencies.md | 30 +++++++++++++++ src/skills/style/build/rules/tests.md | 25 +++++++++++++ src/skills/style/rust/rules/build.md | 39 -------------------- 6 files changed, 68 insertions(+), 42 deletions(-) create mode 120000 .pi/skills/build-style create mode 100644 src/skills/style/build/SKILL.md create mode 100644 src/skills/style/build/rules/dependencies.md create mode 100644 src/skills/style/build/rules/tests.md delete mode 100644 src/skills/style/rust/rules/build.md diff --git a/.pi/prompts/review.md b/.pi/prompts/review.md index d0e78c6..e115e3f 100644 --- a/.pi/prompts/review.md +++ b/.pi/prompts/review.md @@ -10,8 +10,8 @@ Choose skills from the reviewed files: - Use the `nix-style` skill for `*.nix` files. - Use the `rust-style` skill for `*.rs` files. -- Use the `rust-style` skill for `Cargo.toml` files. -- Use the `rust-style` skill for Bazel files that define Rust targets. +- Use the `build-style` skill for `Cargo.toml` files. +- Use the `build-style` skill for Bazel `BUILD` files. If the target includes multiple matching file types, use all matching skills. If the target is a diff, choose skills from the changed files. @@ -35,7 +35,7 @@ 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 style-skill rule citation, such as `rust::files.md:23` or `nix::let.md:7`. +Use a style-skill rule citation in the form `skill::rule-file:line`. Make the fix direct. Do not include alternatives when one fix best follows the cited rule. diff --git a/.pi/skills/build-style b/.pi/skills/build-style new file mode 120000 index 0000000..d358654 --- /dev/null +++ b/.pi/skills/build-style @@ -0,0 +1 @@ +../../src/skills/style/build \ No newline at end of file diff --git a/src/skills/style/build/SKILL.md b/src/skills/style/build/SKILL.md new file mode 100644 index 0000000..4104d2c --- /dev/null +++ b/src/skills/style/build/SKILL.md @@ -0,0 +1,9 @@ +--- +name: build-style +description: Use when creating, editing, or reviewing Bazel `BUILD` files or Rust `Cargo.toml` package manifests in this repository. +--- + +# build-style + +Use this skill for Bazel `BUILD` files and Rust `Cargo.toml` package manifests. +Follow the shared style skill instructions in `src/skills/style/STYLE.md`. diff --git a/src/skills/style/build/rules/dependencies.md b/src/skills/style/build/rules/dependencies.md new file mode 100644 index 0000000..1b5e8cd --- /dev/null +++ b/src/skills/style/build/rules/dependencies.md @@ -0,0 +1,30 @@ +# Dependency rules + +## Use workspace dependency versions + +### Rule + +Declare Rust dependency versions in the repository root `Cargo.toml` under `[workspace.dependencies]`. +Reference workspace dependencies from package `Cargo.toml` files with `workspace = true`. +Do not declare dependency versions in package `Cargo.toml` files unless the operator explicitly requests a package-local version. +Add package-local dependency features only when the feature set is specific to that package. + +### Rationale + +The repository has one Cargo workspace and one `Cargo.lock`. +Centralized versions keep package manifests consistent with the workspace lockfile. + +## Declare Rust dependencies in each build system + +### Rule + +Declare each direct crate dependency in each build system that builds the Rust target. +For Cargo, declare the crate in the package `Cargo.toml` file. +Use `workspace = true` for workspace-managed dependencies. +For Bazel, add the crate label to the `deps` of the target that uses it. +Apply this rule to `rust_library`, `rust_binary`, and `rust_test` targets. + +### Rationale + +Cargo and Bazel resolve Rust dependencies independently. +Complete declarations keep Cargo, Rust Analyzer, and Bazel builds consistent. diff --git a/src/skills/style/build/rules/tests.md b/src/skills/style/build/rules/tests.md new file mode 100644 index 0000000..33d91ba --- /dev/null +++ b/src/skills/style/build/rules/tests.md @@ -0,0 +1,25 @@ +# Test rules + +## Declare Rust tests in Bazel + +### Rule + +Declare Rust test files in the nearest Bazel `BUILD` file with `rust_test`. +Do not add `[[test]]` entries to `Cargo.toml` unless the operator explicitly requests Cargo test declarations. + +### Rationale + +This repository declares Rust test targets in Bazel. +Keeping test declarations in Bazel avoids duplicate test target lists. + +## 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/style/rust/rules/build.md b/src/skills/style/rust/rules/build.md deleted file mode 100644 index 4ccf566..0000000 --- a/src/skills/style/rust/rules/build.md +++ /dev/null @@ -1,39 +0,0 @@ -# Build rules - -## Use workspace dependency versions - -### Rule - -Declare Rust dependency versions in the repository root `Cargo.toml` under `[workspace.dependencies]`. -Reference workspace dependencies from package `Cargo.toml` files with `workspace = true`. -Do not declare dependency versions in package `Cargo.toml` files unless the operator explicitly requests a package-local version. -Add package-local dependency features only when the feature set is specific to that package. - -### Rationale - -The repository has one Cargo workspace and one `Cargo.lock`. -Centralized dependency versions keep package manifests consistent with the workspace lockfile. - -## Declare Rust tests in Bazel - -### Rule - -Declare Rust test files in the nearest Bazel `BUILD` file with `rust_test`. -Do not add `[[test]]` entries to `Cargo.toml` unless the operator explicitly requests Cargo test declarations. - -### Rationale - -Bazel is the source of truth for Rust test targets in this repository. -Keeping test declarations in Bazel avoids duplicate test target lists. - -## 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.