Email: rosnerelena7@gmail.com
Phone:(213) 525-8821
Address: 611 N Brand Blvd, Suite 510, Glendale, CA 91203, USA
Email: rosnerelena7@gmail.com
Phone:(213) 525-8821
Address: 611 N Brand Blvd, Suite 510, Glendale, CA 91203, USA
Codex CLI is OpenAI's open source, terminal based coding agent that reads, edits, and runs code from natural language prompts.
This codex cli tutorial walks through installing it, signing in, and running your first session, plus the commands and settings you'll actually use.
Codex CLI is a command line tool built by OpenAI. According to TechCrunch, OpenAI introduced it as a lightweight, open source coding agent designed to run locally in a developer's terminal.
It runs directly inside your terminal, reads the files in your project directory, and can edit them, run shell commands, and carry out multi step tasks based on plain English instructions.
It doesn't need a separate code editor to function. Open a terminal, point it at a folder, and it works from whatever is already there.
This codex cli tutorial focuses on the parts of the tool most people actually reach for: getting it installed, signed in, and running, then understanding the settings that control how much it's allowed to do on its own.
In practice, most people treat it less like a chatbot and more like a colleague who can read the whole repository before answering.
A few things need to be in place first:
None of this is unusual by CLI tool standards. Teams commonly report that the Node.js version mismatch is the single most common install snag, so it's worth checking node -v before anything else.
There are three confirmed ways to install it, and which one makes sense depends mostly on what's already on your machine.
npm install –global @openai/codex
This is the most common method and requires Node.js to already be installed.
brew install codex
Straightforward if you're already using Homebrew for other command line tools.
curl -fsSL https://chatgpt.com/codex/install.sh | sh
This skips Node.js entirely. Platform specific binaries are also available directly from GitHub releases, which is worth knowing if you're setting this up on a machine without internet access to npm.
Once it's installed, confirm it actually worked:
codex –version
You should see output similar to codex-cli 0.77.0. The exact version number will differ depending on when you install, since it updates regularly.
Codex needs to know who you are before it does anything useful.
Run codex or codex login, and it opens a browser window to authorize access. Once approved, usage is billed through your existing ChatGPT plan rather than separately.
For automation, scripts, or CI/CD pipelines, an API key works better than an interactive login:
export OPENAI_API_KEY=YOUR_API_KEY
This is the method most teams use when Codex is being called from a pipeline rather than a person typing at a keyboard.
Navigate to your project first:
cd ~/your-project
If typing terminal commands isn't second nature yet, most file browsers let you right click a folder and open a terminal directly at that location. Either route gets you to the same place.
codex
The first time you run this inside a given project, it asks which approval mode to use. That choice matters more than it seems, and it's covered in detail below.
Simple prompts work fine to start:
Codex reads the relevant files, proposes a change, and shows a diff before touching anything. Nothing gets modified without your review, at least not under the default settings.
This is one part of the codex cli tutorial worth slowing down for, because it's the setting most likely to catch people off guard later. Approval modes decide how much Codex can do without asking first.
|
Mode |
What It Does |
|
Auto (default) |
Reads, edits, and runs commands inside your working directory automatically. Asks before doing anything outside that scope. |
|
Read-only |
Keeps Codex consultative. It can look at files and suggest changes, but it won't edit or run anything without explicit approval. |
|
Full Access |
Grants broader autonomy, including network access. Best reserved for tasks where you already trust the scope of work. |
Switch between modes mid session with /permissions (some versions use /approval).
Interestingly, a lot of the "why isn't Codex doing X" confusion people run into traces back to a restrictive mode blocking an action quietly rather than the tool actually failing.
Press / inside a session to see the full list. The ones you'll use most:
Prefix any shell command with ! to run it directly without leaving the session:
!ls
!pwd
!git status
The output stays visible in the conversation, so Codex can reference it without you having to describe what you're seeing.
In practice, this usually saves more time than it looks like on paper, since it removes the back and forth of switching terminal windows.
Use @filename to point Codex directly at a file rather than letting it search the whole directory.
Closing a session doesn't lose your context. Exiting gives you a session ID, and you can pick back up with:
codex resume ID
Or, to grab the most recent one without hunting for the ID:
codex resume –last
Session logs are stored locally in JSON Lines format under ~/.codex/sessions/. What's often overlooked is that these same session files are shared with supported editor extensions, so a conversation started in the terminal can continue inside an editor, and vice versa.
Codex reads a file called AGENTS.md at the start of every session if one exists at the project root.
It's a plain markdown file describing conventions for that specific project, such as the tech stack, testing rules, and formatting preferences.
Teams commonly report that setting this up once at the start of a project saves them from repeating the same instructions in every session afterward.
A basic version might just list the stack and a couple of hard rules, like requiring tests to pass before a commit.
Model Context Protocol, or MCP, is an open standard that lets Codex connect to tools outside your local filesystem, such as a browser, a design tool, or a documentation source.
According to Wikipedia, the protocol was introduced in November 2024 to standardize how AI systems integrate and share data with external tools, and it has since been adopted by major AI providers, including OpenAI.
A server can be added with a single command:
codex mcp add [server-name] [command]
Confirm it's connected with:
codex mcp list
Alternatively, servers can be configured directly by editing ~/.codex/config.toml. This route is more manual but gives more visibility into exactly what's connected and how.
A Skill is a reusable set of instructions, stored in a SKILL.md file alongside any needed resources or scripts, that Codex can run on demand for a repeatable task.
Rather than re-explaining a multi step workflow every time, a Skill lets you trigger it with a short phrase.
This tends to matter most once a workflow has been repeated a few times manually. At that point, packaging it into a Skill removes the repetition without needing to script it separately outside of Codex.
A handful of problems come up often enough to be worth listing directly.
Getting Codex CLI running comes down to a short sequence: install it, sign in, run your first session, and understand approval modes before handing it more autonomy.
Everything else, from MCP servers to Skills, builds on that same foundation.
Not entirely on its own. It requires either a paid ChatGPT plan that includes Codex access, or billing through an OpenAI API key. There's no standalone free tier confirmed for ongoing use.
It runs on Windows, but support is described as experimental. For a more stable experience, running it inside WSL (Windows Subsystem for Linux) is the commonly recommended approach.
Auto handles edits and commands automatically within your working directory. Read-only limits it to suggestions. Full Access allows broader autonomy, including network access, for tasks where more trust is warranted.
Yes. Authenticating with an OpenAI API key instead of a ChatGPT sign in works, and it's the more common route for automation or CI/CD use rather than interactive sessions.
Locally, in JSON Lines format, under ~/.codex/sessions/ on your machine. These same files are also read by supported editor extensions, so sessions can carry over between terminal and editor.
Start simplifying your schedule and boosting productivity with Work Schedule’s powerful tools.



