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

# How Momentic works

> How Momentic combines preset steps, AI actions, modules, execution, CLI-based agents, and context from past runs.

## Anatomy of a test

A Momentic test is a sequence of steps. There are many step types: some rely on
AI, while others can be configured deterministically or execute code.

### Human in the loop <em>and</em> agentic

| Step type       | Behavior                                                                     | Examples                                               |
| --------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------ |
| **Preset step** | Executes one configured action. It can use AI or be fully deterministic.     | Click, Type, JavaScript, AI extract, and Drag and drop |
| **AI action**   | A runtime agent determines and executes the sequence needed to reach a goal. | Complete checkout or configure an account              |
| **Module**      | Runs a reusable sequence of preset steps or AI actions.                      | Log in, create an account, or seed a cart              |

Mix preset steps, AI actions, and module calls within one test. Modules can also
combine preset steps and AI actions. Use preset steps when the path needs exact,
reviewable control and agentic steps when the goal matters more than the path.
Preset steps can still use AI to locate elements, evaluate assertions, or
extract data while keeping the sequence explicit.

See [Test structure](/docs/core-concepts/test-format) for the YAML format, variables,
and modules. See [AI action](/docs/core-concepts/agentic-testing) for goal-driven
flows.

### Code integration

Web tests run on Playwright and mobile tests run on Appium. Use preset steps for
common interactions, then drop to code when a flow needs it:

* [JavaScript steps](/docs/integrations/javascript) run custom code in a sandboxed
  Node environment or the current browser page.
* [Appium steps](/docs/reference/mobile-commands/appium) execute Appium scripts
  against the current device.
* [Modules](/docs/core-concepts/modules) and [variables](/docs/core-concepts/variables)
  connect reusable setup, application state, and data across the flow.

## Run locally and in CI

A test provides immediate feedback during development and repeatable
verification after a change leaves a developer's machine. The same test files
and CLI work in both loops:

| Environment           | Value                                                                                                                                                         |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Local development** | Run focused tests while you code, inspect artifacts immediately, and let a coding agent verify its own changes before a pull request.                         |
| **CI**                | Gate pull requests and deployments, select the most relevant tests based on a code change, parallelize larger suites, and publish results for the whole team. |

Use [`momentic run`](/docs/cli-reference/momentic/commands/run) locally or in your
[CI system](/docs/running-tests/ci/custom-setups). [AI test selection](/docs/ai/select)
keeps pull-request feedback focused, while
[AI test maintenance](/docs/reliability/auto-maintenance) turns eligible failures
into recovery, diagnosis, and reviewable repairs.

## CLI-based agents

Momentic exposes its AI agents through the CLI so they can be composed in CI,
scripts, and custom agent loops:

| Command                | Role                                                  |
| ---------------------- | ----------------------------------------------------- |
| `momentic ai explore`  | Discover changed journeys and author missing coverage |
| `momentic ai select`   | Choose representative tests for a code change         |
| `momentic ai classify` | Explain and route failed runs                         |
| `momentic ai triage`   | Investigate, repair, and verify failing tests         |

Commands can emit structured output and operate on repository files or saved
results, so your orchestrator decides when they run and what happens next. See
the [`momentic ai` reference](/docs/cli-reference/momentic/commands/ai) and
[MCP server](/docs/coding-agents/mcp-server).

## Self-learning system

Momentic reuses context across runs:

* The [step cache](/docs/reliability/step-cache) reuses successful element
  resolutions for fast, deterministic replay.
* [Memory](/docs/ai/memory) retrieves relevant decisions from earlier runs for
  locator and assertion agents.
* The [app graph](/docs/ai/app-graph) turns run traces into product journeys and
  coverage, powering [AI test selection](/docs/ai/select) and product risk analysis.
* The [knowledge base](/docs/ai/knowledge-base) adds your terminology, rules, and
  known flows. Your team can customize it from the dashboard.

See [What is AI-native testing?](/docs/get-started/ai-native-testing) for the
end-to-end developer workflow.
