# AI and editors

Hamur gives a coding agent and an editor the same three things: docs that match the installed version, the app's structure as data, and the errors, logs and routes of the running dev server. They come as files and one endpoint. Nothing here adds a dependency, makes a request you did not ask for, or puts code in `.output/`.

## Docs for agents

Every docs page is also served as Markdown, with its code samples in place: add `.md` to the page's URL. `/llms.txt` lists every page by group with its first sentence, and `/llms-full.txt` holds them all in one file. Fetch the Markdown of the page an agent should read, and nothing else.

````sh [ai/fetch-docs.sh]
curl https://server.hamur.dev/llms.txt
curl https://server.hamur.dev/getting-started.md
````

The `hamur` package carries the same Markdown for the version you installed, in `node_modules/hamur/docs/`: `docs/<path>.md` is the page `/<path>`, and `docs/index.md` is the home page. An agent should read that folder first, because the web shows the latest version. [Hamur for coding agents](/agents/hamur) is the long instructions to start from.

## The docs MCP server

The docs answer the [Model Context Protocol](https://modelcontextprotocol.io) at `https://server.hamur.dev/api/mcp`, so an agent asks instead of fetching pages. The server needs no sign-in. It has three read-only tools:

| Tool          | Input                                  | Answers                                                                                                      |
| ------------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `search_docs` | `query`, `limit?` (1 to 20, default 8) | the best matching sections, best first, each with its page `path`, `title`, `titles`, `url` and `score`      |
| `get_page`    | `path`                                 | the page's `title` and its `markdown`, as `/<path>.md` serves it                                             |
| `list_api`    | `symbol?`                              | where the API reference documents a symbol: `symbol`, `path`, `anchor` and `url`; no `symbol` lists them all |

Add it to Claude Code with one command:

````sh [ai/mcp-claude.sh]
claude mcp add --transport http hamur-docs https://server.hamur.dev/api/mcp
````

Cursor reads `.cursor/mcp.json`:

````json [ai/mcp-cursor.json]
{
  "mcpServers": {
    "hamur-docs": { "url": "https://server.hamur.dev/api/mcp" }
  }
}
````

VS Code reads `.vscode/mcp.json`:

````json [ai/mcp-vscode.json]
{
  "servers": {
    "hamur-docs": { "type": "http", "url": "https://server.hamur.dev/api/mcp" }
  }
}
````

An app can serve its own MCP endpoint too; that is a different thing, described in [MCP](/mcp).

## Agent files

`hamur init` writes `AGENTS.md` with the agent rules block, the text between `<!-- hamur:begin -->` and `<!-- hamur:end -->`. It names your library and adapter, tells the agent to read `node_modules/hamur/docs/agents/hamur.md` first, says where pages, layouts, loaders and server code live, and gives your package manager's `typecheck` command. For one version and one library every app has the same block, and nothing outside the markers is touched.

`hamur agents` is the only writer of the block. `hamur upgrade` runs it after the install, so the block follows the version. `--check` writes nothing and exits `1` when the block is missing or differs.

````sh [ai/agents.sh]
hamur agents
hamur agents --check
````

Set `agentRules: false` to keep `AGENTS.md` as you wrote it: `hamur agents` and the step of `hamur upgrade` then leave it alone. The flags and exit codes are on the [CLI page](/cli#hamur-agents), the key in [Configuration](/configuration#hosts-links-and-more).

````ts [ai/agent-rules-config.ts]
import { defineConfig } from "hamur"

export default defineConfig({
  framework: "react",
  agentRules: false,
})
````

Hamur does not write `CLAUDE.md`. An agent that reads `CLAUDE.md` and not `AGENTS.md` needs one line in it:

````txt [ai/claude-md.txt]
@AGENTS.md
````

The package also carries a skill, `node_modules/hamur/skills/hamur/SKILL.md`, which tells an agent when to read the docs and where. Hamur writes nothing into `.claude/` or any other agent folder. For Claude Code, link the skill once:

````sh [ai/skill-link.sh]
mkdir -p .claude/skills
ln -s ../../node_modules/hamur/skills/hamur .claude/skills/hamur
````

Another agent that loads skills from a folder takes the same directory in its own folder.

## The dev MCP endpoint

While `hamur dev` runs, it answers MCP at `POST <app.baseURL>_hamur/dev/mcp`, so an agent asks the running app what went wrong. Its seven tools, their inputs and the rule that guards the endpoint are in [Dev server](/dev-server#the-dev-mcp-endpoint-for-coding-agents): `get_errors`, `get_logs`, `get_routes`, `get_page`, `compile_route`, `get_config` and `get_handlers`. `devServer.mcp: false` turns it off.

An agent starts the server, finds it and stops it with the dev commands. `--background` starts the server detached, waits until it serves and prints the `Local:` URL, the dev MCP URL and the log file `.hamur/dev.log`.

````sh [ai/dev-background.sh]
hamur dev --background
hamur dev status
hamur dev logs -n 20
hamur dev stop
````

`status` exits `0` when the server runs and `1` when not; `logs` prints the end of `.hamur/dev.log`, which only `--background` writes; `stop` ends the server and frees its port. Every `hamur dev` keeps the **dev lock**, `.hamur/dev.lock`, a JSON file that tells another process which server runs:

````json [ai/dev-lock.json]
{
  "version": 1,
  "pid": 48213,
  "startedAt": "2026-12-01T09:14:02.511Z",
  "url": "http://localhost:3000/",
  "port": 3000,
  "mcp": "http://localhost:3000/_hamur/dev/mcp"
}
````

`version` is `1`. `pid` and `startedAt` name the process; `identity`, the process start time the system reports, is added where it can be read, so a reused pid is not taken for the server. `url` and `port` are missing while the server starts, and `mcp` is missing with `devServer.mcp: false`. Read the `mcp` URL from the lock and register it:

````sh [ai/dev-mcp-claude.sh]
claude mcp add --transport http hamur-dev http://localhost:3000/_hamur/dev/mcp
````

The commands are in the [CLI page](/cli#hamur-dev), and the agent rules block tells the agent to call `get_errors` after an edit.

## The routes file

`.hamur/routes.json` holds the app's routes as a file, so an editor or a script reads them without starting Hamur. `hamur typegen`, `hamur build` and `hamur dev` write it, and only when its bytes change. Files are relative to the project root. Within `version: 1` fields are only added, so ignore the ones you do not know.

````json [ai/routes.json]
{
  "version": 1,
  "pages": [
    { "name": "index", "path": "/", "file": "app/pages/index.tsx" },
    {
      "name": "about",
      "path": "/about",
      "file": "app/pages/about.tsx",
      "loader": "app/pages/about.load.ts",
      "layout": "default",
      "middleware": ["auth"]
    }
  ],
  "server": [{ "path": "/api/posts", "method": "GET", "file": "server/posts.ts" }]
}
````

## No TypeScript plugin

Hamur ships no language-service plugin. TypeScript 7, which the react, preact, solid and html starters use, has no `tsserver` to load one into, and the editors of Vue and Svelte take a plugin only through their own configuration. What a plugin would check, the types and the build already do:

- `layout` of a page's `meta` is a union of the layout names the build found, and `middleware` takes imported functions, which go-to-definition follows. Write the object with `satisfies PageMeta`, and a wrong layout name or a middleware name is an error in every editor.

````tsx [react/admin-page.tsx]
import type { PageMeta } from "hamur/app"
import auth from "../middleware/auth.ts"

export const meta = {
  layout: "admin",
  middleware: [auth],
} satisfies PageMeta

export default function AdminHome() {
  return <h1>Admin</h1>
}
````

- An export of an `x.load.ts` that Hamur does not read, such as `laod`, is the warning [HAMUR_W1242](/errors/HAMUR_W1242) with a suggestion, printed by `hamur dev`, `hamur build` and `hamur typegen`.

## The VS Code extension

The Hamur extension, id `hamur.hamur-vscode`, is its own project in the repository `productdevbook/hamur-vscode`. It has no dependency and runs the `hamur` of your app. It gives you:

- A **Hamur routes** view built from `.hamur/routes.json`: pages by path, then server routes; each node opens its file, and a page lists its loader, layout and middleware.
- The command **Hamur: Go to Load / Page**, which moves between a page and its `x.load.ts`.
- Snippets `hhandler`, `hmeta` and `hload`.
- `hamur typegen` after a file under `app/pages/`, `app/layouts/` or `server/` changes, from the app's own `node_modules/.bin/hamur`. It does not run while `.hamur/dev.lock` names a live server, in an untrusted workspace, or when `hamur` is not installed.
- The dev MCP endpoint, offered to the editor's agent while the dev lock is live.

Version 0.1.0 is a `.vsix` on the GitHub release of that repository; the Marketplace listing comes later. Install the file:

````sh [ai/vscode-install.sh]
code --install-extension hamur-vscode-0.1.0.vsix
````
