> For the complete documentation index, see [llms.txt](https://argos-ci.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://argos-ci.com/docs/learn/platform-fundamentals/baseline-build.md). Agents can also search and read this documentation through its [MCP server](https://argos-ci.com/docs/~gitbook/mcp).

# Baseline build

Argos compares screenshots to a chosen baseline build, determined by analyzing the commit history of your Git project.

A **baseline build** is the reference point Argos compares a new build against to detect visual changes. For every new build, Argos looks through the candidate builds in your project and picks the most relevant one.

{% hint style="info" %}
This page covers CI mode, where the baseline comes from your Git history. In [Monitoring mode](https://argos-ci.com/docs/learn/platform-fundamentals/build-modes.md#monitoring-mode), Argos ignores Git history and compares against the latest approved build instead.
{% endhint %}

### How Argos selects the baseline

Argos selects the baseline by finding the closest build in your Git history that satisfies two sets of criteria.

**Criteria on the candidate build itself:**

* **It is complete.** Argos has finished processing it.
* **Its tests passed.** None of the tests that produced the screenshots failed.
* **It is not a** [**subset**](https://argos-ci.com/docs/learn/how-to-guides/ci-pipelines/subset-builds.md)**.** It uploaded the full set of snapshots.
* **It has no active rejection.** A build whose changes were rejected (and the rejection not [dismissed](https://argos-ci.com/docs/learn/review-workflow/review-a-build.md)) can never serve as a baseline, whatever its type.

**Criteria relative to the new build:**

* **Same build name and mode.** Only builds with the same [build name](https://argos-ci.com/docs/learn/how-to-guides/ci-pipelines/monorepos-setup.md) and [build mode](https://argos-ci.com/docs/learn/platform-fundamentals/build-modes.md) are considered.
* **Commit ancestry.** The candidate's commit must be the **merge base** or one of its ancestors. The merge base is the closest common commit between your branch and the baseline branch. In practice, this means the baseline reflects the code your branch actually started from.

#### When the baseline must be approved

The baseline must be **approved**: an auto-approved build, an [orphan](#orphan-builds), or a check build with an approved review or a merged pull request. Argos waives this in two cases:

* **The baseline branch is an** [**auto-approved branch**](#auto-approved-branches) and the new build isn't tied to a pull request, since merging into that branch counts as approving it.
* **The new build's pull request is** [**stacked**](https://argos-ci.com/docs/learn/review-workflow/stacked-pull-requests.md) **on another one**: its baseline branch is the head branch of another open pull request. The build of the pull request below is used even before it's approved, since that pull request is still in review.

Among the builds that meet the criteria on the candidate build itself and share the new build's name and mode, Argos looks in this order and stops at the first match:

1. **A build on the merge-base commit**, or on the commit set with [`ARGOS_REFERENCE_COMMIT`](#choose-a-custom-baseline-via-sdk). A build on the reference commit doesn't need to be approved.
2. **The closest build on an ancestor of the merge base.** Argos walks back through the history and skips builds that don't meet the approval rule above. It searches **5,000 commits**, the merge base included. A build further back is never found, and the new build becomes an [orphan](#orphan-builds).
3. **An approved build on the new build's own commit and branch**, as a last resort. This covers running Argos twice without committing, for example while setting it up.

{% hint style="info" %}
When you push directly to a baseline branch that isn't auto-approved, as in a trunk-based workflow where each push is reviewed in Argos, the merge base is the pushed commit itself. Argos then compares the push with the closest approved build in its history, not with the previous push. Approve a build to make it the baseline for the next pushes; until you do, they keep comparing with the last approved one.
{% endhint %}

### Check whether a build can be a baseline

Every completed build shows whether it's **eligible to become a baseline** for future builds. Look for the baseline-eligibility chip next to the build status on the build page, in the [Builds list](https://argos-ci.com/docs/learn/review-workflow/builds-list.md), and in the build's **Info** panel:

* **Eligible as baseline** — "This build is eligible to be used as a baseline by future builds."
* **Not eligible as baseline** — "This build is not eligible to be used as a baseline by future builds."

![The baseline eligibility chip and its explanation on the build page](https://2221810533-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0slCNmeVzY3qdh0I85HX%2Fuploads%2Fgit-blob-2ce895a938b12d5a6d4cb34d57d6ece88eaf98b3%2Fbaseline-eligibility-chip.png?alt=media)

When a build isn't eligible, the **Baseline eligibility** section of the Info panel lists which criteria it failed to meet.

![The Baseline eligibility section in the build Info panel listing the unmet criteria](https://2221810533-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0slCNmeVzY3qdh0I85HX%2Fuploads%2Fgit-blob-f787ccca059c4ab2b94b68311e1a6ed38c57020f%2Fbaseline-eligibility-info-panel.png?alt=media)

{% hint style="info" %}
The chip appears once a build is complete, and it reflects the build on its own. The comparison-dependent criteria — matching build name, mode, and commit ancestry — depend on the build being compared, so Argos evaluates them when a new build looks for its baseline.

The chip also requires approval, which Argos [waives](#when-the-baseline-must-be-approved) when the new build's baseline branch is auto-approved, for a [stacked pull request](https://argos-ci.com/docs/learn/review-workflow/stacked-pull-requests.md), and for a build named with `ARGOS_REFERENCE_COMMIT`. A build marked not eligible only because it isn't approved can still become a baseline that way.
{% endhint %}

### The baseline branch

The **baseline branch** is the branch Argos uses as the reference when resolving the merge base:

* For pull request builds, the base branch of the pull request is used. For a [stacked pull request](https://argos-ci.com/docs/learn/review-workflow/stacked-pull-requests.md), that's the branch of the pull request below it.
* For push events, Argos uses the default baseline branch configured in your project.

{% hint style="info" %}
By default, the repository's default branch is used as the baseline branch. You can change this in the Argos project settings.
{% endhint %}

### Auto-approved branches

Builds on **auto-approved branches** are approved automatically, so they can serve as baselines without a manual review. Branches are matched by pattern (e.g., `main`, `master`, or `develop`).

Only builds that aren't tied to a pull request are auto-approved. A pull request build is never auto-approved, even when its branch matches the pattern.

{% hint style="info" %}
By default, Argos auto-approves your default baseline branch. In the Argos project settings, you can auto-approve the branches matching a pattern instead, or [turn auto-approval off](#turn-off-auto-approval).
{% endhint %}

#### Turn off auto-approval

To review every build, including the ones on your baseline branch, select **Don't auto-approve any branch** in the project settings. No build is auto-approved from then on, which changes two things:

* **A build on the baseline branch becomes a baseline only once it's approved.** Pull request builds and pushes compare against the closest [approved build](#when-the-baseline-must-be-approved) in their history, so approve the builds on your baseline branch to move the baseline forward.
* **Flaky test detection stops collecting data.** [Flaky test detection](https://argos-ci.com/docs/learn/reliability-and-flakiness/flaky-test-detection.md) only learns from auto-approved builds, so test metrics and auto-ignore see no new changes.

The pattern is kept while auto-approval is off, so selecting **Auto-approve branches matching a pattern** again restores it.

### Configure branches in project settings

In the project settings, under **Baseline builds**, you can configure the default baseline branch and which branches are auto-approved.

![The Default base branch and Auto-approved branches settings](https://2221810533-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0slCNmeVzY3qdh0I85HX%2Fuploads%2Fgit-blob-20ef0a4f5d7d91189c49a55d9ad24ec41e1973e0%2Fproject-baseline-builds-settings.png?alt=media)

### Choose a custom baseline via SDK

To compare against a specific branch or commit instead of the automatically selected baseline, set one of these environment variables in your CI:

* `ARGOS_REFERENCE_BRANCH`: The branch to use as the baseline.
* `ARGOS_REFERENCE_COMMIT`: The commit hash to select a specific baseline build.

`ARGOS_REFERENCE_COMMIT` selects the build on that exact commit, even when newer builds exist and even if nobody approved it: naming the commit counts as choosing that build. It must still meet the [criteria on the candidate build itself](#how-argos-selects-the-baseline): complete, tests passed, not a subset, and no active rejection. When the commit has no such build, Argos falls back to the closest build among its ancestors, and those follow the usual [approval rule](#when-the-baseline-must-be-approved). This fallback searches a shorter history than the merge base search: **300 commits**, the reference commit included.

If `ARGOS_REFERENCE_COMMIT` is the build's own commit, Argos skips builds on that commit at first and searches its ancestors instead. Only when none of them qualifies does it fall back to an approved build on the same commit and branch (the last step of the [search order](#when-the-baseline-must-be-approved)).

### Orphan builds

An **orphan build** is a build for which Argos found no baseline to compare against. This is expected for a project's first builds: once a build on your baseline branch is approved (or auto-approved), subsequent builds find their baseline automatically.

A build is also an orphan when its closest eligible build is more than [5,000 commits](#when-the-baseline-must-be-approved) behind its merge base. This can happen to a suite that doesn't run on every commit of the baseline branch, for example one that runs only when its files change (a `paths` filter in GitHub Actions). Unrelated merges then move the baseline branch away from the suite's last build. To keep a baseline within reach, run the suite on the baseline branch regularly, on every push or on a schedule, or name its baseline with [`ARGOS_REFERENCE_COMMIT`](#choose-a-custom-baseline-via-sdk).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://argos-ci.com/docs/learn/platform-fundamentals/baseline-build.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
