The power of OpenAI’s latest reasoning models is delivered straight to your terminal with the OpenAI Codex CLI, an open-source command-line tool. It serves as a portable coding assistant that can read, edit, and execute code locally on your computer to speed up feature development, fix issues, and help you understand complex code. Your source code never leaves your environment unless you choose to share it, as the CLI operates locally, according to OpenAI. In this article, I will show you how to install and use OpenAI’s Codex CLI locally.
Codex CLI is designed for developers who are comfortable in the terminal and want ChatGPT-level reasoning combined with the ability to run code, manage files, and iterate, all while keeping version control intact. In short, it’s chat-driven development that understands and executes your code. Some of its key features are:
Please note that Codex CLI is an ongoing experimental project. It may have issues, lack features, or experience disruptive changes because it is not yet stable.
Also Read: How to Access and Use OpenAI Codex?
Approval modes control the level of access granted to the AI system (Codex CLI). There are three approval modes available, each described below:
Mode | What the Agent Can Do | When to Use |
---|---|---|
Suggest (default) | Read files. Proposes edits & shell commands, but requires your approval before making changes or executing commands. | Safe exploration, code reviews, learning a codebase. |
Auto Edit | Read and write files automatically. Still asks before running shell commands. | Refactoring or repetitive edits where you want to keep an eye on side-effects. |
Full Auto | Read, write, and execute commands autonomously inside a sandboxed, network-disabled environment scoped to the current directory. | Longer tasks like fixing a broken build or prototyping features while you grab a coffee. |
macOS 12+
Codex CLI uses Apple Seatbelt (sandbox-exec
) to sandbox commands.
$PWD
, $TMPDIR
, and ~/.codex
, which remain writable.curl
, it will fail.Linux
Sandboxing is not enabled by default. OpenAI recommends using Docker for sandboxing.
Codex CLI runs inside a lightweight container image, with your repository mounted in the same location for read/write access. A custom iptables
/ipset
firewall script blocks all egress except access to the OpenAI API. This ensures repeatable, predictable execution without requiring root access on the host. To enable this, use the run_in_container.sh
script to configure the sandbox environment.
codex-mini-latest is a fine-tuned version of o4-mini specifically for use in Codex CLI. It has a context window of 200k, and can output a max of 100,000 tokens. codex-mini-latest’s is pricing between GPT-4.1 and o4-mini, and below is the image showing the pricing of input, cached input, and output per million tokens.
Follow these simple steps to access Codex CLI:
If you would like to experiment with a dummy repository, suggesting you to clone this repository so that we can start testing out codex cli. Github Repository link
Use the command “git clone https://github.com/Badribn0612/warren_buffet_persona” to clone this repository. You can use a even smaller repository as well.
Use the command “cd <working directory>” to go to that directory.
Now that we are set to start accessing Codex CLI. Let’s install the same. Use the command:
npm install -g @openai/codex – this command will install codex cli globally in your system.
OpenAI provides 5$ worth of codex-mini-latest api for Plus users and 50$ worth of credits for Pro users. In order to redeem that use the command.
codex — login
This will ask you to login or use an API key.
After successfully Signing in into Codex CLI, you should be able to see a successful redemption message in your terminal as well as your OpenAI dashboard.
Start accessing codex cli:
After 3 entire minutes of skimming and scanning the repository it gave me a comprehensive response about the repository.
Let’s now ask Codex CLI to make some changes.
Prompt: “Enhance the chainlit application app.py, this has the persona of warren buffet:
1. Add search tools
2. Improve the code quality, 3. Enhance the chainlit application”
Output:
After running the codex cli for around 15+ min, and having gone through changes made by the agent and approving them, the execution stopped.
Above are some screenshots in between the Codex CLI agent execution.
Also Read: 12 AI Code Generator Tools in 2025
Based on my experience using the Codex CLI agent, I found that it takes a cautious and deliberate approach when making changes. It verifies each step, applies modifications only where necessary, and consistently aims to find the best possible solution. However, the process can be noticeably slower compared to making similar changes manually using tools like Cursor or Windsurf.
Of course, this is just my personal experience, your results may vary depending on the domain or tech stack you’re working with. In this case, the codebase involved recently updated libraries, which Codex struggled with. (Note: Codex has a knowledge cutoff of June 1, 2024)
You might also consider experimenting with Claude Code to see how it handles your use case, and decide which tool works best for your workflow.
Also Read: Building a CodeBase Explorer with Google’s Gemini-2.0
Codex CLI is a powerful command-line tool that brings OpenAI’s advanced reasoning capabilities directly to your local development environment. It allows developers to interact with their code, using natural language, enabling tasks like debugging, refactoring, and feature development, all while keeping sensitive data local and secure.
With built-in sandboxing, multimodal support, and minimal setup, Codex CLI is ideal for developers who prefer working in the terminal and want to maintain full control over their codebase. While it remains experimental and may be slower than other tools in certain scenarios, its careful approach to code changes and strong emphasis on privacy make it a compelling choice for integrating intelligent code assistance into your workflow.