Skip to content

goga build

Execute a build plan inside an isolated Docker container.

Synopsis

goga build PLAN [OPTIONS]

Description

goga build launches the goga build pipeline for a given plan file. It prepares the environment, validates preconditions, and delegates execution to the build engine running inside a Docker container with the goga in-container process as the entry point. Inside the goga image itself the same composed command runs directly as a child process instead — see step 1 below and Runtime — Direct in-container execution.

The build pipeline performs these steps:

  1. Docker check (host only) -- Verifies Docker is installed and accessible. Inside the goga image (GOGA_DOCKER=1) there is no docker launch to check or acquire: the docker-CLI check, the version check, and the image steps (6, 7, and the image guard) are skipped, and the host-only options (-e/--env, --add-host, --proxy, -u/--update) are rejected with an error naming the option before any other work. --clean there wipes <cwd>/.ralphex (the directory the build engine actually uses) before the run, and ralphex state does not persist across direct runs; --dry-run prints the direct command line.
  2. Config loading -- Reads .goga/config.yml for build settings. The optional machine-wide home config (~/.goga/config.yml) layers underneath: home.env is the base (lowest-priority) layer of the container env-file, home.docker.run is appended to every docker run, home.docker.build is forwarded to image builds. Git identity env (GIT_AUTHOR_NAME/EMAIL, GIT_COMMITTER_NAME/EMAIL) is layered in, tolerating absent git config.
  3. Uncommitted manifest check -- Scans git status for uncommitted CODEMANIFEST files (can be skipped).
  4. Agent preconditions -- Requires a build section host-side (a missing section is rejected with exit 1, before any container launch). The tasks agent (build.agent) is guarded in-container on the effective configuration: a None agent (after amendments) stops the run with exit 1 before any .ralphex/ state write or pass, and an amendment supplying build.agent satisfies the guard. The review agent's wrapper (build.review.agent) and, when the strategy engages the external review, the additional agent's wrapper are validated in-container before their pass.
  5. Defaults copy -- Fully rewrites the engine's prompt and agent defaults from the configured build.prompts_dir/build.agents_dir, or from the defaults shipped with goga. When build.review.roles is set, the vendored review prompts are filtered to the selected roles (a custom build.prompts_dir is copied as-is, without role filtering — see Configuration); when build.review.finalize is set, the finalize step's ralphex files are materialized from the prompt.
  6. Image refresh (optional) -- When --update/-u is set, the image is refreshed: if a top-level dockerfile is declared in .goga/config.yml, docker build runs against it (build failure is fatal — exit 1); otherwise docker pull runs (a pull failure is logged as a warning and the build proceeds with the locally available image). By default no refresh happens and the local image is used as-is.
  7. First-run safety net -- Runs unconditionally at launch entry: when the configured image is absent locally AND a project dockerfile is declared, the image is built once before launch (fatal on failure — the launch is skipped). This closes the corner case where a Dockerfile is declared but the image was never built and --update is not passed.
  8. Docker execution -- Launches the build inside the configured Docker image, after the shared pre-launch host–image version check (see Runtime — Pre-launch version check). The launcher adds no credential mounts — provide the agent's credentials yourself (see Runtime — Credentials). Persistent build state is isolated from the project directory (see Runtime state isolation). The pass structure: a run with review on is always two passes — a tasks pass (--tasks-only) on the build.agent wrapper, then a review pass (--review, or -e (external-only) under strategy: short) on the review-stage agent's wrapper; the passes launch with no env layer (the subprocess inherits the container environment) and the env layers of the roles (build.env, build.review.env, build.review.additional.env, and the decoded -e entries applied on top) travel through generated per-role sh closures; a failed tasks pass skips the review; when a workflow is in effect and a profile resolved, the in-container process prints Build running with workflow "<name>" and profile "<profile>" to stderr; --skip-review (or build.review.skip: true) collapses the run to the tasks pass alone. Before the first pass, the build/validate_build hooks gate runs — a vetoed run stops with exit 1 and no pass (see Hooks).
  9. Plan relocation -- After a successful final pass the plan file moves to <plan_dir>/completed/<plan_name> (atomic replace, idempotent by name). A failed run or a dry run leaves the plan in place so the build can resume.

Arguments

Argument Description
PLAN Path to the build plan file (required).

Options

Option Type Default Description
--dry-run flag off Print the assembled command without executing
--skip-manifest-check flag off Skip check for uncommitted CODEMANIFEST files
--skip-review / --no-skip-review bool pair (tri-state) unset Skip the review phase (--skip-review — a tasks-only run) or force the full cycle (--no-skip-review). Overrides build.review.skip in .goga/config.yml; when neither is given, the config decides
--session-timeout string config Session timeout duration
--idle-timeout string config Idle timeout duration
--wait string config Wait time on rate limit
--max-iterations int config Maximum number of build iterations (tasks pass)
--review-patience int config External-review patience — addresses build.review.additional.patience in .goga/config.yml; forwarded to the container only when set
--base-ref string config Review diff base (branch name or commit hash); overrides build.review.base_ref; reaches ralphex as --base-ref on the review pass only
-e, --env string (repeatable) — Additional environment variable (KEY=VALUE, repeatable)
--proxy string config HTTP/HTTPS proxy URL; overrides build.proxy. Adds HTTP_PROXY/HTTPS_PROXY/NO_PROXY=localhost,127.0.0.1 to the container env-file
--add-host string (repeatable) — Add a docker run --add-host HOST:IP entry; merges on top of build.hosts (CLI wins on key conflict)
-u, --update flag off Refresh the image before launch (build if a project Dockerfile is declared, else pull). Default skips the refresh
-c, --clean flag off Wipe the build's persistent runtime directory on the host before launch (default preserves state across runs)
-w, --workflow string — Apply the workflow at <cwd>/.goga/workflows/<name>.yml to this build — strict: the host validates containment and existence before launch (a missing file or an escaping name is a clean exit 1, no docker activity). Unlike the pipeline's auto-match, there is no implicit workflow; the value travels to the in-container build as the --workflow <name> argv flag (this launcher never writes GOGA_WORKFLOW — only the pipeline-run launcher does, so a goga build nested inside a pipeline stage inherits the pipeline's effective workflow through it, and the -w flag beats it). A value starting with - is rejected
-p, --profile string — Activate a profile — the CLI activation channel of the workflow rendering (same channels and precedence as goga pipeline: --profile > GOGA_PROFILE > the workflow's profile: default). A profile renders a workflow: with no workflow in effect (-w unset, no GOGA_WORKFLOW inherited from an enclosing pipeline run) the flag is inert — nothing loads (see Workflows — Profiles)

Timeout and iteration options fall back to values in .goga/config.yml when not provided on the command line.

--review-patience and --base-ref are review-scoped: they resolve with precedence CLI > build.review.* in .goga/config.yml > omit, and they apply to the review pass only — a skipped run carries neither. The patience setting lives at build.review.additional.patience (the legacy build.review_patience and build.review_executor.patience keys are not parsed).

Proxy and hosts

--proxy and --add-host (with build.proxy / build.hosts in .goga/config.yml) follow the shared container contract — see Runtime — Proxy and hosts.

Credentials

The launcher adds no credential mounts — mount the agent's credential file yourself via a docker.run volume token in the home configuration, or pass its API-key env var with -e; see Runtime — Credentials.

Runtime state isolation

The build engine writes its persistent state to a .ralphex/ directory it auto-detects in its working directory. Rather than letting that state accumulate inside your project directory, goga build bind-mounts a centralized host directory over /workspace/.ralphex, so the bytes physically land on the host under:

~/.goga/runtime/builds/<normalized_project>/<branch>/

<normalized_project> is the project's absolute path with leading slashes stripped and remaining slashes replaced by hyphens; <branch> is the current git branch (slashes replaced with hyphens), or default when git is unavailable, the directory is not a repository, or HEAD is detached.

The directory survives across runs of the same project on the same branch by default, so an interrupted build can be resumed. Pass --clean to wipe and recreate it before launch for a fresh run. The host path never reaches the container except as the /workspace/.ralphex mount source — the container sees only /workspace/.ralphex.

From the host, that directory is addressable without a build: goga runtime build prints it (exactly one line — for scripting) and goga runtime archive -b packages it into a single .tar.gz; see Runtime.

On the direct substrate (inside the goga image) there is no host runtime mount: the build engine writes its .ralphex/ under the current working directory, --clean wipes that directory, and the no-.ralphex/-left-in-the-project invariant holds on every exit path of both substrates.

Note: concurrent builds of the same project on the same branch share one runtime directory; run them on different branches or use --clean if isolation is required.

Pre-launch version check

Before the working container starts, goga build runs the shared host–image version check — the goga versions on the host and inside the image must agree at the (major, minor) level, or the launch is refused. The full behavior table and the GOGA_SKIP_VERSION_CHECK=1 escape hatch live in Runtime — Pre-launch version check.

Examples

Run a build plan:

goga build plan.md

Perform a dry run to see the command without executing:

goga build plan.md --dry-run

Run with custom timeouts and an extra environment variable:

goga build plan.md --session-timeout 1h --max-iterations 50 -e ANTHROPIC_API_KEY=sk-xxx

Skip the uncommitted CODEMANIFEST check:

goga build plan.md --skip-manifest-check

Skip the review phase (run tasks only):

goga build plan.md --skip-review

Review against a specific branch or commit instead of the detected default:

goga build plan.md --base-ref origin/1.2.x

Pull the latest image, then build (default skips the pull):

goga build plan.md --update

Route container traffic through a corporate proxy and add a local host entry:

goga build plan.md --proxy http://corp:3128 --add-host foo.local:127.0.0.1

Wipe persistent build state before launching a fresh build:

goga build plan.md --clean

Configuration

Build settings are loaded from .goga/config.yml. Example configuration:

language: python
image: qarium/goga-python-3.12:2.0
# dockerfile: .goga/Dockerfile   # optional — when set, `--update` builds the image from this Dockerfile instead of pulling
pipeline:
  agent: claude
build:
  agent: claude
  env: {}
  proxy: http://corp:3128      # optional HTTP/HTTPS proxy URL for the build container
  hosts:                        # optional docker run --add-host entries
    foo.local: 127.0.0.1

Only language is required by the loader. goga build additionally requires a build section host-side (it exits with a ClickException when build is absent, before any container launch) and the top-level image field must be set; otherwise the command exits with an error. build.agent is guarded in-container on the effective (post-amendment) configuration: an agent that resolves to None (optional at the loader level — absent/empty/whitespace all resolve to None) stops the run with exit 1 inside the container before any state write or pass, and a tool's config/amend_config contribution of build.agent satisfies the guard (see Hooks). The deprecated build.image field is silently ignored — set the top-level image field instead — as are the retired keys (worktree, skip_finalize, codex_review, and the task_executor / review_executor block names) — see Configuration. The optional top-level dockerfile field (when set) makes --update build the image locally from that Dockerfile instead of pulling it. The optional build.proxy and build.hosts fields are overridden/augmented by the --proxy and --add-host CLI options respectively.

Exit Codes

Code Meaning
0 Build completed successfully
1 Build failed (Docker not found, config error — including the in-container configuration load/amendment failure of the load-and-amend opening — precondition failure — including a None effective build.agent at the in-container guard, invalid review configuration, a hook veto at the build/validate_build gate, an execution-engine error — a missing engine binary inside the image or a rejected launch surfaces as a clean one-line message with exit code 1 — a fatal docker build under --update, or the pre-launch version check refusing the launch: a host–image (major, minor) mismatch, an image that cannot answer the version probe, or an undeterminable host version — see Runtime — Pre-launch version check)