Codex is the most direct tool to compare against the other agentic CLIs we have been looking at.
Pi gives us an open multi-provider agent toolkit. Herdr gives us persistent terminal workspaces around multiple coding agents. NanoClaw explores container-isolated personal assistants.
Codex is OpenAI’s own local coding agent CLI.
The repository is more than a small wrapper around a model call. It contains a Rust workspace, the npm launcher package, TypeScript and Python SDKs, sandboxing components, execution policy code, MCP support, app-server pieces, and release tooling.
OpenAI Codex CLI is a local coding agent from OpenAI that runs on your computer and connects to OpenAI’s Codex experience through ChatGPT or API-key authentication.
OpenAI Codex GitHub Source Code OpenAI Codex Documentation OpenAI Codex Use Cases GPT-5.3-Codex model page License: Apache-2.0
What is Codex CLI?
Codex CLI is the local command-line version of OpenAI’s coding agent.
The README separates three experiences:
- Codex CLI: the local terminal coding agent
- Codex in IDEs: editor integrations for tools like VS Code, Cursor, and Windsurf
- Codex Web: the cloud-based Codex agent at ChatGPT
This post focuses on the open-source CLI repository.
The quick install paths are:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
npm install -g @openai/codex
brew install --cask codex
The README also points to GitHub release binaries.
Repository Shape
The current source checkout is a Rust-first repo:
| Path | What it contains |
|---|---|
codex-rs/ |
the main Rust workspace |
codex-cli/ |
npm wrapper package for launching the platform binary |
sdk/typescript/ |
TypeScript SDK that spawns Codex CLI and exchanges JSONL events |
sdk/python/ |
Python SDK for Codex threads, turns, streaming, and login helpers |
docs/ |
repo docs that mostly point to official OpenAI Codex docs |
scripts/ |
packaging, install, format, release, and support scripts |
.devcontainer/ |
development container setup |
The npm package is intentionally thin. codex-cli/bin/codex.js detects the platform, looks for a platform-specific optional package such as @openai/codex-linux-x64, and then spawns the native binary.
That is why a source checkout plus pnpm install is not the same as a usable local Codex build.
Installing and Authenticating
For day-to-day use, install the released CLI:
npm install -g @openai/codex
Then:
codex
For authentication, the local CLI supports:
codex login
codex login --with-api-key
codex login --with-access-token
codex login --device-auth
codex login status
The README recommends signing in with ChatGPT so Codex can use the user’s ChatGPT plan where applicable. API-key use is also supported, but it is a separate setup path.
Local Field Test
I cloned the repository into:
tmp/foss-post/codex
Source state:
| Item | Value |
|---|---|
| Commit | 87b808b |
| Commit message | fix(remote-control): preserve enrollment on generic websocket 404s (#26741) |
| Latest local tag observed | rust-v0.138.0-alpha.6 |
| License | Apache-2.0 |
Local environment:
| Item | Value |
|---|---|
| Node | v22.22.0 |
| npm | 10.9.4 |
| pnpm | 10.33.0 |
| Python | 3.12.3 |
| uv | 0.10.2 |
| Rust | not available on PATH |
| Free disk | about 19GB |
| Available RAM | about 1.6-1.8GB |
| Swap | 0B |
Workspace Dependency Install
I installed the workspace dependencies without lifecycle scripts:
/usr/bin/time -v pnpm install --frozen-lockfile --ignore-scripts
Result:
| Metric | Result |
|---|---|
| Exit status | 0 |
| Packages added | 529 |
| Wall time | 1.84s |
| Peak RSS | 658,856 KB |
Repo-local npm Wrapper
Then I tested the repo-local wrapper:
/usr/bin/time -v node codex-cli/bin/codex.js --version
It failed quickly:
Missing optional dependency @openai/codex-linux-x64.
Reinstall Codex: npm install -g @openai/codex@latest
That is a useful gotcha. The wrapper expects a platform binary package or vendored native binary. The source checkout itself does not create that binary unless you build the Rust workspace.
Installed CLI Surface
This machine already had Codex installed:
which codex
codex --version
codex --help
Observed:
~/.nvm/versions/node/v22.22.0/bin/codex
codex-cli 0.130.0
The help output exposed these commands:
| Command | Purpose |
|---|---|
codex |
interactive CLI |
codex exec |
non-interactive execution |
codex review |
non-interactive code review |
codex login / logout |
authentication |
codex mcp |
manage MCP servers |
codex plugin |
manage plugins |
codex mcp-server |
run Codex as an MCP server |
codex app-server |
experimental app-server tooling |
codex remote-control |
experimental remote-control app-server |
codex sandbox |
run commands inside a Codex-provided sandbox |
codex resume / fork |
continue or branch previous sessions |
codex cloud |
experimental Codex Cloud task browsing |
codex exec-server |
experimental standalone exec-server |
Important flags include:
codex --model <MODEL>
codex --sandbox read-only
codex --sandbox workspace-write
codex --sandbox danger-full-access
codex --search
codex --oss
codex --local-provider ollama
codex --local-provider lmstudio
And the intentionally scary one:
codex --dangerously-bypass-approvals-and-sandbox
No-auth Exec Test
I wanted to see what happens without touching the real Codex credentials, so I used a temp CODEX_HOME:
rm -rf tmp/codex-empty-home
mkdir -p tmp/codex-empty-home
/usr/bin/time -v timeout 25s env \
CODEX_HOME=/home/jalcocert/Desktop/fossengineerpapermod/tmp/codex-empty-home \
codex exec \
--ignore-user-config \
--skip-git-repo-check \
--ephemeral \
--sandbox read-only \
"Say hello in one sentence"
The command started and printed:
model: gpt-5.5
provider: openai
approval: never
sandbox: read-only
Then it retried the Responses websocket and failed with:
401 Unauthorized: Missing bearer or basic authentication in header
Result:
| Metric | Result |
|---|---|
| Exit status | 1 |
| Wall time | 18.26s |
| Peak RSS | 67,592 KB |
So an empty auth home does not fail instantly in codex exec. It starts the execution flow, attempts websocket connection, retries, and then fails with a clear auth error.
I did not run an authenticated model session in this pass.
Building from Source
The official source build path is Rust-based:
git clone https://github.com/openai/codex.git
cd codex/codex-rs
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
rustup component add rustfmt
rustup component add clippy
cargo install --locked just
cargo install --locked cargo-nextest
cargo build
cargo run --bin codex -- "explain this codebase to me"
The repo pins Rust:
[toolchain]
channel = "1.95.0"
components = ["clippy", "rustfmt", "rust-src"]
On this machine, rustc and cargo were not available, disk was already around 90% used, and there was no swap. I did not force a full Rust build.
That means the local trial validated the released CLI surface and JavaScript/SDK workspace pieces, but not the full native source build.
TypeScript SDK
The TypeScript SDK is useful if you want Codex inside another app or automation flow.
It wraps the codex CLI, starts threads, runs turns, streams structured events over JSONL, supports structured output schemas, forwards images, resumes threads, and lets callers control working directory and environment.
Install path:
npm install @openai/codex-sdk
Local SDK build:
/usr/bin/time -v pnpm -C sdk/typescript run build
Result:
| Metric | Result |
|---|---|
| Exit status | 0 |
| Wall time | 1.90s |
| Peak RSS | 307,332 KB |
SDK tests:
/usr/bin/time -v timeout 120s pnpm -C sdk/typescript test
Result:
| Metric | Result |
|---|---|
| Exit status | 1 |
| Wall time | 6.47s |
| Peak RSS | 327,604 KB |
The failure was consistent:
spawn .../codex-rs/target/debug/codex ENOENT
That is not surprising. The SDK tests expect a local debug Codex binary from the Rust build, and this machine did not build it.
Python SDK
The repo also contains a beta Python SDK:
pip install openai-codex
The README shows:
from openai_codex import Codex
with Codex() as codex:
thread = codex.thread_start()
result = thread.run("Explain this repository in three bullets.")
print(result.final_response)
It can reuse existing Codex authentication, start ChatGPT browser/device-code login, or store an API key.
I inspected the Python SDK docs and package metadata but did not run its tests in this pass.
Security and Sandboxing
Codex exposes sandbox modes directly in the CLI:
codex --sandbox read-only
codex --sandbox workspace-write
codex --sandbox danger-full-access
There is also a codex sandbox command with platform-specific subcommands:
codex sandbox linux
codex sandbox macos
codex sandbox windows
Inside the Rust workspace, the security-related surface is broad:
- sandboxing crates
- Linux sandbox / bubblewrap support
- Windows sandbox support
- execution policy engines
- process hardening
- network proxying
- shell escalation protocol
The practical recommendation is simple: use the default sandbox/approval modes unless you understand exactly why you are changing them. The bypass flag is labeled dangerous for a reason.
Codex vs Pi vs Herdr vs NanoClaw
| Tool | Best Fit |
|---|---|
| Codex CLI | OpenAI’s local coding agent and reference Codex developer workflow |
| Pi | Open multi-provider coding-agent CLI and TypeScript toolkit |
| Herdr | Persistent terminal workspace manager for multiple coding agents |
| NanoClaw | Container-isolated personal assistant runtime |
| Graphify | Codebase knowledge graph layer that agents can query |
Codex and Pi are the closest pair. Both can be local coding-agent CLIs, and both now have SDK/toolkit surfaces. The difference is that Codex is the OpenAI-native path, while Pi is more explicitly multi-provider.
Herdr is not a replacement for Codex; it can sit around Codex sessions. Graphify is also not a replacement; it can give Codex a graph-shaped memory of a codebase.
If you are reading the agentic tooling series in order, start here, then compare OpenCode and Pi before moving up the stack to Herdr, Graphify, Paperclip, and Symphony.
Conclusion
Codex CLI is the OpenAI-native local coding agent path, and the open repo shows a serious implementation behind it: Rust core, npm distribution wrapper, SDKs, app-server pieces, sandboxing, exec policy, MCP, and remote-control work.
The local trial confirmed the installed CLI surface, the no-auth failure mode, the workspace install, and the TypeScript SDK build. It also surfaced the important source-build caveat: without Rust and a built codex-rs/target/debug/codex, the repo-local npm wrapper and SDK tests cannot fully run.
For readers choosing between current agentic CLI tools, Codex is the right baseline to include. It is the OpenAI reference implementation, while Pi, Herdr, NanoClaw, and Graphify each occupy adjacent but different parts of the local agent workflow.
FAQ
Is OpenAI Codex CLI open source?
openai/codex repository is public and licensed under Apache-2.0. The CLI still depends on OpenAI authentication for OpenAI-hosted model use.
Can I install Codex CLI with npm?
Yes:
npm install -g @openai/codex
The source checkout’s local npm wrapper is not enough by itself unless the platform binary dependency or a locally built Rust binary is present.
Does Codex CLI support API keys?
Yes. The installed CLI exposes:
codex login --with-api-key
The README also recommends ChatGPT sign-in for users who want Codex through their ChatGPT plan.
Did you run a real authenticated Codex task locally?
CODEX_HOME for the execution test. The CLI started, retried the Responses websocket, and failed with 401 Unauthorized.
Can Codex run with local models?
--oss and --local-provider with lmstudio and ollama options. I did not validate a local-model Codex session in this pass.
Comments