
AI coding agents like Claude, Cursor, and Codex are transforming how developers write software. For many developers coding with agents, the bottleneck has shifted from writing code to validating code…
AI coding agents like Claude, Cursor, and Codex are transforming how developers write software. For many developers coding with agents, the bottleneck has shifted from writing code to validating code written by agents - with builds and tests.
Remote Bazel ensures these builds and tests run quickly by running them on powerful remote runners. These runners are colocated with cache and RBE servers, reducing network latency. They can be cloned and reused for future builds, ensuring a warm analysis cache. All the local machine needs to do is stream back the logs.
It's like giving your AI a build farm.
This blog post is one of a series of related posts about using Remote Bazel with coding agents.
For tactical instructions on how to configure your agent to use Remote Bazel, see our blog post on agent configuration.
For more details on the technical setup of our remote runners, see our blog post on our Firecracker cloning architecture.
Bazel is a great fit for coding agents because it provides deterministic, reproducible outputs, reduces redundant computation through remote caching, and enables parallelization with remote execution.
However agents may hit bottlenecks because Bazel is notoriously resource intensive.
Typically, coding agents run builds either on developers' local machines or in lightweight cloud VMs offered by AI providers. Several issues can impact performance:
Remote Bazel eliminates each of these:
You can run any bash command on BuildBuddy remote runners with Remote Bazel. You can get started for free by creating a BuildBuddy account here and generating an API key. Remote runs can be triggered via curl request or by using our CLI and the bb remote command.
See our Remote Bazel docs for more details. They include instructions for how to configure secrets, timeouts, and other advanced features.
When using our CLI, bb remote supports some additional features out-of-the-box. It automatically:
bb remote is a drop-in replacement for bazel:
bb remote build //path/to:targetbb remote test //path/to:targetbb remote run //path/to:targetAny bash commands can be run on the remote runner with the --script flag.
bb remote --script='
./setup.sh
bazel run :gazelle
bazel test //path/to:target
echo "ALL DONE!"
'
If installing the CLI isn't practical, agents can also initiate remote runs via CURL requests.
curl -d '{
"repo": "git@github.com:your-org/your-repo.git",
"branch": "main",
"steps": [{"run": "bazel test //src/..."}]
}' \
-H "x-buildbuddy-api-key: YOUR_API_KEY" \
-H 'Content-Type: application/json' \
https://app.buildbuddy.io/api/v1/Run
A GitHub repo is not required to use the API, but if set, the remote runner will fetch the configured repository and reference and run the commands within the GitHub workspace.
The Run API returns an invocation ID. Agents can poll GetInvocation to check completion and GetLog to fetch logs.
Another benefit of Remote Bazel is that it can be used to easily run builds on different platforms, regardless of what machine the agent is running on.
# Test on Linux AMD64 from a Mac
bb remote --os=linux --arch=amd64 test //...
# Use a specific container image
bb remote --container_image=docker://gcr.io/my-project/my-image:latest test //...
For whatever reason, you may want to run a build on a different runner. One example is if you want to run a build with a different Bazel startup option, but don't want the analysis cache to be discarded on a warm runner you're using for other builds.
You can do this by setting a new execution property with the --runner_exec_properties flag with the CLI or the platform_properties field in the API request.
We take a hash of all execution properties and use that in the snapshot key. This means that if you change an execution property, you will get a new snapshot and runner. This can be used to get independent runners for different types of builds.
# These builds will run on different runners due to the different execution properties
bb remote test //...
bb remote --runner_exec_properties=runner-key=my-other-runner test //...
Here's what a sample AI coding agent workflow might look like with Remote Bazel:
bb remote test //src/auth:login_testbb remote mirrors the local git state: It uploads the local diffs to the remote runner, so the remote workspace contains the agent's local changesbb remote test //src/auth:login_test again. This command resumes from the warm VM snapshot from the first bb remote command, and runs much faster because the workspace is warmbb remote --os=darwin --arch=amd64 test //src/auth:login_testbb remote --runner_exec_properties=runner-key=race test //src/auth:login_test --@io_bazel_rules_go//go/config:race. Because the command is configured with a different execution property, a different runner will be used. This prevents the build from discarding the analysis cache from the first run, which it would typically do with the race flag. If the agent ran another build without runner-key set, it would start from the warm runner from step #9 with a warm analysis cacheIn this example, the agent never needs to even install Bazel. It just edits local files and triggers remote runs, using limited resources on the local machine. All the heavy lifting happens on snapshotted remote runners.
Remote Bazel lets AI coding agents run fast, warm, well-resourced Bazel builds without any local overhead. The combination of VM snapshots, cache colocation, and automatic git mirroring creates a tight feedback loop that's ideal for the edit-test-iterate pattern that coding agents rely on.
The setup is minimal: (1) install the CLI, (2) set an API key, (3) replace bazel with bb remote. The performance difference can be substantial, especially on repeated builds in the same repo. That speed difference can meaningfully change what an agent can accomplish in a single session.
We're building more features to support coding agents and would love to hear from our users. If you're facing challenges with setup, have anecdotes about how you're using Remote Bazel with agents, or feature requests, please reach out. You can find us on our open source Slack channel or you can contact me by email at maggie@buildbuddy.io.