# Cursor

> Use midcode beside Cursor on the same project, run Cursor's CLI agent in midcode's terminal view, and copy references and briefs Cursor can act on.

- Page: https://midcode.app/docs/agents/cursor
- From the midcode docs. Every page as Markdown: https://midcode.app/llms.txt

Cursor works with midcode in two ways. Its CLI agent runs inside midcode's Agent panel, in the Terminal view. And the Cursor app runs beside midcode on the same folder: you copy from the canvas what Cursor needs to know, and the canvas shows what Cursor saves.

Cursor does not run in midcode's Chat view. That view is for [Claude Code](https://midcode.app/docs/agents/claude-code.md), [Codex](https://midcode.app/docs/agents/codex.md), [Gemini CLI](https://midcode.app/docs/agents/gemini-cli.md) and [OpenCode](https://midcode.app/docs/agents/opencode.md).

## At a glance

| What | How |
| --- | --- |
| In the Agent panel | Terminal view only, as "Cursor Agent" |
| midcode starts | `cursor-agent`, typed into a login shell |
| Needs on your Mac | Cursor's CLI, signed in with your Cursor account |
| Cursor's edits | On the canvas and in Publish's changed files; undone in Cursor or with git, not with midcode's `⌘Z` |

## Cursor's CLI in the Terminal view

1. Install Cursor's CLI, if you don't have it. This is the command midcode shows when it can't find it (see [cursor.com/cli](https://cursor.com/cli)):

   ```bash
   curl https://cursor.com/install -fsS | bash
   ```

2. In midcode, open the Agent panel and switch it to the Terminal view ("Show as a terminal").
3. Choose "Cursor Agent" in the "Agent" menu. midcode opens a login shell in your project's folder and starts it. Sign in there if it asks.

Cursor's CLI installs under two names, so midcode finds it as either and types this:

```bash
cursor-agent || agent
```

With an element selected, "Send the selection to the agent" in the panel's header pastes its reference into the agent's prompt, and "Send the open comments to the agent" pastes your open comments. Nothing is sent until you press `Enter`.

## The Cursor app beside midcode

Open the same project folder in both. There's nothing to connect: midcode runs your real dev server, so whatever Cursor saves shows on the canvas at every breakpoint, and Publish lists the files it changed next to yours.

### Copy a reference

Select an element and press `⌘C` (or "Copy reference for your agent" in the right panel). midcode keeps the element for pasting on the canvas and puts this on the clipboard, ready for Cursor's chat:

```text
<h1> "Built to outlast"
written at src/components/Hero.tsx:14:7
inside src/app/page.tsx:9:5
page / · Desktop 1440px
```

It says what the element is, its text, where its opening tag is written (`file:line:col`), the files it sits inside, and the page and breakpoint you were looking at. With several elements selected, right-click and choose "Copy references for your agent".

### Copy your comments

Comments you pin on the canvas are saved in your project, in `.midcode/comments.json`, where Cursor can read them. "Copy open comments for your agent", in the Comments list, puts them on the clipboard as one Markdown brief. It's grouped by page, and each comment has a heading with its number, page, breakpoint and whether it's open, then this:

```md
- **Element:** `<h1>` · "Built to outlast"
- **Written at:** `src/components/Hero.tsx:14:7`
- **Inside:** `src/app/page.tsx:9:5`
- **Where on it:** 50% across, 50% down

> Make this one line on desktop
```

Files attached to a comment are listed with their path inside the repository. More in [Comments](https://midcode.app/docs/editor/comments.md).

### Open the file in Cursor

In Settings (`⌘,`), set "Code editor" to Cursor. "Automatic" already picks Cursor when it's in your Applications folder. Then "Open in your code editor", in midcode's code pane, opens the file in Cursor at the line you were on. To get to the pane from the canvas, right-click an element and choose "Open code".

## Editing at the same time

midcode and Cursor write the same files:

- midcode reads the file again for every edit and changes only the characters of that edit. It never writes back an older copy.
- `⌘Z` in midcode only undoes an edit while the file is still as that edit left it. If Cursor changed it since, midcode says so and leaves it alone.
- If you edit on the canvas right after Cursor saved, before the page reloaded, midcode may say it couldn't find the element. Wait for the canvas to reload and do it again.

## Limits

- No Chat view for Cursor, so no crosshair, no diffs in a thread and no undo of its edits in midcode.
- midcode doesn't talk to the Cursor app: the clipboard and the files are what passes between them.

To have Cursor write code that stays editable on the canvas, install [the midcode skill](https://midcode.app/docs/agents/skill.md) or point it at [Code that midcode can edit](https://midcode.app/docs/agents/editable-code.md).
