Skip to content

Commit 35adf5c

Browse files
chore: add agents guidance for creating bzl_library targets (#3264)
I found it was doing a very poor job, so some guidance is needed. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent b67b9b6 commit 35adf5c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

AGENTS.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@ using a grandoise title.
1919
When tasks complete successfully, quote Monty Python, but work it naturally
2020
into the sentence, not verbatim.
2121

22+
### bzl_library targets for bzl source files
23+
24+
* `.bzl` files should have `bzl_library` defined for them.
25+
* They should have a single `srcs` file and be named after the file with `_bzl`
26+
appended.
27+
* Their deps should be based on the `load()` statements in the source file.
28+
* `bzl_library()` targets should be kept in alphabetical order by name.
29+
30+
Example:
31+
32+
```
33+
bzl_library(
34+
name = "alpha_bzl",
35+
srcs = ["alpha.bzl"],
36+
deps = [":beta_bzl"],
37+
)
38+
bzl_library(
39+
name = "beta_bzl",
40+
srcs = ["beta.bzl"]
41+
)
42+
```
43+
2244
## Building and testing
2345

2446
Tests are under the `tests/` directory.
@@ -67,3 +89,11 @@ When modifying locked/resolved requirements files:
6789

6890
When building `//docs:docs`, ignore an error about exit code 2; this is a flake,
6991
so try building again.
92+
93+
BUILD and bzl files under `tests/` should have `# buildifier: disable=bzl-visibility`
94+
trailing end-of-line comments when they load from paths containing `/private/`,
95+
e.g.
96+
97+
```
98+
load("//python/private:foo.bzl", "foo") # buildifier: disable=bzl-visibility
99+
```

0 commit comments

Comments
 (0)