Codex CLI With Zed: Terminal and Agent Options
Zed has a built-in terminal and its own AI assistant. Codex CLI runs in the terminal as a separate tool. Here is how each fits, when to combine them, and how to keep task context consistent between sessions.
Updated 5 min read
Zed is a code editor built in Rust with a built-in terminal panel and AI assistant features. Codex CLI is a separate, standalone command-line tool from OpenAI. You can run Codex CLI from the terminal panel inside Zed, just as you would from any other terminal. They are not the same thing, and Zed does not integrate with Codex CLI directly.
The two tools serve different jobs, and the choice between them changes depending on what you are trying to accomplish. A tool like fenbs keeps your task context outside either tool so you can switch between a Zed session and a Codex CLI run without losing the thread of the work.
Running Codex CLI from Zed's terminal
Open a terminal panel in Zed with the built-in shortcut and run Codex CLI from there as you would from any terminal. It sees the same working directory and file system as any other terminal on your machine. There is no special configuration needed to make this work.
The advantage of using Zed's terminal panel is proximity: you can see the agent's output and review the resulting diff in the editor panels side by side without switching windows. The disadvantage is that closing Zed ends the terminal session. For long runs, use a separate terminal window or tmux rather than relying on Zed's panel to stay open.
Zed's own AI assistant
Zed has a built-in AI assistant panel that connects to a language model directly. It can answer questions about your code, generate completions, and make targeted edits within the editor. It is not a terminal agent: it does not execute shell commands or run your test suite.
Codex CLI, by contrast, is a terminal agent that can run any command in your shell. It reads and edits files, runs tests, and executes build steps. The two tools occupy different roles: Zed's AI assistant is useful for in-editor help with specific questions; Codex CLI is useful for autonomous multi-step tasks that touch the build system.
When to use each one
| Task | Better tool |
|---|---|
| Explain this function or suggest an improvement | Zed AI assistant |
| Generate a short snippet to insert at the cursor | Zed AI assistant |
| Make a change, run tests, and fix the failures | Codex CLI |
| Apply a refactor across many files in one run | Codex CLI |
| Review a specific file while you discuss it in chat | Zed AI assistant |
| Run a build verification after edits | Codex CLI |
The two do not share context with each other. A decision you described to the Zed assistant is not available to a Codex CLI session that starts in the same project. If that context matters, write it into AGENTS.md in the repository, or keep it in an external record.
Setting up for a longer project
For a project that spans many sessions, a consistent starting point helps both tools. Write the project's current goal, the active constraints, and the relevant files into an AGENTS.md in the repository root. Codex CLI reads this at the start of every session. The Zed assistant can read it if you open the file and paste the relevant section, though it does not load it automatically.
When you switch from a Codex CLI session to the Zed assistant on the same project, take a moment to confirm what changed. Run git log --oneline -5 to see the last few commits and read the diff if anything is unclear. Starting the Zed assistant from an accurate picture of the current state avoids asking it to work from stale assumptions.
Keeping context consistent between sessions
Both tools start without memory of what you discussed in a previous session. The Zed assistant begins from the current file content. Codex CLI begins from AGENTS.md and whatever you put in the initial prompt.
For decisions that must carry across sessions, write them down. AGENTS.md in the repository is the right place for project conventions that every Codex CLI session should know. Decisions about the work in progress, what is complete and what remains, belong in a project record outside the repository so they survive a branch change or a clone on another machine.
Carry task context between Zed and Codex CLI sessions
Add your active tasks and Decisions in fenbs and connect Codex CLI over MCP from Integrations. The agent reads the project context before it starts and saves progress before it exits. When you switch back to the Zed assistant, check the same record to see where things stand.
Create a free accountFree for one person · No credit card · Works with Claude, ChatGPT, Cursor and more
How to do this with fenbs
- Create a free account and add a project for the codebase you are working on in Zed.
- Add the current tasks and any agreed decisions or rules. These become the starting context for any session, regardless of which tool opens them.
- Connect Codex CLI to fenbs over MCP from Integrations. Ask the agent to read the project context before making changes.
- After a Codex CLI run, save progress in fenbs: what changed, what was tested, and the next step.
- Before starting a Zed assistant session on the same work, check the fenbs context to see what the previous session left.
For other editor integrations, the Codex CLI best practices guide covers general setup advice. The Codex app vs CLI vs IDE extension comparison explains how the terminal agent relates to Codex-based IDE plugins. For Codex CLI skills that let you invoke common tasks by name, see codex-cli-skills.