# Set up Hatch with an agent

This page is for AI agents setting Hatch up for someone: Claude Code, Codex, Cursor or any other. If you're a person, copy the prompt below into your agent.

> Set up Hatch for me. Follow https://hatch-docs.pages.dev/get-started/set-up-hatch-with-an-agent.md and read the pages it links before you run anything.

## Rules for agents

- **Don't set Hatch up from memory.** Package names, commands and options change between versions. Run the commands on this page, and read the linked pages as Markdown before you use anything they describe.
- **Every page is Markdown.** Add `.md` to any page's address. The list of pages is at https://hatch-docs.pages.dev/llms.txt, and every page in one file is at https://hatch-docs.pages.dev/llms-full.txt.
- **The vault is the person's.** Never rewrite or reformat a note you weren't asked to change, and keep any field you don't understand. Read the vault's own `AGENTS.md` before filing anything.
- **Ask before anything public.** Deploying a site or publishing a package puts it on the internet. Check with the person first.

## Pick what the person wants

| They want to | Do this |
|---|---|
| Give you their notes | Connect the MCP server (below) |
| Use the app | Run it from the repo, see [Quickstart](https://hatch-docs.pages.dev/get-started/quickstart/) |
| Publish a folder as a site | Build it with `hatch-site`, see [Site templates and style](https://hatch-docs.pages.dev/publishing/site-templates-and-style/) or [Docs sites](https://hatch-docs.pages.dev/publishing/docs-sites/) |
| Move a docs site to Hatch | Run `hatch-migrate`, then follow [Moving a docs site to Hatch](https://hatch-docs.pages.dev/publishing/moving-a-docs-site-to-hatch/) |
| Add Hatch to their own app | Install the packages, see [React hooks](https://hatch-docs.pages.dev/building-on-hatch/react-hooks/), [Agent memory with the AI SDK](https://hatch-docs.pages.dev/agents/agent-memory-with-the-ai-sdk/) or [Hatch's shadcn registry](https://hatch-docs.pages.dev/building-on-hatch/hatch-s-shadcn-registry/) |

## Connect the MCP server

Ask which folder is their vault, then add the server. For Claude Code:

```sh
claude mcp add hatch -- npx -y @hatchmd/mcp /path/to/vault
```

[Connect an agent](https://hatch-docs.pages.dev/agents/connect-an-agent/) has the setup for Codex, Cursor and Claude Desktop. Once it's connected, call `vault_guide` first. It returns the vault's folders, tags, properties, templates and filing rules. Search before you create a note, and link notes with `[[Note]]`.

If the vault has no `AGENTS.md` yet, offer to write one with the person: where meetings, people and projects go, which tags to use, and what not to touch.

## Build a site

```sh
npx -y -p @hatchmd/publish hatch-site build /path/to/vault --out site
```

The vault needs a `.hatch/site.json` first. The app writes it from Settings, Publish, along with a JSON schema beside it (`site.schema.json`). By hand, the smallest one names the site, its kind (`blog`, `docs` or `portfolio`) and the folders it publishes:

```json
{ "title": "Notes", "kind": "blog", "folders": ["Blog"] }
```

`npx -y -p @hatchmd/publish hatch-site preview /path/to/vault` serves the site on localhost and rebuilds on every change. Check the site in light and dark, at desktop and phone width, before you tell the person it's done.

## Check your work

- After connecting the server, call `vault_guide` and tell the person what it found.
- After building a site, open the home page and one inner page, and check that the build printed no problems.
- After installing a package, run the project's own type check and build.
