This layer integrates the OpenAI Codex CLI with Spacemacs, allowing you to send code regions, file paths, or context directly to Codex running in an interactive terminal buffer.
I’ve not made a Spacemacs layer before, so as always PRs/feedback welcome.
Requires a ChatGPT Plus plan or above.
- Run Codex in the project root (`SPC a c !`)
- Send regions (`SPC a c r`)
- Send file path or file+line (`SPC a c f`, `SPC a c F`)
- Auto-detects and uses vterm if available, else ansi-term
- Preserves insert mode focus
- Install codex `npm i -g @openai/codex`.
- Clone this repo into
~/.emacs.d/private/codex - Add `codex` to your
dotspacemacs-configuration-layerslist.
dotspacemacs-configuration-layers ‘( codex )
- Restart Spacemacs.
- Spacemacs
- Projectile
- Either
vtermoransi-term - Codex CLI available on your system PATH.
Set `codex/vterm-available-p` to force or disable vterm detection if needed.
| Key | Description |
|---|---|
| SPC a c ! | Launch Codex terminal |
| SPC a c r | Send region to Codex |
| SPC a c f | Send current file path |
| SPC a c F | Send file + line (editable) |
Start by launching Codex terminal. Enter your instructions, or use the shortcuts to specify which file, line or region to give context to the agent.