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

# Building with AI

> Mercur ships version-matched docs inside your project so AI coding agents build from accurate APIs instead of stale training data.

Mercur is built so AI coding agents work from **accurate, version-matched documentation** instead of their training data — which is almost always out of date for a fast-moving framework. The docs ship *inside your project's dependencies*, and your project tells agents to read them before writing any code.

<Info>
  **Why agents do well here.** Every extension surface an agent touches has a machine-checkable contract: routes generate the [typed client](/rc/tools/api-client) (wrong calls fail to compile), pages follow [file conventions](/rc/resources/customization/extending-panels) the SDK validates at build time, and blocks are diffable source. An agent doesn't need to guess whether its change works — the toolchain tells it.
</Info>

## How it works

When you install a Mercur project, the documentation is bundled as a dependency at `node_modules/@mercurjs/docs/`. It mirrors the structure of this site:

```txt theme={null}
node_modules/@mercurjs/docs/
├── llms.txt              # index: every page with a one-line description
└── content/
    ├── learn/            # concepts — sellers, products, offers, commissions…
    ├── resources/        # tutorials, integrations, deployment, this guide
    ├── tools/            # CLI, API client, dashboard SDK
    ├── references/       # module, HTTP API, and configuration reference
    └── user-guide/       # admin and vendor panel usage
```

Because the docs travel with the package, an agent always has documentation that **matches your installed version** — no network request, no external lookup, and no drift between what the agent reads and what your code actually runs.

## Set up your project

### New projects

Projects created with `bunx @mercurjs/cli@rc create` are ready out of the box. The template ships:

* `@mercurjs/docs` as a dependency, so the docs land in `node_modules` on install
* an `AGENTS.md` and a `CLAUDE.md` at the project root that tell agents to read the bundled docs first

Most AI coding agents — Claude Code, Cursor, GitHub Copilot, and others — read `AGENTS.md` automatically when they start a session. There is nothing else to configure.

### Existing projects

Add the docs dependency:

```bash theme={null}
bun add @mercurjs/docs
```

Then create an `AGENTS.md` at the project root with a single, focused instruction:

```md AGENTS.md theme={null}
# Mercur: read the docs before coding

Before any non-trivial change, read the bundled documentation — it is
version-matched to this project's installed packages, and far more accurate
than training data.

1. Read the index: `node_modules/@mercurjs/docs/llms.txt`
2. Open the pages it points to under `node_modules/@mercurjs/docs/content/`

Don't guess at an API, data model, or file convention the docs already describe.
```

[Claude Code](https://docs.anthropic.com/en/docs/claude-code) reads `CLAUDE.md`; point it at the same instructions instead of duplicating them:

```md CLAUDE.md theme={null}
@AGENTS.md
```

## What the agent reads

The workflow is deliberately simple: **index first, then the page.** An agent reads `llms.txt` to see what exists, then opens the one or two `content/` pages relevant to the task before implementing. The bundled docs cover the full domain model (sellers, products, offers, attributes, commissions, payouts, order groups), the CLI, the typed API client, the dashboard SDK, module references, and how-to guides — so the agent looks up the correct contract rather than inventing one.

## Verify its work

Mercur gives an agent a fast, machine-checkable way to know whether a change is correct — the equivalent of a grading loop it can run itself:

| Check                              | What it proves                                                |
| ---------------------------------- | ------------------------------------------------------------- |
| `bun run build`                    | Types resolve and the generated client matches the routes     |
| `bun run lint`                     | Code conforms to the project's rules                          |
| Integration tests (`packages/api`) | Backend behavior still holds                                  |
| `bunx @mercurjs/cli@rc diff`       | Local blocks vs. the registry — what changed and what drifted |

Because these are objective, an agent can define what "done" looks like, run the checks, read the output, and iterate until they pass — instead of stopping at "looks plausible."

## Beyond bundled docs

The bundled docs are for agents working *inside your project*. For chat assistants and hosted tools, Mercur also publishes its docs online:

<CardGroup cols={2}>
  <Card title="llms.txt" href="/rc/resources/ai/llms">
    Feed the full documentation to Claude, ChatGPT, or any LLM.
  </Card>

  <Card title="MCP server" href="/rc/resources/ai/mcp">
    Let your editor search the docs live via Model Context Protocol.
  </Card>
</CardGroup>
