> ## 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, 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, a separate product from the YAML test framework: its npm package and CLI are `qa` (not `mo` — `npx mo` is a different project). Install with `npm install -g qa`, authenticate the same MOMENTIC_API_KEY way, install repo skills with `qa skills -y`, and start a session with `qa start "<brief>"` or `qa <url>`. Docs: https://momentic.ai/docs/mo.md.
> You cannot complete the browser sign-in yourself. Read the API key from the exact MOMENTIC_API_KEY environment variable (similarly named vars like BILT_MOMENTIC_API_KEY are ignored), or ask the user to create one at https://app.momentic.ai/settings/api-keys and paste it back.
> Momentic's capability summary for agents is at https://momentic.ai/docs/skill.md. Install the skills with `npx momentic skills --yes` (or `npx momentic-mobile skills --yes` for mobile).
> 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. Physical devices are not supported.

# Generate tests from a pull request diff

> Use a coding agent with the momentic-spec skill to turn a pull request's changed journeys into Momentic tests.

A coding agent with the Momentic MCP server and the
[`momentic-spec` skill](/docs/coding-agents/skills#spec-driven-development) reads a
pull request diff and identifies the affected user journeys. It updates existing
tests or adds `.test.yaml` specifications in the working tree so the expected
behavior enters review with the code.

## Setup

Both come from the CLI, documented in
[Building with AI](/docs/coding-agents/building-with-ai):

```bash theme={null}
npx momentic install-mcp   # registers the MCP server with your agents
npx momentic skills --yes  # installs the Momentic skills, including momentic-spec
```

The agent needs a `MOMENTIC_API_KEY` in its environment and a reachable app to
test: the PR's dev server, a preview deploy, or staging.

## In your coding agent

Inside Claude Code, Cursor, Codex, or another agent with the Momentic MCP server
and skills installed:

```text theme={null}
/momentic-spec cover the user journeys changed by this pull request
```

The agent reviews repository guidance and existing coverage before editing the
tests. At a usable end-to-end checkpoint, it prepares the required state and
runs the smallest affected set, with confirmation for long runs. The tests enter
review on the same branch and can use the suite's existing CI job.

Point the agent at the diff when the default scope is too broad, for example
`/momentic-spec cover the checkout changes in src/payments/`. A repo-level agent
rules file (`CLAUDE.md`, `AGENTS.md`, `.cursor/rules`) that names your app URLs
and auth path keeps every run consistent.

<Note>
  For autonomous bug finding rather than diff-scoped tests, use [Mo](/docs/mo).
</Note>

## What to expect

* Generated tests cover *journeys* (sequences a user can take), not unit-level
  coverage. They complement, not replace, tests you write deliberately.
* Review for intent: delete steps that assert incidentals, tighten
  postconditions to the actual contract of the change.
* Tests are most valuable on the diff that motivated them. If a generated test
  would have caught this PR's bug, keep it; if it only re-asserts unchanged
  behavior, drop it.

## Related

* [AI test selection](/docs/ai/select): the complementary direction. It picks
  existing tests to run for a diff.
* [Coding agent skills](/docs/coding-agents/skills)
* [Common CI setups](/docs/guides/common-setups)


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