Skip to main content
The Aspect CLI (aspect) is a free, Apache-licensed task runner on top of Bazel. It replaces the shell scripts and CI YAML a Bazel monorepo accumulates (format pre-submits, lint enforcement, BUILD file generation, release delivery) with one tool that behaves the same on a laptop and in CI. Built-in tasks like aspect build and aspect test work out of the box, and custom tasks are Starlark functions you add to your repo and run as aspect <name>. The CLI needs no account. Step 4 connects to Aspect Cloud, which needs a free account. Your existing bazel workflow keeps working alongside all of it.

1. Install the CLI

Works on macOS and Linux, with no extra package manager. The script installs the aspect-launcher binary as /usr/local/bin/aspect, using sudo, so it may prompt for your password. The launcher is a thin shim that downloads and runs the actual CLI, like bazelisk for Bazel, or nvm for Node. See Install the Aspect CLI for other installation methods (Homebrew, GitHub Actions, bazel_env, manual download). Verify the install:
The launcher runs whichever CLI version your repository pins, which step 3 sets.

2. Point aspect at a Bazel repo

aspect build, aspect test, and aspect run work in any existing Bazel workspace. cd into your repo and try them out:
The rest of the quickstart works against your existing MODULE.bazel or WORKSPACE.
Each invocation runs the equivalent bazel command, with the same flags and the same exit code, and adds:
  • A status line summarizing the task and its phases (🔨 Build, 🧪 Test, 🚀 Run)
  • Automatic retry on transient Bazel errors (BLAZE_INTERNAL_ERROR, LOCAL_ENVIRONMENTAL_ERROR)
  • A consistent task lifecycle that CI integrations hook into (status checks, annotations, artifact upload)

3. Pin the CLI version

For reproducible builds across developers and CI, pin the CLI version in your repo. Connecting to Aspect Cloud in the next step needs v2026.41.24 or newer:
.aspect/version.axl
The launcher reads this file and downloads the matching aspect-cli binary the first time it’s needed, then caches it. See Pin the Aspect CLI version for custom sources (local builds, internal mirrors, alternate registries).

4. Connect to Aspect Cloud

A remote cache means an action that has already run with the same inputs, platform and configuration comes back from the cache instead of running again. Sign up for an Aspect account. The Free tier needs no credit card to start; see pricing for its limits. Then log in:
That opens a browser, signs you in, and stores the credential in your OS keyring (the macOS Keychain, or the Linux kernel keyring). Aspect Cloud’s endpoints are built into the CLI, so there’s nothing else to configure.
Add --remote to any task:
It connects the build to the remote cache and streams it to the Build Results UI. Off CI, a task builds locally unless you pass the flag, so you choose when to use the cache.
Now clear your local outputs and build again, so nothing can come from your own machine:
This time the actions should come back as remote cache hit. The CLI prints a link to the invocation in the Build Results UI, which shows the cache hit rate. aspect cache diff names any actions that missed. Aspect Cloud local setup covers profiles, organizations, making the cache the default, and checking it all worked.

5. Share the cache with CI

Give CI jobs the same cache as your laptop.
  1. Create an API token on the app’s API tokens settings page. Copy it when it’s displayed: it’s shown only once.
  2. Store it as a CI secret named ASPECT_API_TOKEN.
  3. Install the Aspect Workflows GitHub App (optional, for PR status checks and comments) on your GitHub org, and link it to your Aspect account. See GitHub App.
On GitHub Actions, hand the token to the setup-aspect action:
.github/workflows/ci.yaml
The action installs the launcher and Bazelisk, logs in with the token, and points vanilla bazel at the same cache, so bazel steps get it too. On CI, a task uses the cache without --remote. Aspect Cloud CI setup covers Buildkite, CircleCI, GitLab CI and any other CI, and the setup step’s inputs. Running tasks in CI has complete pipeline examples for the Aspect CLI tasks.

Go further with the CLI

Discover what’s available

The output lists every task the CLI knows about, including any you’ve defined in this repo. The built-in set: aspect <task> --help shows every flag for a specific task with its current default.

Customize tasks in config.axl

Built-in tasks accept configuration via .aspect/config.axl at the repo root. The file is evaluated once per invocation, locally and in CI. This config activates a --config=ci group from your .bazelrc when the CI env var is set, and turns on test-log artifact upload for failures:
.aspect/config.axl
BazelTrait.extra_flags land in Bazel’s build rc section, so they reach every build-like invocation the CLI makes — build, test, run, coverage — but not bazel query, which keeps a build-only flag from breaking a task’s sidecar query. ArtifactUpload uploads test logs, BEP, Bazel profiles, and execution logs to your CI platform’s native artifact storage. Both are documented in aspect build & aspect test.

Write your first custom task

When the built-ins don’t cover what you need, write your own. Custom tasks are Starlark functions you register with the task() built-in. Drop them in any .axl file inside .aspect/ and they’re auto-discovered as CLI commands (see How tasks are registered for the other registration paths):
.aspect/build-and-list.axl
Re-run aspect help and your new build-and-list task appears alongside the built-ins (the variable name’s underscores become dashes in the command):
Tasks can call any subprocess, read and write files, query the build graph, subscribe to Bazel’s Build Event Stream and its execution log for detail on individual actions, and define their own typed arguments. See Run and define tasks for the full walkthrough.

Where to next

Speed up more of your builds
  • Aspect Cloud CI setup: the same cache for vanilla bazel steps on the CI runners you already have.
  • Aspect Workflows: remote execution and warm CI runners, and when you’d want Aspect Enterprise, an isolated deployment of your own.
More on the CLI
  • Tasks overview: every built-in task, with config options and CI examples.
  • Run and define tasks: writing custom tasks, with arguments, processes, the filesystem, build queries, phases and cleanup.
  • External AXL modules: extension libraries like rules_lint, pulled in through MODULE.aspect.
  • AXL reference: every type, function and module AXL exposes.