> ## 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.

> ## Agent Instructions
> The canonical docs host is https://momentic.ai/docs. Append .md to any page URL for clean Markdown. Fetch https://momentic.ai/docs/llms.txt for the page index and https://momentic.ai/docs/llms-full.txt for every page in one file.
> For an unattended setup, first check whether Claude Code already has the Momentic plugin. With the plugin, run `npx --yes @momentic/wizard@latest -y --platform web --editor-tools none` and ignore any CLI skills-install suggestion in its output. Otherwise, run `npx --yes @momentic/wizard@latest -y --platform web --editor-tools skills`. Use `--platform ios` or `--platform android` for mobile. Never run an interactive command in a non-TTY shell.
> Mo is the AI QA engineer, separate from repository YAML tests. With the Momentic plugin, use bundled mo-qa and hosted OAuth by default. Without the plugin, install only mo-qa with `npx -y qa skills --target <agent>`. Keep the requested interface. Otherwise, use hosted tools for web or mobile, including private web targets with an existing Connector. Run sessions that need a new tunnel with the qa CLI. If you can't run commands on the machine that reaches the target, ask the user to start the tunnel there, then use hosted tools unless you lack them or the CLI was requested. For a requested hosted session, use an online Connector and pass its name as access, not a CLI tunnel ID. If none is online, ask the user to run `npx -y qa tunnel start --name <name> <address>` on a machine that reaches the target and wait. Do not run login or tunnel commands for them. For a requested hosted session, report unavailable tools or authentication failures without starting a CLI session. For coding-agent bridge setup, ask the user to complete `npx -y qa login`, then add momentic-hosted as a stdio server running `npx -y qa mcp`. Plugin users must explicitly opt in and disable their hosted plugin entry before adding the bridge. Claude.ai/ChatGPT connectors keep https://mcp.momentic.ai with OAuth. After hosted testing completes, read the report and summarize findings and uncovered requirements. Call `momentic_mo_stop_session` only when the user asks or agrees. For CLI sessions, unless the user wants more testing, export the report, run `qa stop <id> --subagents` even if export fails, then summarize. The CLI is qa, not mo. Docs: https://momentic.ai/docs/mo/quickstart.md.
> Ask the user to complete browser sign-in. For local CLI tools, use the exact MOMENTIC_API_KEY environment variable. If it is absent, ask the user to create a key at https://app.momentic.ai/settings/api-keys and set it in the agent's environment. Never print the key or ask the user to paste it into chat.
> Momentic's capability summary for agents is at https://momentic.ai/docs/skill.md. Claude Code users with the Momentic plugin should use its bundled skills and skip CLI skills installation. Otherwise, run `npx momentic skills -y --target <agent>` or `npx momentic-mobile skills -y --target <agent>`. Both install momentic-test, momentic-maintain, and momentic-spec with web/mobile references. Use the running agent's target. The Momentic plugin also includes mo-qa; qa skills installs only mo-qa.
> Tests are YAML files in the user's repository. Use only the step names listed at https://momentic.ai/docs/reference/commands.md and the file structure at https://momentic.ai/docs/core-concepts/file-format.md. Do not invent step names, config keys, or CLI flags.
> Web tests run on Chromium, iOS tests on simulators, and Android tests on emulators.

# Auto-heal

> Use AI to escalate from in-run locator fixes to transient failure recovery, permanent healing, and quarantine.

Momentic uses locator auto-healing (autoheal) during a run and permanent healing
to repair test files. It starts with the least invasive response:

* **Locator auto-healing** re-resolves a stale target or waits for the page to
  settle. The current step continues without editing the test.
* **Failure recovery** generates temporary steps to clear an obstruction, then
  retries the failed step. The test still does not change.
* **Permanent healing** uses classification and triage to explain the failure,
  decide whether it is healable, and permanently repair the test when possible.
* **Quarantine** keeps an unresolved flaky test running and collecting data
  without letting it block CI.

Not every failure reaches every layer. Real product regressions and
infrastructure failures remain failures; quarantine is containment, not a
repair.

## Locator auto-healing

When a cached target no longer matches the page, the locator agent finds the
element again from the step's description. Smart waiting also waits for
navigation, requests, and page changes to settle before the action runs.

The resolution applies to the current run and never edits the test. After an
eligible successful run, Momentic can save it to the
[step cache](https://momentic.ai/docs/reliability/step-cache.md) for fast replay.

When an unexpected one-off condition blocks the flow, the next layer is
[failure recovery](#failure-recovery).

## Failure recovery

During eligible CI runs, failure recovery can generate temporary steps to clear
a cookie banner, wait out a transition, or handle another transient obstruction.
It then retries the failed preset step. Generated steps apply only to that run
and never edit the test.

Enable it in `momentic.config.yaml`:

```yaml momentic.config.yaml theme={null}
ai:
  failureRecovery: true
```

Give the recovery agent custom guidance with a
[knowledge base](https://momentic.ai/docs/ai/knowledge-base.md) agent rule that targets the failure
recovery agent. Use it to say which failures count as recoverable and how to
handle them.

When
[in-flow classification](https://momentic.ai/docs/reliability/failure-classification.md#classify-during-the-run)
is enabled, the classifier investigates the failure first. Only failures mapped
to **heal** and judged recoverable trigger a recovery attempt. Without
classification, a built-in recovery planner makes that decision.

Recovery has these limits:

* On web, Android, and iOS, it does not run in the editor and stops after three
  recovery attempts in one run.
* Only failed preset steps are eligible, including preset steps inside modules.
  Module containers and AI action steps are not.
* On Android and iOS, the temporary steps recovery runs are not written to the
  replay cache.
* It does not hide product regressions, configuration errors, network outages,
  5xx responses, CAPTCHAs, or browser crashes.

See [AI configuration](https://momentic.ai/docs/configuration/ai.md#ai-failurerecovery) for the full
reference.

Recovery can also clear a stale
[AI action cache](https://momentic.ai/docs/reliability/step-cache.md#ai-action-caches). When a later step
fails because an earlier AI action replayed its cached steps without reaching
the goal, recovery repairs the page for the current run and drops that entry, so
the next run resolves the goal again instead of replaying the same flow.

Frequent recovery is a flakiness signal. Use
[permanent healing](#permanent-healing) to find and fix the cause.

## Permanent healing

Permanent healing combines AI classification, AI triage, and configurable
delivery for repaired and unrepaired tests.

The `momentic-mobile` CLI has no `ai classify` or `ai triage` commands. For
mobile failures, use the
[`momentic-maintain` skill](https://momentic.ai/docs/coding-agents/skills#maintenance) with the
[hosted Momentic MCP server](https://momentic.ai/docs/coding-agents/mcp-server.md) for run history and
quarantines and the
[mobile MCP server](https://momentic.ai/docs/cli-reference/momentic-mobile/commands/mcp.md) for run
artifacts and repairs.

Permanent healing starts from
[failure classification](https://momentic.ai/docs/reliability/failure-classification.md), which explains
each failure and picks the heal, warn, or fail action.

### Heal behavior

Triage settings control how accepted repairs and failed repair attempts are
delivered.

#### Patch delivery

The **On successful heal**
[Triage setting](https://app.momentic.ai/settings/triage) controls how an
accepted repair is delivered from the CI runner. Outside CI, every mode leaves
the changes on disk instead.

* **Pull request** (default): open a pull request with the repairs.
* **Draft pull request**: open a pull request with the repairs as a draft.
* **Direct commit** (`direct-commit-except-main`): commit and push to the branch
  under test. On the main branch or a protected branch it opens a draft pull
  request instead of pushing.
* **Patch**: print a git patch to stdout, to apply with `git apply`.
* **Nothing**: leave the changes on disk.
* **Follow triage skill**: let a matching [skill](https://momentic.ai/docs/ai/skills.md) in
  `.momentic/skills` choose one of the behaviors above per repair, with a pull
  request as the fallback.
* **AI routing**: let triage decide where each repair goes based on what caused
  the failure. See [AI routing](#ai-routing).

![A merged Momentic auto-heal pull request with root cause, fix, validation, and links to the base pull request and results](https://mintcdn.com/momentic-docs/SZGi8yiMYy_JzZIR/images/reliability/auto-heal-pull-request.jpg?fit=max\&auto=format\&n=SZGi8yiMYy_JzZIR\&q=85\&s=844e3b9f3b0058e72da88ac5c5b3de1a)

An auto-heal pull request records the root cause, fix, and validation

When a heal opens a pull request, two optional toggles in the same settings
control who is added to it: **Assign original commit authors to pull requests**
adds the original authors of the healed tests as assignees, and **Request
original commit authors as reviewers** requests those same authors as reviewers.
Both draw on the same participants (the source pull request's assignees plus the
commit authors and co-authors that GitHub resolves for the change) and default
to off.

The [`--on-heal-success`](https://momentic.ai/docs/cli-reference/momentic/commands/ai#triage) flag
overrides the first five modes for one run. **Follow triage skill** and **AI
routing** can only be enabled from the dashboard.

#### AI routing

Set [**On successful heal**](https://app.momentic.ai/settings/triage) to **AI
routing** to choose delivery separately for each repaired issue:

* **The branch under test caused the failure.** Triage commits the repair to
  that branch, or opens a pull request when the run is on the main branch.
* **Another cause is responsible.** Triage opens a separate pull request against
  the main branch and assigns it from commit and pull-request evidence.
* **A fix already exists.** Triage references the existing pull request instead
  of creating a duplicate.

AI routing requires
[`gitMainBranch`](https://momentic.ai/docs/configuration/momentic-config#gitmainbranch) and the
[GitHub integration](https://momentic.ai/docs/integrations/github.md). If routing cannot complete, Momentic
delivers the repair on the current branch and logs the reason.

#### Failed heals

The [**On failed heal**](https://app.momentic.ai/settings/triage) Triage setting
controls what happens to tests the agent cannot repair:

* **warn** (default): report the failure and the agent's reasoning.
* **fail**: exit non-zero.
* **quarantine**: exit non-zero and quarantine the unfixed tests.

The `--on-heal-fail` flag overrides it for one run.

### Circuit breaker

When a run group has **at least 20 failures and at least 50% of its tests
failed**, triage is skipped and the command exits non-zero with the reason: a
suite failing at that scale points to a single outage, not many separate bugs.
Quarantined and recovered runs do not count toward either number, and runs named
with `--run-id` are always triaged. Triage resumes on the next run.

If a recurring flake cannot yet be repaired, contain it with
[quarantine](#quarantine).

## Quarantine

Quarantine keeps a flaky test running without failing the build. The run remains
visible in the dashboard as a quarantined failure, so you keep the evidence
needed to fix it.

Quarantine a test with a reason:

```bash theme={null}
npx momentic quarantine add <test> --reason <reason>
```

You can also quarantine from the run viewer or the dashboard's **Quarantine**
page. Quarantine rules can act automatically based on pass rate, failure count,
flake rate, or [transient failure recovery](#failure-recovery) usage. See the
[`momentic quarantine` reference](https://momentic.ai/docs/cli-reference/momentic/commands/quarantine)
for commands and rule options. A failure count rule can count only failures of
CLI runs classified into chosen categories; unclassified failures do not count.

Quarantine should be temporary. Continue investigating, then remove the
quarantine when the test is stable.

## Related

* [Maintain tests with a coding agent](https://momentic.ai/docs/coding-agents/skills.md#maintenance)
* [How regression tests work](https://momentic.ai/docs/get-started/how-momentic-works.md)
* [Results and reporting](https://momentic.ai/docs/running-tests/results.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.