Why OpenAI Rewrote Codex CLI in Rust: Boosting Performance, Security, and Simplicity
OpenAI has rebuilt its upcoming AI command‑line tool Codex CLI in Rust, citing faster performance, stronger security, zero‑dependency installation, sandbox support, and low memory usage, while maintaining compatibility with its TypeScript version and extending support for JavaScript and Python.
OpenAI recently rewrote its upcoming AI command‑line coding tool Codex CLI in Rust, improving performance and security while removing the dependency on Node.js, which can be a barrier for some users.
Codex is an experimental coding agent that can run in the ChatGPT web browser or locally via the Codex CLI. The CLI offers a chat‑style interactive mode (prompts starting with codex) and a silent non‑interactive mode suitable for continuous‑delivery pipelines such as changelog generation.
It should not be confused with the earlier product also named Codex that was discontinued in March 2023.
Codex CLI is open‑source on GitHub: https://github.com/openai/codex. It can be run on macOS, Linux, or Windows (via WSL). The original source was written in TypeScript for Node.js, but the team has now rewritten it in Rust.
Maintainer Fouad Matin notes that until the Rust version reaches feature parity with the TypeScript implementation, bug‑fixes will continue to be merged into the TypeScript codebase.
The rewrite is driven by four key reasons:
Zero‑dependency installation, eliminating the need for Node.js 22 or higher.
Sandbox requirements: on macOS the CLI is wrapped by Apple Seatbelt (sandbox‑exec); on Linux OpenAI recommends container execution, and they have created a sandbox method using sandbox‑exec on macOS and Landlock on Linux.
Performance optimization: no runtime garbage collection and very low memory consumption.
Ability to use the existing Rust MCP (Model Context Protocol) implementation, allowing the CLI to act as either an MCP client or server.
Rust, as a systems language, runs more efficiently than code executed on the V8 JavaScript engine used by Node.js, though it is harder to program.
Despite Rust’s lower popularity compared with JavaScript and Python, the Rust‑based Codex CLI remains extensible and already supports generating code in JavaScript and Python.
OpenAI is not the only organization investing in Rust for performance gains; Vue.js creator Evan You released Rolldown‑Vite, a Rust‑based replacement for Rollup.js that reduces production build time from one‑third to one‑sixteenth and cuts memory usage by up to a hundredfold.
Editor: Action‑in‑Progress
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
