AI CODING TOOLS / LESSON 14
Setting Up Codex.
Install the Codex CLI, sign in, and run your first safe task

Loading the lesson…
Loading activities…
AI CODING TOOLS / LESSON 14
Install the Codex CLI, sign in, and run your first safe task

Loading the lesson…
Loading activities…
Time to get Codex running on your own computer. We'll install the Codex CLI, sign in, open it in a project folder and give it a first task that can't break a thing. Then we'll look at how Codex asks permission and where the AGENTS.md file fits in.
If you followed the Claude Code installation lesson, a lot of this is gonna feel familiar.
OpenAI's official README gives one main install command for each kind of computer.
Open your terminal and run this.
Open PowerShell and run this.
If you already use a package manager, these work too.
You only need ONE of these. If you're not sure, go with the main installer.
First, move into your project folder. If your project lives in a folder called my-project, it looks like this.
Now fire up Codex.
The first time you run it, Codex asks how you want to sign in. Choose Sign in with ChatGPT. A browser window pops open, you log in to your ChatGPT account, and the browser hands your login back to Codex. Donezo.
If you ever need to sign in again on purpose, run codex login. To check which account you're on, run codex login status.
When Codex starts up, it shows a lil welcome box with the model it's using and the folder it's working in. Below that you'll see a short list of commands you can type. They're called slash commands because they start with /.
Here are the ones worth knowing on day one.
| Command | What it does |
|---|---|
/init | Creates an AGENTS.md file with instructions for Codex |
/status | Shows your current settings, including what Codex is allowed to do |
/permissions | Lets you choose what Codex can do without asking first |
/diff | Shows exactly what changed in your files |
/review | Asks Codex to review your changes and point out problems |
Type /status now. It's an easy way to make sure Codex is pointed at the right folder before you ask it to do anything.
Make your first prompt a question. Questions only read files, so nothing on your computer gets touched. OpenAI's own quickstart suggests this one.
Codex reads through your folder and explains what the project is, how it's organized and which files matter. Read the answer and see if it lines up with what you know about the project.
Once that feels comfortable, try a teeny, low-risk change.
When Codex finishes, type /diff to see exactly what it changed. Like it? Keep it. Don't like it? Ask Codex to undo it, or use Git to throw the change away.
Codex keeps you safe with two layers working together.
When you start Codex in a folder tracked by Git, it recommends a setup OpenAI calls Auto. In Auto, Codex can read files, edit files and run commands inside your project folder on its own. It has to ask you before it edits anything outside the project folder or uses the internet. Internet access for commands is off by default.
In a folder that isn't tracked by Git, Codex recommends read-only instead, so it can look but can't change anything. Depending on your setup, Codex may also start read-only until you tell it you trust the folder.
Type /permissions whenever you want to switch. These are the two you'll use most as a beginner.
You can also pick these when you start Codex.
Remember CLAUDE.md from the Claude Code lessons? That's the file Claude Code reads at the start of every session so it knows your project's rules. Codex has the same idea, and its file is called AGENTS.md.
Codex reads AGENTS.md files before it does any work. You can put them in a few places.
AGENTS.md at the top of your project holds that project's rules. This is the one you'll use most.~/.codex/AGENTS.md holds personal preferences that apply to every project.AGENTS.md files deeper in, for rules that only apply to one part. Codex reads the ones between the top of your project and the folder you started it in, and when rules disagree, the file closest to that folder wins.The easiest way to start one is to run /init inside Codex. It creates an AGENTS.md starter you can edit. A simple one might look like this.
Codex combines these files up to a size limit (32 KiB by default), so keep them short and focused, same as a good CLAUDE.md.
Close your terminal completely and open a new one. Still nothing? Run the install command again and keep an eye out for error messages.
Run codex login to start the sign-in again. Make sure you're logging in to the same ChatGPT account that has your plan.
Type /status to see your current permissions. If you're in Read Only, use /permissions to switch to Auto. If your folder isn't tracked by Git, Codex may be recommending read-only on purpose.
codexAGENTS.md is Codex's version of CLAUDE.md, and /init makes one for youYou've now got both Claude Code and Codex installed. Next lesson we'll put them side by side and talk about when you might reach for each one...