Skip to main content
This guide covers building Codex CLI from source, including both the Rust and legacy TypeScript implementations.

Building the Rust Implementation

The Rust implementation is the maintained version of Codex CLI and lives in codex-rs/.

Quick Start

1

Navigate to Workspace

2

Build with Cargo

For optimized builds, use cargo build --release
3

Run the TUI

Launch the TUI with a sample prompt:
After making changes, use these workspace helpers:
Important: Run just fmt automatically after making Rust code changes. Do not re-run tests after running fix or fmt.

Workspace Organization

The codex-rs/ directory is a Cargo workspace with these key crates:
CratePurpose
core/Business logic for Codex - intended as a reusable library crate
tui/Fullscreen TUI built with Ratatui
exec/Headless CLI for automation and non-interactive use
cli/CLI multitool providing TUI and exec via subcommands
app-server/App server protocol implementation
app-server-protocol/Protocol types and schemas
For detailed information about each crate, read the module-level README.md files under each crate directory.

Building the TypeScript Implementation

The TypeScript implementation is legacy and has been superseded by the Rust implementation. This section is for reference only.
The legacy TypeScript CLI lives in codex-cli/.
1

Navigate to CLI Directory

2

Build with pnpm

3

Run Locally

TypeScript Build Commands

Debugging

Debugging the Rust CLI

1

Enable Verbose Logging

Set the RUST_LOG environment variable:
2

View TUI Logs

The TUI logs to ~/.codex/log/codex-tui.log by default:
Override the log directory with:
The TUI defaults to RUST_LOG=codex_core=info,codex_tui=info,codex_rmcp_client=info.Non-interactive mode (codex exec) defaults to RUST_LOG=error with messages printed inline.See the Rust documentation on RUST_LOG for more configuration options.

Debugging the TypeScript CLI

1

Build with Source Maps

This generates cli.js.map alongside cli.js in the dist folder.
2

Run with Debugger

The program waits until a debugger is attached.
3

Attach Debugger

Choose one:
  • VS Code: Run Debug: Attach to Node Process from the command palette and select the option with debug port 9229
  • Chrome: Go to chrome://inspect and find localhost:9229, then click inspect

Enable Debug Output

For the TypeScript CLI, enable full API request and response logging:

Troubleshooting

Ensure all required tools are installed:
Make sure you’re running tests from the correct directory:
  • Rust: Run from codex-rs/
  • TypeScript: Run from codex-cli/
See Testing for detailed test commands.
Run the automatic fixers:

Next Steps

Testing

Learn about testing workflows

Guidelines

Review coding standards