Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .agents/rules/github_actions_workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ globs: ".github/workflows/**,.github/actions/**"
(such as multi-line shell or Python logic) into standalone files (e.g. `.sh`
or `.py` files) instead of inlining them in workflow YAML steps (`run: |`),
shell scripts, or command invocations via heredocs (`<< 'EOF'`) or `-c` flags
(`bash -c`, `python3 -c`).
(`bash -c`, `python3 -c`). For single-line substitutions in shell scripts, use
`sed --in-place`.
* **Shell Rules**: Consult the shell rules when writing shell code in workflows
or action scripts.
* **Executable Permissions**: Workflow step scripts must have `chmod +x` (mode
`100755`) and a shebang (e.g. `#!/usr/bin/env python3`).
* **Test Location**: Place workflow tests under `tests/workflows/`.
* **Platform Constraints**: Set
`target_compatible_with = ["@platforms//os:linux"]` on tests for Linux-only
workflow scripts instead of adding macOS/BSD workarounds.
* **Imports over `sys.path`**: Never alter `sys.path`. Define a `py_library`
with `imports = ["../../.github/workflows"]` in `tests/workflows/BUILD.bazel`.
* **Functional Design & Fixtures**: Keep scripts functional with one public
Expand Down
10 changes: 10 additions & 0 deletions .agents/rules/rules_python.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@ description: rules_python-specific Bzlmod, PyPI, and rule usage invariants
logic, feature guards, or comments for older Bazel versions.
* When guarding a feature added after `MINIMUM_BAZEL_VERSION`, verify and
comment the exact Bazel version that introduced it.

## Internal Labels & Helpers
* **Toolchain Type Labels**: Define toolchain type constants in
`//python/private/toolchain_types:toolchain_types.bzl` and targets in
`//python/private/toolchain_types:BUILD.bazel`.
* **`render` Helpers (`//python/private:text_util.bzl`)**: Use `render.*`
(`render.string`, `render.toolchain`, `render.call`, `render.list`) instead of
`repr()` when generating Starlark calls.
* **`@bazel_tools` `bzl_library` Deps**: Use `"//python/private:bazel_tools"` in
`bzl_library` `deps` for files loading `@bazel_tools//...`.
16 changes: 16 additions & 0 deletions .agents/rules/starlark.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ globs: "*.bzl,BUILD,BUILD.bazel,*.bazel"
freeze). Use `tuple[T]` or `depset[T]` in providers placed into depsets; do
not use mutable `list[T]`.

## Repository Rules & Code Generation
* **Structured Attributes**: Pass separate typed attributes (`attr.string_list`,
`attr.string_list_dict`) instead of pre-rendered `BUILD` text or JSON blobs;
render `BUILD.bazel` in the rule implementation.
* **Single-Value Templates**: For generated file templates with one interpolated
value, use a top-level string and `.format()`.
* **Reuse `http_file`**: Use `http_file` from
`@bazel_tools//tools/build_defs/repo:http.bzl` for single-file downloads. Omit
`downloaded_file_path` unless required and reference `@<repo>//file`.
* **`rctx.read()` Files**: Do not add `exports_files()` for files only read via
`rctx.read(Label(...))`.
* **`repository_ctx.repo_metadata`**: `repository_ctx.repo_metadata` was
introduced in Bazel 8.3.0.

## Code Style & Conventions
* **Direct Attribute Access**: Use normal attribute access (`x.field`) instead
of `getattr(x, "field", default)` for fields defined on a provider or struct
Expand All @@ -77,6 +91,8 @@ globs: "*.bzl,BUILD,BUILD.bazel,*.bazel"
above `provider()` declarations that do not end in `Info` (e.g. `*Fileset`).
* **`config_setting` Naming**: Prefix `config_setting` names with `is_` (e.g.
`is_linux_x86_64`), so that `select()` keys read as conditions.
* **Explicit Required Parameters**: Declare required parameters explicitly
instead of passing them through `**kwargs`. Document `Args:` and `Returns:`.
* **Docstring Formatting Invariants**: Use triple-quoted strings for multi-line
docstrings without trailing backslashes (`\`) for line continuation.
* **Workaround Comments**: Comment non-obvious workarounds with the intent, why
Expand Down
Loading