Codex Link
Codex Link is a VS Code extension that makes it easier to send selections, files, and folders into the official Codex - OpenAI's coding agent extension.
It does not replace Codex chat. It adds faster entry points on top of the official Codex extension so you can move context into Codex with fewer steps.
Source repository: github.com/lcwlucky/codex-link-vscode-plugin

What This Extension Does
Codex Link adds these entry points:
- An
Add to Codex CodeLens above the selected range
- An editor title action named
Add Current File to Codex
- A terminal context action named
Add Terminal Selection to Codex
- Explorer context menu actions named
Add to Codex for files and folders
- A dedicated
Codex Link sidebar with:
Open Codex
Add Current File to Codex
Pick Files or Folder for Codex
- a sidebar action for reliably picking files or folders for Codex
- a drop zone for best-effort drag and drop when your VS Code environment supports it
Behind the scenes, Codex Link delegates to the public commands exposed by the official Codex extension:
chatgpt.addToThread
chatgpt.addFileToThread
Requirements
You must install and enable the official Codex extension first:
Codex - OpenAI's coding agent
- extension id:
openai.chatgpt
Codex Link depends on that extension. If it is missing or disabled, Codex Link will show an install or enable prompt instead of sending content.
Installation
There are two common ways to install Codex Link.
Option 1: Install from VS Code Marketplace
- Open VS Code.
- Open the Extensions view.
- Search for
Codex Link.
- Click
Install.
- Make sure the official
Codex - OpenAI's coding agent extension is also installed and enabled.
Option 2: Install from a .vsix file
- Open VS Code.
- Open the Extensions view.
- Click the
... menu in the top-right corner of the Extensions view.
- Choose
Install from VSIX....
- Select the
.vsix package for Codex Link.
- Reload VS Code if prompted.
Quick Start
After both Codex Link and the official Codex extension are installed:
- Open a local project folder in VS Code.
- Open a local file.
- Select a block of code.
- Click
Add to Codex.
- Codex should open and receive the selected context.
If you prefer not to select text manually, use the file, folder, or sidebar actions described below.
Detailed Usage Guide
1. Send a selected code block to Codex
Use this when you want to send only part of a file.
Default shortcut:
- macOS:
Cmd+Option+L
- Windows / Linux:
Ctrl+Alt+L
You can change this shortcut in VS Code Keyboard Shortcuts. The inline CodeLens keeps showing the default shortcut text and does not dynamically reflect user-customized keybindings.
Steps:
- Open a local file, an untitled scratch file, or a VS Code JSON settings editor.
- Select a single contiguous block of text.
- Look for the
Add to Codex CodeLens above the selection.
- Click it, or use the
Cmd+Option+L / Ctrl+Alt+L shortcut.
What happens:
- Codex Link calls the official Codex selection command
- Codex receives the selected file range as thread context
Notes:
- This works in local
file documents, untitled documents, and VS Code JSON settings editors such as settings.json
- This action supports one non-empty selection at a time
- If you have multiple selections, Codex Link will reject the action
- To reduce flicker during word-level search/navigation, single-line selections without whitespace only show
Add to Codex when their trimmed length is at least 50 characters by default
Selection visibility setting:
Add this to settings.json if you want shorter or longer single-line expressions to trigger the inline actions:
{
"codexLink.minSingleLineSelectionLength": 12
}
This setting only affects single-line selections without whitespace. Multi-line selections and single-line selections that already contain whitespace still always show the action.
2. Send a terminal selection to Codex
Use this when the context you want to share is terminal output or a command snippet instead of editor text.
Default shortcut while terminal focus is active:
- macOS:
Cmd+Option+L
- Windows / Linux:
Ctrl+Alt+L
Steps:
- Focus an integrated terminal in VS Code.
- Select a block of terminal text.
- Right-click and choose
Add Terminal Selection to Codex, or use the terminal shortcut.
What happens:
- Codex Link copies the current terminal selection
- Codex Link writes that text to a temporary file with a short name such as
fish-1 or fish-2
- The temporary file starts with terminal metadata such as the terminal name, working directory, and capture time so Codex can treat it as terminal output instead of an ordinary note
- Codex Link sends that temporary file to Codex as an attachment-style context item
Notes:
- This path is best-effort because VS Code does not expose a stable extension API for reading terminal selections directly
- The bridge uses the system clipboard to capture the terminal selection before creating the temporary file
- If terminal copy does not place any text on the clipboard, Codex Link will show an error instead of sending stale empty content
- The resulting attachment UI is controlled by the official Codex extension, so it may not look exactly like Cursor's terminal context chip
- Codex Link cleans up old terminal capture temp files automatically using
codexLink.terminalCaptureRetentionHours and codexLink.terminalCaptureMaxFiles, which default to 24 hours and 100 files
3. Send the current file from the editor title bar
Use this when you already have a file open and want a persistent button without selecting text.
Steps:
- Open a local file.
- Look at the editor title bar.
- Click
Add Current File to Codex.
What happens:
- Codex Link sends the current file to Codex using the official file command
4. Send a file from the Explorer
Use this when you want to add a whole file from the file tree.
Steps:
- Open the Explorer view.
- Right-click a file.
- Click
Add to Codex.
What happens:
- Codex Link sends that file path to Codex
5. Send a folder from the Explorer
Use this when you want Codex to know about a folder without expanding every file manually.
Steps:
- Open the Explorer view.
- Right-click a folder.
- Click
Add to Codex.
What happens:
- Codex Link sends the folder path to Codex
- Codex Link does not enumerate folder contents itself
- Codex can then read from that folder on demand
The sidebar is useful when you want a dedicated handoff panel.
How to open it:
- Look at the left Activity Bar in VS Code.
- Click the
Codex Link icon.
The sidebar contains four main actions.
Open Codex
Use this when you just want to focus the official Codex sidebar.
Add Current File to Codex
Use this when the active editor already contains the file you want to send.
Steps:
- Open a local file.
- Open the
Codex Link sidebar.
- Click
Add Current File to Codex.
Pick Files or Folder for Codex
Use this when you want to add files or folders through the OS file picker.
Steps:
- Open the
Codex Link sidebar.
- Click
Pick Files or Folder for Codex.
- Select one or more files or folders.
- Confirm the picker dialog.
What happens:
- Codex Link sends each selected resource to Codex
- Codex Link then opens the Codex sidebar
Use this only if drag and drop from the VS Code Explorer works in your environment.
Steps:
- Open the
Codex Link sidebar.
- Drag a file or folder from the VS Code Explorer.
- Drop it into the drop zone.
Important limitation:
- Drag and drop support is best-effort
- VS Code Explorer drag and drop may not provide usable data to the webview in some environments
- External OS drag and drop may vary by platform and VS Code behavior
Recommended fallback:
- Use
Pick Files or Folder for Codex
What Happens When Codex Is Missing
If the official Codex extension is not installed:
- Codex Link shows an error message
- Codex Link offers an
Install Codex action
If the official Codex extension is installed but disabled:
- Codex Link shows an error message asking you to enable it
Current Limitations
- Only local
file resources are supported
- Only a single non-empty text selection shows the
Add to Codex CodeLens
- Selection handoff supports local files, untitled editors, and VS Code JSON settings editors
- Terminal selection handoff is best-effort and depends on terminal copy updating the system clipboard
- Folder contents are not expanded by Codex Link itself
- Drag and drop is best-effort and is not guaranteed to work identically across all VS Code environments
- Codex Link cannot inject custom UI into the official Codex chat input itself
Troubleshooting
I clicked Add to Codex, but nothing happened
Check these items:
- Confirm the official
openai.chatgpt extension is installed
- Confirm that extension is enabled
- Confirm you are working in a supported editor such as a local file, an untitled document, or a VS Code JSON settings editor
- Try
Open Codex from the Codex Link sidebar
- Try reloading the VS Code window
The inline selection action does not appear
Check these items:
- Make sure the file is a local file
- For JSON settings files, make sure you are editing the text document itself, not the Settings UI
- Make sure the selection is not empty
- Make sure you only have one selection range
- Try changing the selection once more to refresh the CodeLens
Terminal selection did not send the expected text
Try this:
- Re-select the terminal text and run
Add Terminal Selection to Codex again
- Confirm the terminal selection can be copied normally in your VS Code environment
- Check whether another app or extension is interfering with the system clipboard
- If the terminal path remains unreliable, paste the terminal snippet into an untitled editor and use the regular selection action
- Look for a new temporary attachment in Codex whose file name looks like
fish-1 or terminal-1
Try this:
- Drag from the VS Code Explorer instead of the OS file manager
- Use
Pick Files or Folder for Codex, which is the recommended reliable path
I only see install prompts
That means Codex Link can run, but the official Codex extension is missing or disabled. Install or enable openai.chatgpt first.
Manual Verification Checklist
Use this checklist before packaging or publishing:
- Install and enable the official
openai.chatgpt extension.
- Open a local file.
- Select a single contiguous range and confirm the
Add to Codex CodeLens appears above the selection.
- Click the CodeLens and confirm Codex receives the selected range.
- Confirm the editor title action
Add Current File to Codex appears.
- Right-click a file in Explorer and confirm
Add to Codex appears and works.
- Right-click a folder in Explorer and confirm
Add to Codex appears and adds only the folder path context.
- Open the
Codex Link sidebar and test:
Open Codex
Add Current File to Codex
Pick Files or Folder for Codex
- drag and drop from the VS Code Explorer if your environment supports it
- Select terminal text and confirm
Add Terminal Selection to Codex works from the terminal context menu or shortcut.
- Disable or uninstall
openai.chatgpt and confirm install guidance appears.
Internal Command IDs
These command ids are stable inside this project:
codexBridge.addSelectionToChat
codexBridge.addTerminalSelectionToChat
codexBridge.addResourceToChat
codexBridge.installCodexDependency
codexBridge.openCodex
codexBridge.addCurrentFileToChat
codexBridge.pickFilesOrFoldersToChat