Skip to content

Agents and the IDE link

Agents in a terminal work blind: they cannot see what you are looking at, and their edits land in files you have not read yet. Next Term closes that gap. Agents that have an IDE protocol connect to Next Term as their IDE. Every agent gets Send to Agent, which types a reference to your selection into its prompt, and Next Term’s MCP tools, which let it read the editor’s selection and open files — and drive other agents.

AgentTab statusIDE link: live selection, edits as diffsMCP tools, set up for youSend to Agent (⌥⌘K)Its sessions, to resume
Claude CodeFrom its screenYesYesYes, as an @-mentionYes
Gemini CLIFrom its screenYes, with the open filesYesYesYes
Qwen CodeFrom output timingYes, with the open filesYesYesYes
GitHub Copilot CLIFrom output timingYesYesYes, as an @-mentionYes
OpenCodeFrom its screenThe selection onlyYesYes, as an @-mentionYes
Codex, Command CodeFrom its screen—YesYesYes
Cursor AgentFrom output timing—YesYesYes
Amp, JunieFrom output timing—YesYes—
Other agentsFrom output timing, for the ones it recognises by name—Add nxtrm mcp yourselfYes—
  • From its screen: the spinner follows the agent’s own working hint (“esc to interrupt”, or OpenCode’s “esc interrupt”), so it stops the moment the agent stops. Claude Code’s, Codex’s, Command Code’s and OpenCode’s permission questions also turn the tab amber, and so do Claude Code’s and OpenCode’s questions with options; Gemini CLI’s are not read yet, so its tab shows done while it asks. The hints are checked against that agent’s own screen.
  • From output timing: printing counts as working and 2.5 seconds of silence as done. An idle agent that keeps redrawing its screen can keep the spinner going, and a question turns the tab amber only if the agent words it the way Claude Code or Codex does, or rings the bell. Next Term reads every agent’s screen the same way, so if one of these agents shows the same hints, its tab follows them.

See How Next Term knows.

With the MCP tools, any of these agents can ask for the editor’s selection (get_editor_selection) and open files (get_open_files), and one of them can run the others. See Orchestrate agents (MCP).

There is nothing to set up. Start claude in a Next Term tab and it connects to Next Term as its IDE, through the protocol Claude Code uses for editors. This is verified with Claude Code 2.1.280.

  • The lines you select go with your next prompt. Claude shows “⧉ 10 lines selected” above its input, so you can ask about “this function” without pasting it. With nothing selected, Claude knows which file you have open.
  • ⌥⌘K puts an @-mention straight into Claude’s prompt, such as @app/User.php#L10-20.
  • A claude started in another terminal inside one of your open projects finds Next Term too.

The editor with two lines selected in main.php, and Claude Code running in the terminal below, showing “2 lines selected” in its prompt.

When Claude wants to change a file, its change opens in a diff tab: your file on the left, Claude’s version on the right, the changed words marked. The header reads “Claude proposes changes to main.php”.

  • Accept (⌘↩︎): Claude writes the file.
  • Reject: the file stays as it is.
  • Closing the tab counts as Reject. Close Others and Close Tabs to the Right ask first when a proposal is among the tabs they close.
  • Answering in the terminal works too, as it always has.

Next Term never writes the file itself; the agent does, after you accept. You read every change before it lands, in the same window as the agent that made it. Step through the changes in a long proposal with the arrows in the header.

A diff tab titled “main.php ✻ Claude”: the header says Claude proposes changes to main.php, +1 −1, with Reject and Accept buttons. The left side has “Hello”, the right side “Hi”, with the changed word marked.

Gemini CLI and Qwen Code use their own IDE companion protocol, and Next Term speaks it. Start gemini or qwen in a Next Term tab and it connects by itself.

  • What they see: up to 10 files you have open, most recent first, and in the active one the caret position and your selection.
  • Proposed edits open as a diff to accept or reject, as with Claude. A new proposal for the same file replaces the old one.
  • Nothing to set up. Both CLIs connect to an editor only when their IDE mode is on. Next Term turns it on for you by setting "ide": {"enabled": true} in ~/.gemini/settings.json and ~/.qwen/settings.json. It changes only that setting and leaves the rest of the file byte for byte. It writes nothing if the agent is not installed, and never rewrites a settings file that has comments in it.

Copilot CLI connects to an editor through the protocol VS Code’s Copilot extension uses, and Next Term speaks it. Start copilot in a Next Term tab and it connects by itself.

  • What it sees: the lines you select go with your next prompt, and Copilot shows which ones. With nothing selected, it knows which file you have open.
  • ⌥⌘K puts an @-mention straight into Copilot’s prompt, such as @app/User.php:10-20.
  • Proposed edits open as a diff to accept or reject, as with Claude. Copilot asks in the terminal at the same time; answer in either place, and the other closes.
  • Where it connects: Copilot connects by itself when it starts in a folder Next Term lists for it: an open project, or the folder a tab is in, except your home folder and /. It takes the first editor it finds with that folder, so where VS Code has the same folder open, a copilot in a Next Term tab may connect to VS Code, and one in VS Code’s own terminal may connect to Next Term. /ide in Copilot switches.
  • From another terminal: a copilot started outside Next Term in one of those folders connects too, as does one that picks Next Term in /ide. It sees the selection of the Next Term window that has its folder open (the window’s project, a tab’s folder, or a folder inside one of them), and its proposed edits open in that window. If no window has its folder open, it is sent no selection, and its proposed edits open in the front window.
  • Nothing to set up, and nothing of Copilot’s is changed: Next Term only adds its own lock file to ~/.copilot/ide, and only when ~/.copilot exists (Copilot makes it the first time it runs). Copilot still asks its own question about trusting a folder; Next Term never answers it for you.

OpenCode reads Claude Code’s lock files and connects to Next Term the same way. Started in another terminal inside one of your open projects, it presents the token from the lock file. From a Next Term tab it connects without the token, so Next Term checks who is calling instead: the connection is kept only when it comes from OpenCode running in one of Next Term’s own tabs.

  • What it sees: the lines you select, which go with your next prompt. With nothing selected, it is told which file you have open. When the editor shows no file, or one whose selection is never shared (such as .env), it is told the last file it was sent, without its lines, so lines you no longer see never go with a prompt.
  • ⌥⌘K puts the selected lines straight into OpenCode’s prompt as an @-mention of those lines, numbered from 1 as OpenCode counts them. A whole file or a folder is typed into its prompt instead (see Send to Agent), because OpenCode takes a mention only with lines.
  • No proposals: OpenCode does not ask an editor to show its edits, and without the token it could not.
  • Not in tmux or a remote tab: OpenCode inside tmux, even tmux started in a Next Term tab, or in a remote tab, is not linked, because Next Term cannot tell it is in one of its tabs.

Its tab follows OpenCode’s own screen: the spinner while its footer shows “esc interrupt”, amber when it asks for a permission or asks you a question, and done once its footer is back without the hint. The notification for a permission quotes the request, such as “Permission required: Shell command ($ npm test)”, and an agent can answer it with answer_agent. What is read, and its limits, are in OpenCode’s screen.

After an update or a quit, OpenCode’s line goes back on its tab’s prompt, unrun, with the session it was showing, such as opencode -s followed by the session’s id: press Return to resume it. Next Term finds that session by the title OpenCode gives its tab, so a session you switched to inside OpenCode, and worked in, comes back rather than the one you started with. When the title fits more than one session, the line names the newest session started in that folder since OpenCode started instead; either way the note says the session is a guess. OpenCode doesn’t resume by itself, as Claude Code, Codex and Qwen Code do (see Lines put back on the prompt).

Send to Agent hands your context to the agent in a tab, in that agent’s own syntax, and puts the cursor in its prompt so you can add the instruction.

What you can send:

  • Lines in the editor: select them and press ⌥⌘K (Agents › Send to Agent). With nothing selected, the whole file is sent.
  • Lines in a diff: select them on the new side of a diff, or in its Unified column, and press ⌥⌘K. With nothing selected, the file is sent.
  • Files and folders in the sidebar: select them and press ⌥⌘K, or right-click and choose Send to Agent (“Send 3 Items to Agent” for several).
  • Text in a terminal: select it (an error, a test’s output) and press ⌥⌘K, or right-click and choose Send Selection to Agent. It goes into the agent’s prompt as a fenced block, so the agent reads it as output, not as your instruction; an agent that takes no pastes gets it on one line. Up to 200 lines (16 KB).

Which agent receives it: the agent in the front tab if one is running there; otherwise the agent tab you used most recently. Text selected in one agent’s output goes to another agent when one is running, the one you used most recently, not back to the agent that wrote it. An agent in a remote tab never gets it, because what it types are paths on your Mac. If no agent on your Mac is running in the window, Next Term says so, and says when the only one runs on a server.

What it types: a reference relative to the agent’s folder, in the agent’s own syntax.

AgentLines 10–20 of a fileOne lineA folder
Claude Code@app/User.php#L10-20@app/User.php#L10@app/
OpenCode@app/User.php#10-20@app/User.php#10@app/
Gemini CLI, Qwen Code@app/User.php (lines 10-20)@app/User.php (line 10)app/ (folder)
Copilot CLI@app/User.php:10-20@app/User.php:10app/ (folder)
Codex and every other agentapp/User.php:10-20app/User.php:10app/ (folder)

Several items go on one line for agents that use @-mentions; for the others they become a short “Context:” list. A path with spaces is quoted; for Copilot CLI it is typed without the @ and with the lines in words, because Copilot’s @-mentions end at a space. When Claude Code, OpenCode or Copilot CLI is connected through the IDE link, files go in as real @-mentions instead of typed text. A folder, or a reference with a note such as “(unsaved changes in the editor)” or “(as staged)”, is still typed: a mention carries only a file and its lines. For OpenCode a whole file is typed too, as it takes a mention only with lines. When one item has to be typed, they all are, so they stay in one prompt.

Unsaved changes: if the file has edits you have not saved, the reference says “(unsaved changes in the editor)” and the selected code is pasted after it as a fenced code block, so the agent sees what you see.

It never presses Return. You read what was typed, add your instruction, and send it yourself. The text arrives as a bracketed paste: code keeps its line breaks and tabs, every other control character is removed, and the text never starts with a character an agent treats as a command (!, /, $, &, ? or #).

View › Prompt Box (⇧⌘I) puts a native text box under the terminal of the tab in front, for writing a longer prompt the way you write anywhere else on the Mac. The agent keeps its own screen above it.

  • Return sends the text as one paste, then presses Return for you, so several lines arrive whole. ⇧Return or ⌥Return adds a line. The box grows to 8 lines, then scrolls.
  • Files: drop them on the box, or copy them in Finder and paste: they go in as quoted paths. In a tab on your server they are copied there first. An image pasted on its own goes to the agent, as ⌘V in the terminal does.
  • ↑ in the empty box brings back the last prompt you sent. ⎋ in the empty box goes to the terminal, so an agent stops on it.
  • ⇧⌘I again moves the keyboard between the box and the terminal; from the box, it hides the box. Each pane has its own.

See an agent’s session as a chat (⇧⌘J)

Section titled “See an agent’s session as a chat (⇧⌘J)”

A tab running Claude Code, Codex or Command Code has two small buttons in its top-right corner: the terminal and a chat bubble. Over the terminal they appear when you point at that corner, so they never cover the agent’s own text; over the chat they stay in view. The chat is the same live session, not a copy. Next Term reads the session file the agent writes as it works, and shows:

  • your prompts and the agent’s replies;
  • tool calls, each on one calm line: point at it, or unfold it, for the whole command and its output;
  • edits, with their line counts and an Open Diff link;
  • plans, as a checklist that stays in sight while the agent works through it.

File paths show relative to the tab’s folder, reads and searches that come one after another share one row, and each turn ends by naming the files it changed.

When the agent asks a question, it shows as a card with the agent’s own choices.

  • Open it with the chat button, View › Show as Chat (⇧⌘J) or the tab’s right-click menu.
  • Type in the chat: its box is the Prompt Box, so what you type goes into the agent’s own prompt, as if typed in the terminal. Return sends; ⇧↩ adds a line.
  • It reads like a page: one column with the box you type in lined up under it, long lines and code wrapped, nothing scrolling sideways. It follows new messages only while you’re at the end; scrolled up, you stay where you are, and Jump to Latest takes you down.
  • Nothing restarts: the agent keeps running in its terminal the whole time. The terminal button, or ⇧⌘J again, brings its screen back, for what only the terminal has: signing in, /mcp, trust questions, /rewind.
  • Replies appear as the agent writes them to its session file. Claude Code writes each reply once it finishes, so a long reply appears whole; tool calls appear one by one.
  • Other agents (OpenCode, Gemini CLI, Cursor Agent and the rest) show no buttons, and their tabs work as before.
  • Open new sessions as a chat: pick Chat in the agent’s Opens as in Settings › Agents; every agent opens as its terminal until you do.
  • Token usage: under the box you type in, the agent’s own count, such as “184k tokens · 92% of context”, turning amber past 80%. Hover for the input, output and cache breakdown. It shows nothing for an agent that doesn’t report usage; Settings › Agents › Show token usage in chat turns it off.
  • Token budget: right-click the usage line and choose Set Token Budget…, or ask an agent (“give this tab a 2M token budget”). The line then adds “· 254k of 1M budget”, with a thin bar under it that turns amber at 90%. A budget is shown, never enforced: nothing stops when it runs out. It lasts while the tab is open, and counts only in Claude Code and Codex tabs, the agents that record a running total.
  • Turn it off in Settings › Agents › Chat view for agent tabs.
  • For agents over MCP: switch_view shows a tab as its chat or its terminal, and list_tabs gives a tab’s view. It’s a view change only: nothing is typed into the agent.

With a screenshot or another image alone on the clipboard, ⌘V pastes it into the agent in your tab.

  • Claude Code, Codex, Gemini CLI, Qwen Code, OpenCode, Cursor Agent and Command Code get ⌃V, their own key for an image, and read the image from the clipboard themselves. You no longer need to reach for ⌃V.
  • Anywhere else on this Mac (a shell, Copilot CLI, any other program) the image is kept as a PNG only you can read, and its quoted path is pasted, which any agent can open. It is removed a day later.
  • In a tab on a server, the image is copied there first and its path there pasted. A tab logged in to another machine by hand (ssh) gets nothing, with a note why: the image is on this Mac.

Text on the clipboard always pastes as text, and a file copied in Finder pastes as its full path, as dropping it does. See Security and privacy.

Settings › Editor › Agents has two switches, both on by default:

  • “Agents in a tab see the editor (Claude Code, Gemini CLI, Qwen Code, OpenCode)”
  • “GitHub Copilot CLI in a tab sees the editor”

Turn one off and Next Term stops those IDE servers: the agents no longer see your selection or open files, and their proposed edits are answered in the terminal only. Send to Agent keeps working, because it types into the prompt instead.

  • Local only. The servers for Claude Code, OpenCode, Gemini CLI and Qwen Code listen on 127.0.0.1 and nowhere else. Copilot CLI’s has no network port at all: it is a Unix socket in a new folder that only you can open.
  • A fresh secret every launch. Each run of Next Term creates new 256-bit secrets; an agent must present one, and the check runs in constant time. The lock files that tell Claude Code and Copilot CLI where to connect are readable only by you (0600 in a 0700 folder) and are removed when Next Term quits.
  • Without the token, only OpenCode in your tabs. A connection without the token is kept only when the process making it is OpenCode running in a Next Term tab. It then only receives your selection and @-mentions: it cannot propose edits or call anything.
  • Browsers are refused. Requests that carry an Origin header, as requests from web pages do, are rejected. A website cannot reach the link, and would still need the token.
  • Agents cannot write through it. Nothing an agent sends over the link writes a file. Next Term reports the selection and shows proposals; the agent writes only after you accept, with its own permissions.
  • Secrets are never shared. Selections and open files from .env and .env.* (except .env.example), *.pem, *.key, id_rsa, id_ed25519, .npmrc and .netrc never leave the editor.

More in Security and privacy.

Next Term lists the conversations eight agents keep for a folder: Claude Code, Codex, Command Code, Gemini CLI, Qwen Code, OpenCode, Cursor Agent and Copilot CLI. You find them in three places:

  • The Welcome window, for each of your projects: every session, newest first, to filter by agent.
  • ⌥⌘O in a project window: the same list as a panel, to filter by typing.
  • Agent Sessions at the top of the project sidebar: the folder’s newest five, and More… for the rest.

In the ⌥⌘O panel, the session you select shows its last turns beside the list: your prompts, the agent’s replies, and how many tools it ran. That preview is for Claude Code and Codex, whose conversations Next Term reads; for other agents the panel says so.

Resume types the agent’s own command into a new tab, in the folder the session was started in. Fork continues a copy and leaves the original as it was; it is offered only for the agents that can fork from the command line.

AgentResumeForkContinue latest
Claude Codeclaude --resume <id>--fork-sessionclaude --continue
Codexcodex resume <id> -C <folder>codex fork <id>codex resume --last
Command Codecommand-code --resume <id>--fork-sessioncommand-code --continue
Gemini CLIgemini --resume <id>—gemini --resume latest
Qwen Codeqwen --resume <id>--fork-sessionqwen --continue
OpenCodeopencode --session <id>--forkopencode --continue
Cursor Agentcursor-agent --resume=<id>—cursor-agent resume
Copilot CLIcopilot --resume=<id>—copilot --continue

A session open in a tab says so. It is marked “open in a tab” in the lists and “running” in the sidebar, and Resume becomes Go to Tab: it shows that tab rather than start the session a second time. Claude Code and Copilot CLI record which session each running copy has open (Claude Code’s record follows /clear and /resume), and Next Term goes by that. OpenCode titles its tab after the session it shows, so for OpenCode that title comes next, and a switch inside OpenCode moves the mark with it. For the other agents, and for an OpenCode title that two sessions share, a tab is in the session it resumed by id, or, when the agent started there without one, the session that began after it did. When two tabs run the same agent in one folder, a session either of them could have begun is marked in neither, rather than in the wrong one. A Claude Code or Copilot CLI session that the agent has open in another terminal is marked “open in a running agent”; for Claude Code, Fork is the safe way to continue it.

Continue Latest is in the ⋯ menu of the sidebar’s Agent Sessions group, for each agent with a session in that folder. It runs the agent’s own command from the last column, which picks up its latest session in the folder.

See The Welcome window and agent sessions for where Next Term reads them from.

Claude Code, Codex and the agents that speak the Agent Client Protocol (Gemini CLI, Qwen Code, OpenCode, Cursor CLI, Copilot CLI, goose and others) can also run as an agent session: Agents › New Agent Session…, or nxtrm agent claude in a tab. Next Term follows the agent’s own turns, tool calls and permission requests instead of its screen, so the tab’s mark is exact. It runs the CLI you installed, signed in as you signed it in, and never touches its login. See Agent sessions.

Next Term is also an MCP server. An orchestrator agent can list every project and tab with each agent’s state, start agents in new tabs, send them prompts, wait for them, read their screens and answer their questions. It is set up for you in the agents above. See Orchestrate agents (MCP).

A remote tab (⌥⌘T) runs an agent on a server you reach with ssh, kept running in tmux or herdr while your Mac sleeps, with the same marks as a local one. Agents can open and check those tabs through MCP too. See Remote tabs on your servers.

Coming later Remote access to the MCP server for agents outside your Mac.