Skip to main content
Version: 0.207

Usage

Use the Terrabuild CLI to run targets, inspect build decisions, compare changes, and manage your local workspace.

Choose a command​

TaskCommandWhen to use it
Build, test, package, or deployrunExecute one or more targets and their prerequisites; optionally restore cached outputs or write a JSON result.
Start development servicesserveRun the serve target for selected projects.
Read previous build logslogsInspect stored target logs without starting another build.
Understand the next runexplainSee selection, cache, and scheduling decisions without executing targets.
Measure branch impactimpactCompare the local graph with a base commit graph stored in Insights and write changed targets to JSON.
Investigate cache-key changescompareCompare two saved diagnostic reports locally, including changed files, dependencies, and inputs.
Create workspace configurationscaffoldGenerate starter WORKSPACE and PROJECT files.
Explore the graph visuallyconsoleOpen the local web console.
Reset local cachesclearRemove selected local cache data.
Reclaim cache spacepruneRemove local cache entries older than an access-age threshold.
Connect shared cache and InsightsloginSave an Insights workspace connection on this machine or CI runner.
Remove an Insights connectionlogoutDelete a saved connection.
Check the installed binaryversionPrint the installed Terrabuild version.

explain answers what a run would do now. impact answers which logical targets changed since a recorded commit. compare answers why cache keys or decisions differ between two saved runs. Only impact requires an Insights baseline.

Get command help​

Append --help to any command, for example terrabuild impact --help. Run terrabuild --help for the top-level usage:

USAGE: terrabuild [--help] [version] [<subcommand> [<options>]]

SUBCOMMANDS:

scaffold <options> Scaffold workspace.
logs <options> dump logs.
run <options> Run specified targets.
compare <options> Explain cache-key changes between two saved diagnostic reports.
explain <options> Explain target selection and execution decisions.
impact <options> Report impacted targets compared to a base commit.
serve <options> Serve specified targets.
console <options> Launch web console.
clear <options> Clear specified caches.
prune <options> Prune stale local build cache entries.
login <options> Connect to backend.
logout <options> Disconnect from backend.

Use 'terrabuild <subcommand> --help' for additional information.

Shared selection options​

run, explain, impact, logs, and serve accept the following options. Each command page lists its complete syntax and additional options.

OptionShort formPurpose
--workspace <path>-wUse this workspace root. When omitted, Terrabuild searches the current directory and its parents for WORKSPACE.
--configuration <name>-cSelect a configuration, overriding the workspace default.
--environment <name>-eSelect the environment used to evaluate configuration and targets.
--variable <name>=<value>-vSet a variable. Repeat the option to set multiple variables.
--project <projects>...-pSelect projects by identifier or workspace-relative path. Unknown selectors fail the command.
--label <labels>...-lSelect projects matching any of the supplied labels.
--type <types>...-tSelect projects using any of the supplied extension types.

Different filters are combined: a project must satisfy each supplied filter. Dependencies required by the selected targets can include projects outside those filters.

terrabuild run build test -w ./repo -p api web -c Release -e staging -v version=1.2.3

scaffold and console also accept --workspace (-w); see their pages for workspace behavior. For login, --workspace is an Insights workspace ID, not a filesystem path.

Common patterns​

  • Use terrabuild run <target> to build, test, package, or deploy locally and in CI.
  • Use terrabuild explain <target> to understand what Terrabuild would do and why.
  • Use terrabuild run <target> --out <file> when automation needs a machine-readable build report.
  • Use terrabuild impact <target> --base <sha> --out <file> to compute impacted targets from a stored base graph.
  • Use terrabuild compare --before <report.json> --after <report.json> to explain cache-key changes between saved debug runs without an Insights connection.
  • Use terrabuild logs <target> when you only need the stored logs for a target.
  • Use terrabuild login once per machine or CI environment to enable shared cache and Insights-backed features.