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

# Coding agents

> Let Claude Code, Codex, or Cursor write, run, and debug e2e tests with the e2e skill, a live app session over the e2e MCP server, and trace reports.

A coding agent such as Claude Code, Codex, or Cursor can write, run, and
debug e2e tests. It learns e2e from the skill, uses the app through the
`e2e mcp` server, and reads the trace page of a failed test.

## Install the skill

<CodeGroup>
```bash npm
npx e2e init
```

```bash pnpm
pnpm dlx e2e init
```

```bash bun
bunx e2e init
```
</CodeGroup>

| Path | Used by |
| --- | --- |
| `.agents/skills/e2e/` | Codex, Cursor, OpenCode, and other agents that read `.agents/skills` |
| `.claude/skills/e2e/` | Claude Code. A symlink to `.agents/skills/e2e/` when both are installed. |

`init` writes `SKILL.md` and topic references there, and
[`e2e upgrade`](https://e2e.com/docs/reference/cli#e2e-upgrade) keeps them up to date. It also
adds a pointer to `AGENTS.md` (and to `CLAUDE.md`, with the `.claude/skills`
path), creating the file if needed, so a prompt like "add a test for
checkout" picks up the skill:

```md title="AGENTS.md"
End-to-end tests use e2e; read .agents/skills/e2e/SKILL.md before writing or running one.
```

Without `init`, install the skill with `npx skills add e2e-inc/e2e` and add
that line yourself, or print the skill with `npx e2e guide [topic]`. The
package also ships these docs offline in `node_modules/e2e/docs/`.

Claude Code, Codex, and Cursor can also install the three e2e skills as a
[plugin](https://e2e.com/docs/reference/cli#plugins-and-skill-registries), and pnpm can
[link the skill](https://e2e.com/docs/reference/cli#skills-linked-by-pnpm) instead of keeping a
copy.

## Let the agent use the app

`e2e mcp` is an MCP server that gives the agent a live session on your app,
on web, iOS, or Android. The agent sees the screen, acts on it, and checks
its work.

| Task | Without `e2e mcp` | With `e2e mcp` |
| --- | --- | --- |
| Write a test | Guesses locators, runs, fails, guesses again | Writes the test as it walks the flow, from test lines the session checked |
| Change the UI | Done when it compiles | Opens the page and checks the result |
| Reproduce a bug | Guesses from the code | Follows the steps in the app |
| Fix a failing test | Clicks through the flow again | Runs the test and stops on the failure |
| Show a change in a PR | Describes it | Records a video |

The server doesn't need a model. You only need one if the agent runs a test
with an uncached agent step.

### Register the server

`e2e init` offers to write the registration for Claude Code, Cursor, and
Codex, and the Codex and Cursor plugins include the server. To add it by
hand, install your dependencies and start the client in the project
directory:

<Tabs>
  <Tab title="Claude Code">
    ```json title=".mcp.json"
    {
      "mcpServers": {
        "e2e": { "command": "npx", "args": ["e2e", "mcp"] }
      }
    }
    ```
  </Tab>
  <Tab title="Codex">
    ```toml title=".codex/config.toml"
    [mcp_servers.e2e]
    command = "npx"
    args = ["e2e", "mcp"]
    ```
  </Tab>
  <Tab title="Cursor">
    ```json title=".cursor/mcp.json"
    {
      "mcpServers": {
        "e2e": { "command": "npx", "args": ["e2e", "mcp"] }
      }
    }
    ```
  </Tab>
  <Tab title="OpenCode">
    ```json title="opencode.json"
    {
      "$schema": "https://opencode.ai/config.json",
      "mcp": {
        "e2e": { "type": "local", "command": ["npx", "e2e", "mcp"] }
      }
    }
    ```
  </Tab>
</Tabs>

Trust the project in Codex, and start a new session in any client. If your
target defines an `app.command`, the session starts your app and prints its
URL and port. The config reads the MCP server's environment, not your
agent's shell.

See [Setup](https://e2e.com/docs/reference/mcp#setup) for `claude mcp add`, other package
managers, and a `Connection closed` error. Without an `e2e.config.ts`, the
agent opens a session by [naming the engine](https://e2e.com/docs/reference/mcp#without-a-config).

## Ask the agent

- "Add a Remember me checkbox to the login form. Check it in the app with e2e."
- "Write a test for checkout while you walk it in the app."
- "Reproduce issue #123 in the app and record a video."

Add "headed" to watch a local browser or simulator.

## How an agent writes and runs a test

The skill tells your agent to read your config and an existing test first.
With `e2e mcp`, it then walks the flow in a session. Each action answers
with the [test line](https://e2e.com/docs/reference/mcp#test_lines) that repeats it, and the
agent tries any other line, such as an assertion, with
[`run_code`](https://e2e.com/docs/reference/mcp#run_code) before it writes it:

```text wrap
Tapped #n31.
Test line: await screen.getByRole("button", "Sign in").tap();
```

Each test checks one behavior: arrange the starting state, act toward one
goal, then check the outcome at the end.

```ts title="tests/shop.e2e.ts"

test('filters the shop to items under $20', { session: 'customer' }, async ({ app, agent, screen }) => {
  const results = screen.getByRole('status', 'Results');
  const products = screen.getByRole('list', 'Products').getByRole('listitem');
  await app.open('/shop');
  await results.waitFor();
  await products.filter({ hasText: 'Leather Backpack, $90' }).waitFor();

  await agent.act('show only items under $20');

  await expect(results).toHaveText('2 items under $20');
  await expect(products).toHaveText(['Canvas Tote, $14', 'Steel Bottle, $18']);
});
```

- **One behavior and one [goal](https://e2e.com/docs/core-concepts#goals) per test.** The agent
  [splits a long flow](https://e2e.com/docs/agent-steps#split-a-long-flow-into-goals)
  only when a later step needs a known state. The check at the end also
  confirms the [recording](https://e2e.com/docs/cache#when-a-recording-is-written).
- **Named locators, no sleeps.** A locator the test uses twice, like
  `results`, is a `const`, so a renamed control is one edit. Locators poll,
  actions wait for their target, and `expect` retries until its timeout.
- **A separate session for each user, and no secrets in the test.** A
  [setup test](https://e2e.com/docs/authentication) signs in with `credentials.user(name)` and
  saves that user's session. A flow like chat
  [opens a second session](https://e2e.com/docs/core#open-a-host-inside-a-test), which gets its
  secrets through `launch({ secrets })`.

While iterating, the agent runs only the test it's editing, by line number,
as in `npx e2e run tests/checkout.e2e.ts:3 --action-timeout 5000`, so a
wrong locator fails in 5 seconds instead of 30. It keeps the replay cache
on, and once the test passes it drops `--action-timeout` and runs the test
once with `--no-cache`: see
[Rerun a test while you fix it](https://e2e.com/docs/cache#rerun-a-test-while-you-fix-it).

<a id="run-tests-next-to-a-session" />

A session can stay open during `e2e run` unless the two
[collide on a port or a mobile device](https://e2e.com/docs/reference/mcp#running-tests-beside-a-session).
Each agent, subagents included, opens [its own session](https://e2e.com/docs/reference/mcp#several-sessions).

## How an agent reads a failure

The terminal prints the path of a [trace page](https://e2e.com/docs/debugging#traces) under each
failure (`❯ trace .e2e/results/<test>/trace.md`). The agent reads `trace.md`
rather than the raw `report.json`: it has the failing line, every step's
target and outcome, console errors, failed network requests, the agent's
last turns, and the screen at failure.

- **A screen that isn't in the trace.** The agent opens that URL in a
  session instead of walking the flow again.
- **The failing screen itself.** `open_session {test: "tests/checkout.e2e.ts:12"}`
  [runs the test in a session](https://e2e.com/docs/reference/mcp#running-a-test) and stops
  where it failed. The agent fixes the line there.
- **Individual model calls.** The agent reruns with `--ai-trace --no-cache`
  and reads the output with [unbox-ai](https://e2e.com/docs/debugging#agent-steps), never the
  raw `ai-trace.json`: it repeats prompts across turns and can grow to
  several megabytes.

## Generate a verification skill for your app

The `e2e` skill teaches the framework, not your app. The
`create-verification-skill` skill writes a project-local
`.agents/skills/verify-<app>/` skill for your app and tests it once before
finishing. Install it with the plugin or with
`npx skills add e2e-inc/e2e --skill create-verification-skill`, then ask the
agent for `/create-verification-skill`. Installed with the plugin, it is
`/e2e:create-verification-skill` in Claude Code and
`$e2e:create-verification-skill` in Codex.

The generated skill holds the launch and doctor commands from your config,
the two ways to drive the app (a live `e2e mcp` session and a test), the
evidence a proof keeps, and a feature map with one `e2e explore` charter for
each feature, so a [bug bash](https://e2e.com/docs/explore#bug-bashes) fans out from the map. It
is based on
[create-verification-skill](https://github.com/cursor/plugins/tree/main/pstack/skills/create-verification-skill)
from poteto's pstack, with e2e in place of a hand-rolled harness.

## Migrate an existing suite

The `migrate-to-e2e` skill moves a Playwright, Cypress, Selenium, Appium,
Detox, Maestro, or TesterArmy suite to e2e one slice per session, while the
old suite keeps running. See
[Let an agent migrate the suite](https://e2e.com/docs/migrate#let-an-agent-migrate-the-suite).

## Next

<CardGroup cols={2}>
  <Card title="MCP server reference" icon="book" href="/reference/mcp">
    Every tool, flag, session rule, and error code.
  </Card>
  <Card title="Debugging a run" icon="bug" href="/debugging">
    The report, the artifacts, and the agent flags.
  </Card>
</CardGroup>
