Skip to content

Commit 19122c4

Browse files
authored
fix: force AI agents to execute commands from the root of the repo (#9174)
Even despite the instruction to execute the specified commands in `.claude/CLAUDE.md` from the root of the repository, agents would often ignore it and execute the commands from some subdirectory causing them to misbehave. To fix this we explicitly prefix each command with `cd "$(git rev-parse --show-toplevel)"`.
1 parent d90d6af commit 19122c4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

.claude/CLAUDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ After changing Rust code (`*.rs`) follow these steps in order:
88

99
1. **Format** by running the following from the root of the repository:
1010
```
11+
cd "$(git rev-parse --show-toplevel)"
1112
rustfmt <MODIFIED_RUST_FILES>
1213
```
1314
where `<MODIFIED_RUST_FILES>` is a space separated list of paths of all modified Rust files relative to the root of the repository.
1415
2. **Lint** by running the following from the root of the repository:
1516
```
17+
cd "$(git rev-parse --show-toplevel)"
1618
cargo clippy --all-features <CRATES> -- \
1719
-D warnings \
1820
-D clippy::all \
@@ -30,6 +32,7 @@ After changing Rust code (`*.rs`) follow these steps in order:
3032
Fix any linting errors.
3133
3. **Build** the directly affected bazel targets by running the following from the root of the repository:
3234
```
35+
cd "$(git rev-parse --show-toplevel)"
3336
TARGETS="$(bazel query 'kind(rule, rdeps(//..., set(<MODIFIED_FILES>), 1))' --keep_going 2>/dev/null)"
3437
if [ -n "$TARGETS" ]; then
3538
bazel build $TARGETS
@@ -40,6 +43,7 @@ After changing Rust code (`*.rs`) follow these steps in order:
4043
Fix all build errors.
4144
4. **Test** the directly affected bazel tests by running the following from the root of the repository:
4245
```
46+
cd "$(git rev-parse --show-toplevel)"
4347
TESTS="$(bazel query 'kind(".*_test|test_suite", kind(rule, rdeps(//..., set(<MODIFIED_FILES>), 2)))' --keep_going 2>/dev/null)"
4448
if [ -n "$TESTS" ]; then
4549
bazel test --test_output=errors $TESTS

0 commit comments

Comments
 (0)