Feature request: Support auto-including selected code from VS Code editor into Codex CLI context

Open 💬 1 comment Opened Mar 14, 2026 by m01e-40x

What variant of Codex are you using?

Codex CLI in the VS Code integrated terminal, not VS Code Extension

What feature would you like to see?

I’d like Codex CLI to add a small feature similar to Claude Code in the VS Code integrated terminal:

When I select one or more lines in the VS Code editor, Codex should detect that active selection and make it easy to include it in the current conversation context automatically.
<img width="1136" height="483" alt="Image" src="https://github.com/user-attachments/assets/f667056a-571b-4035-88c4-428fa7d2d8b8" />

Why this would help

When working inside VS Code, I frequently select a block of code and then ask the coding agent questions about it, such as:

  • explain this logic
  • find security issues in this snippet
  • suggest a refactor
  • help debug this code
  • generate a patch based on this exact selection

Today in Codex CLI, this usually requires manually copying and pasting the selected code into the Codex CLI, which adds friction.

Desired behavior

A convenient solution would be:

  • detect the current selection in the active editor while Codex is running in the VS Code terminal
  • show a small visual indicator that selected code is available
  • optionally auto-attach that selected code as context to the next prompt
  • clearly show what selection is being sent, so the user keeps control

Example UX

  1. I highlight 10–20 lines in a file in VS Code
  2. Codex notices the current selection
  3. In the terminal UI, Codex shows something like “13 lines selected”
  4. When I send my next prompt, the selected code is included as contextual input automatically.

Important details

  • The file path and line range would be very useful metadata
  • It should be obvious when selection context is being attached
  • Ideally this should work with multi-line selections and update in real time as the selection changes
  • A toggle in settings would be helpful for users who do not want this behavior enabled by default

This would make Codex much smoother to use for editor-driven workflows, especially for code review, debugging, vulnerability research, and refactoring.

Additional information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗