# Send a selected passage to a CLI agent without copying and pasting

Hand one passage of a Markdown draft to Claude Code, Codex or any CLI agent on a Mac: select it, press one shortcut, add your instruction. No pasting.

**The short version:** Keep the draft as a Markdown file and run your agent in Flywrite's terminal under the page. Select the passage and press ⌘⇧L. It types a reference such as `@issues/2026-11-07-issue-42.md#L12-18` at the agent's prompt, and you add your instruction. Claude Code, and Cursor Agent after its setup, see your selection without it; Codex and other CLI agents need it.

We make Flywrite, the Markdown writing app these steps use. The steps follow each tool's own docs; if one looks different, check that tool's docs under Sources.

## What you'll need

- A Mac: Flywrite is a Mac app.
- Flywrite, with your drafts opened as a project, which is an ordinary folder of files ([Your first project](/docs/your-first-project)).
- A CLI agent on its own plan: [Claude Code](/glossary/claude-code), [Codex](/glossary/codex-cli), Cursor Agent or another, such as Gemini CLI or OpenCode. If it runs in your Mac's terminal, it runs in Flywrite's, and Flywrite adds no AI fee.
- The passage in a Markdown file inside that project. The agent reads it from the file.

## Do it step by step

By the end, you hand any agent one passage with a shortcut and a sentence, and it works on those lines in your file, with no copying and pasting.

1. **Open your writing folder in Flywrite.** Choose **Open Folder** to use a folder already on your Mac, or **New Project** to start fresh. A project is an ordinary folder of files, such as this example:

   ```text
   weekend-gardener/
     ideas.md
     issues/
       2026-11-07-issue-42.md
   ```

2. **Start your agent in the terminal under the page.** Press `⌃2` for Claude Code, `⌃3` for Codex or `⌃4` for Cursor Agent, or open a plain terminal tab with `⌃1` and start any other agent there. Flywrite saves a checkpoint of the whole project when Claude Code starts in its terminal, and when Cursor Agent starts after its one-time setup. Codex and other CLI agents don't trigger it, so press `⌘⇧C` before you start them. These are Flywrite's default shortcuts, and [every one is customizable](/docs/keyboard-shortcuts).

   ```text
   ⌃2   Claude Code
   ⌃3   Codex
   ⌃4   Cursor Agent
   ```

3. **Select the passage.** Drag across the lines you want the agent to work on, in Rendered or Source view. The agent reads them from the file on disk, and Flywrite autosaves as you write (`⌘S` saves at once). Source view (`⌘E`) shows line numbers; these are lines 12 to 18 of the example issue:

   ```2026-11-07-issue-42.md
   ## Putting the beds to sleep

   Cut the spent tomato vines and leave the roots.

   Spread two inches of leaves over every bed.

   Water once more, then let the garden rest.
   ```

4. **Press `⌘⇧L`.** Send Selection to Terminal types a reference to the file and those lines at the prompt of the active terminal tab, then stops. It doesn't press Enter, so nothing is sent yet. With nothing selected, it types the line your cursor is on, such as `#L12`. If no terminal tab is open, it types nothing, so start your agent first.

   ```text
   @issues/2026-11-07-issue-42.md#L12-18
   ```

   You should see that reference at the agent's prompt, followed by a space.

5. **Add your instruction and press Enter.** Press `⌘J` to jump into the terminal; the highlight stays on your passage so you can still see it. Type what you want after the reference. With Codex, typing `@` and the file name also points it at the file, and with any agent you can name the lines in words, such as "lines 12 to 18".

   ```prompt
   @issues/2026-11-07-issue-42.md#L12-18 Make this warmer, under 40 words.
   ```

   You should see the edit land in the draft above as the agent writes it.

6. **With Claude Code, skip the shortcut.** Claude Code already sees your selection, the open file and the line you're on, with no setup. Cursor Agent does too, after its one-time setup in **Settings → Agents** ([Writing with Cursor](/docs/writing-with-cursor)). Select the passage and ask about "the selected paragraph"; press `⌘⇧L` when you want the lines named in the prompt as well.

   ```prompt
   Tighten the selected paragraph.
   ```

7. **Check the edit, and roll back if you need to.** The draft updates as the agent edits. To undo, press `⌘⇧V` to open Versions, expand the checkpoint from before the run, and restore the project or only this file ([Roll back what an agent changed](/guides/review-and-undo-agent-edits)).

   ```text
   ⌘⇧V, then expand a checkpoint:
   Restore project to this point
   Restore (on one file)
   ```

## Facts at a glance

| Agent | Sees your selection on its own | `⌘⇧L` | Checkpoint at start |
| --- | --- | --- | --- |
| Claude Code (`⌃2`) | Yes, with the open file and line | Optional | Yes |
| Cursor Agent (`⌃4`) | After its one-time setup | Optional | After its setup |
| Codex (`⌃3`) | No | Needed, or type `@` and the file name | No, press `⌘⇧C` |
| Any other CLI agent | No | Needed; the reference arrives as text | No, press `⌘⇧C` |

| Fact | Value |
| --- | --- |
| What `⌘⇧L` types | `@`, the file's path in the project, then `#L` and the first and last line, at the prompt, without pressing Enter |
| With nothing selected | The cursor's line, such as `#L12` |
| What the agent reads | The saved file, at those lines |
| Flywrite's price | $99 a year for Mac, with no AI fee |

## When not to use this

- **You already work in Warp.** Select text in Warp's code editor and press `⌘L` to attach it to a Claude Code or Codex session running in a Warp tab ([Warp: Selection as context](https://docs.warp.dev/agents/local-agents/agent-context/selection-as-context/)).
- **You write in VS Code with Claude Code's extension.** It sees your selected text automatically, and `Option+K` inserts an @-mention with the line numbers, such as `@app.ts#5-10` ([Use Claude Code in VS Code](https://code.claude.com/docs/en/vs-code)).
- **You only want the agent, not a writing app.** In macOS Terminal, type `@` and the file name in Claude Code or Codex, and name the lines in your request ([Claude Code interactive mode](https://code.claude.com/docs/en/interactive-mode), [Codex CLI commands](https://learn.chatgpt.com/docs/developer-commands?surface=cli)).
- **The passage isn't in a file.** Text in an email or on a web page has no file to point at, so paste it into the prompt, or save it into the project first.

## Questions

### Does Codex see the text I select?

No. Codex doesn't see what you have open or selected in Flywrite on its own. Press `⌘⇧L` to type a reference to the file and those lines at its prompt, or type `@` and the file name.

### Can I paste the text instead?

Yes, any terminal takes pasted text. `⌘⇧L` types a short reference instead, so the prompt stays short and the agent works on those lines in the file itself.

## Sources

1. [Flywrite docs: Writing with Claude Code](/docs/writing-with-claude-code), checked 2026-11-17
2. [Flywrite docs: Writing with Codex](/docs/writing-with-codex), checked 2026-11-17
3. [Flywrite docs: Writing with Cursor](/docs/writing-with-cursor), checked 2026-11-17
4. [Flywrite docs: The terminal](/docs/the-terminal), checked 2026-11-17
5. [Flywrite docs: The editor](/docs/the-editor), checked 2026-11-17
6. [Flywrite docs: Keyboard shortcuts](/docs/keyboard-shortcuts), checked 2026-11-17
7. [Flywrite docs: Checkpoints & versions](/docs/checkpoints-and-versions), checked 2026-11-17
8. [Flywrite docs: Your first project](/docs/your-first-project), checked 2026-11-17
9. [Flywrite pricing](/pricing), checked 2026-11-04
10. [OpenAI Codex docs: Developer commands (CLI)](https://learn.chatgpt.com/docs/developer-commands?surface=cli), checked 2026-11-17
11. [Claude Code: Interactive mode](https://code.claude.com/docs/en/interactive-mode), checked 2026-11-17
12. [Claude Code: Use Claude Code in VS Code](https://code.claude.com/docs/en/vs-code), checked 2026-11-17
13. [Warp docs: Selection as context](https://docs.warp.dev/agents/local-agents/agent-context/selection-as-context/), checked 2026-11-17
14. [Gemini CLI docs](https://geminicli.com/docs/), checked 2026-11-17
15. [OpenCode docs](https://opencode.ai/docs/), checked 2026-11-17

---

This is the Markdown copy of https://flywrite.app/guides/send-selection-to-cli-agent.
