> ## Documentation Index
> Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Explore agent

> Discover the user journeys changed by a diff and author tests to cover them, from the CLI or in CI.

The explore agent reads a git diff and determines what changed for the user,
then proposes (or builds) Momentic tests to cover it. Reach for it to keep
coverage current with the product without someone remembering to write a test
for every pull request.

<Warning>The explore agent is in beta and may change.</Warning>

## What it does

Given a base and head ref, the agent:

* Diffs the two refs and identifies user-facing changes. These are not always
  frontend edits: a backend change that surfaces to the user counts, and the
  agent reasons about which parts of the app are affected and how.
* Maps each change to the user journeys it touches.
* Checks existing tests for coverage. When a test already partially covers a
  journey, it proposes an edit to that test rather than a brand-new sibling.
* With `--build`, opens a live browser session and authors or edits the tests,
  drawing on your [knowledge base](/ai/knowledge-base) for terminology and
  flows.

The agent's analysis is read-only with respect to your application code. It
describes observable behavior and the test-coverage implication; it does not
propose product code changes.

## Discover vs. build

Without `--build`, the agent only discovers and logs the changed journeys. This
is the safe default for inspecting what it would do:

```bash theme={null}
npx momentic ai explore --base main --head HEAD
```

With `--build`, it authors or edits tests for each discovered journey:

```bash theme={null}
npx momentic ai explore --base main --head HEAD --build
```

When run in CI (GitHub Actions, CircleCI, GitLab, Buildkite, Azure DevOps),
`--base` and `--head` default to the current pull request's base and head, so
you usually do not pass them. See
[Author tests from a diff in CI](/guides/explore/in-ci) for a ready-to-use
workflow.

You can steer the agent with `--prompt` (or `--prompt-file` to load the prompt
from a file), or set a default custom prompt in
[Settings > Explore](https://app.momentic.ai/settings/explore).

## Seed coverage for the whole app

A diff is the usual starting point, but you can also explore the entire product
at once with `--seed`. Instead of a commit range, the agent maps the whole app
and self-replicates into child explorers, one per surface, so a new project can
go from zero to a baseline of coverage without a diff to anchor on. `--seed`
ignores `--base` and `--head`.

```bash theme={null}
npx momentic ai explore --seed --build
```

## Ground the agent in the running app

By default the explorer reads your repository (git history and files) to reason
about changes. Two flags shift it toward the running app instead:

* `--browser` hands the agent a live browser session, starting on a blank page,
  that it can navigate freely to ground its analysis in what the app actually
  does.
* `--no-code` removes the agent's git and filesystem access entirely, forcing it
  to earn coverage through the browser. It implies `--browser`.

## Control how deep it goes

`--granularity` sets how specific the proposed test plans are:

| Level    | Coverage                                                         |
| -------- | ---------------------------------------------------------------- |
| `low`    | Headline journeys only.                                          |
| `medium` | Adds common secondary flows and key error states. The default.   |
| `high`   | Exhaustive, down to individual UI elements, options, and states. |

The flag overrides the per-project default; leave it unset to use the project
config (`medium` if not configured).

`--timeout` caps the wall-clock budget for a run (default 15 minutes). On
timeout the agent stops and emits whatever partial results it has rather than
running indefinitely, which keeps a stuck build from consuming a full CI job.

## What happens to the tests

When `--build` writes tests, the **On successful explore** behavior in
[Settings > Explore](https://app.momentic.ai/settings/explore) decides the
outcome:

| Behavior               | What it does                                                           |
| ---------------------- | ---------------------------------------------------------------------- |
| **Pull request**       | Opens a pull request with the new and edited tests.                    |
| **Draft pull request** | Opens a draft pull request.                                            |
| **Direct commit**      | Commits and pushes, except on `main` or a protected branch (draft PR). |
| **Patch**              | Prints a git patch to stdout to apply with `git apply`.                |
| **Leave on disk**      | Writes the changes without committing or opening a pull request.       |

Pull requests are pushed to a `momentic-explore/` branch. Because the output is
a reviewable PR, generated coverage lands in the same review flow as any other
change rather than appearing silently.

## Related

* [Author tests from a diff in CI](/guides/explore/in-ci) for a ready-to-use
  workflow
* [`momentic ai explore` CLI reference](/cli-reference/momentic/commands/ai#explore)
* [Post-run heal agent](/guides/auto-heal/in-ci) for repairing failing tests
* [App graph](/ai/app-graph) for tracking coverage of discovered journeys
