Documentation Index
Fetch the complete documentation index at: https://docs.aspect.build/llms.txt
Use this file to discover all available pages before exploring further.
aspect format runs your formatter (Prettier, gofmt, Black, clang-format, or any other) against changed files and detects whether the tree is clean. It works on any CI system without any CI-specific setup, and runs identically on a developer’s machine.
The core value: format only what changed. On a large monorepo, formatting every file on every PR is prohibitively slow. aspect format detects the PR’s changed file set and passes only those files to the formatter, making format checks fast at any scale.
How change detection works
aspect format uses the most accurate signal available, in order:
- GitHub PR Files API — when running on a PR with the Aspect Workflows GitHub App authenticated. Returns the exact files GitHub considers changed, including renames and moves.
git diff <merge-base>— fallback on any CI system. Defaults to--base-ref=origin/main; override with--base-refif your default branch has a different name, or pass--merge-base=<sha>to use an explicit SHA.
Reliable drift detection via git snapshot
Most formatters rewrite files in place and exit 0 even when they changed something. You can’t use the exit code to know whether formatting was required.aspect format solves this with a non-destructive git tree snapshot:
git stash create is the key: it’s non-destructive. It writes a tree object into the git object store and returns its SHA without modifying the working tree, the index, or the stash reflog. The snapshot captures any pre-existing dirty state, so if a developer has uncommitted work before running the formatter, those pre-existing changes don’t false-positive as “formatter modified something”.
Configuration
Formatter target
aspect format builds and runs a Bazel target that contains your formatter(s). The default is //tools/format:format (a format_multirun or similar target from aspect_rules_lint).
.aspect/config.axl
Scope: changed files vs. the whole tree
--scope=all is useful for nightly maintenance jobs or when introducing a new formatter for the first time. In this mode the formatter walks the tree itself; changed-file detection is bypassed.
Reacting to formatter output
.aspect/config.axl
auto (the default) maps to fail on CI and silent locally.
File filters
.aspect/config.axl
--scope=changed mode, ignored paths are dropped from the file list before the formatter runs — the formatter never sees them. Pattern syntax: * (one path segment), ** (any number of segments), ? (one character); case-sensitive.
Patch upload
When the formatter modifies files,aspect format can upload the diff as a format.patch artifact so developers can apply it locally:
.aspect/config.axl
ArtifactUpload feature build/test use. The download URL is recorded on ArtifactsTrait.artifact_urls["format_diff"] so status-check features can surface a direct link.

