---
id: chatgpt-codex
lang: en
track: chatgpt
title: "Codex"
seoTitle: "Codex in ChatGPT: what it is, how to start"
description: "Codex is ChatGPT's agent for code and technical work. Where it runs, how the review-and-approve loop works, how to set permissions, and how to start small."
part: advanced
partTitle: "Advanced"
partOrder: 5
order: 1
level: Advanced
durationMinutes: 9
outcome: "Explain what Codex is, understand its review-and-approve loop and permission modes, and run it on a small task in a real folder or codebase."
summary: "Codex is ChatGPT's agent for building and changing software. It works in a folder or repository, shows you every change as a diff, and asks before it steps outside the lines you set. Start small, keep it on Ask for approval, and review before you keep anything."
draft: false
updated: "2026-10-14"
furtherReading:
  - title: "Codex quickstart (ChatGPT Learn)"
    url: "https://learn.chatgpt.com/codex/quickstart"
    note: "Signing in, choosing a folder, and your first task in the desktop app."
  - title: "Permission modes (ChatGPT Learn)"
    url: "https://learn.chatgpt.com/codex/permission-modes"
    note: "Ask for approval, Approve for me, Full access, and what each one allows."
  - title: "AGENTS.md (ChatGPT Learn)"
    url: "https://learn.chatgpt.com/codex/agent-configuration/agents-md"
    note: "How to give Codex standing instructions for a project."
  - title: "ChatGPT Work and Codex"
    url: "https://help.openai.com/en/articles/20001275-chatgpt-work-and-codex"
    note: "How Codex sits next to Work, where it runs, and how usage is counted."
keywords:
  - OpenAI Codex
  - Codex in ChatGPT
  - Codex CLI
  - AGENTS.md
  - AI coding agent
  - Codex permission modes
quiz:
  intro: "Five quick questions. Ace them all and you can hand Codex a real job."
  passScore: 5
  questions:
    - q: "Where can you use Codex?"
      options:
        - "Only in a terminal on your own laptop, through the Codex CLI"
        - "Only on chatgpt.com in your browser"
        - "In the desktop app, a terminal, your editor, or the cloud"
        - "Only inside GitHub, as comments on pull requests"
      answer: 2
      explain: "Codex lives in several places: the Codex view of the desktop app, the CLI in a terminal, an IDE extension, and Codex Cloud for tasks that keep running when your laptop sleeps."
    - q: "Codex is on Ask for approval and wants to use the internet. What happens?"
      options:
        - "It goes ahead; the internet is always allowed"
        - "It asks you first before going online"
        - "It sends the request to automatic review"
        - "It switches itself to Full access"
      answer: 1
      explain: "Ask for approval keeps Codex inside your workspace folder. Anything beyond that, like the internet or files elsewhere, needs your yes first. It's the mode OpenAI recommends starting with."
    - q: "Do you need to upload your code for Codex to work on it?"
      options:
        - "No; you point it at a folder or repository"
        - "Yes, as a zip file in the chat"
        - "Yes, into a project it can read"
        - "Only for repositories hosted on GitHub or GitLab"
      answer: 0
      explain: "Codex works where your code lives: a local folder in the desktop app or terminal, or a repository connected to a cloud environment. No copy-pasting."
    - q: "What is an AGENTS.md file good for?"
      options:
        - "Storing the API keys Codex needs"
        - "Keeping a log of what Codex changed in each session"
        - "Choosing Codex's permission mode"
        - "Standing project rules, like which tests to run"
      answer: 3
      explain: "Codex reads AGENTS.md before it starts. Write your project's working agreements there once, and you stop repeating them every session."
    - q: "When is Codex the right tool, rather than Chat or Work?"
      options:
        - "For a deck built from a report"
        - "For building or fixing code in a real codebase"
        - "For a cited report on a market"
        - "For a quick question about a snippet you'll paste"
      answer: 1
      explain: "Chat is for quick answers, Work for documents and multi-step office tasks, and Codex for code: it brings a sandbox, diffs, tests, and Git along."
  pass:
    badge: "Codex unlocked"
    title: "You can hand a real coding job to an agent now."
    body: "Full marks. You know where Codex runs, how its approve-first loop works, and how to keep it inside the lines. Next: images, Sites and slides, for things you can see."
  retry: "Check the marked answers and give it another go. You've got this."
---

> **Level:** Advanced · **Reading time:** ~9 min
>
> **What you'll be able to do:** explain what Codex is, understand its review-and-approve loop and permission modes, and run it on a small task in a real folder or codebase.

Everything so far has lived in Chat or in [Work](/learn/chatgpt/working-smart/chatgpt-work-on-your-files). This lesson steps onto different ground: **Codex**, ChatGPT's agent for code. It reads a codebase, writes and changes files, runs commands and tests, and shows you every change before you keep it. It is the most technical tool in the course, and the most powerful for one job: building and changing software.

You don't have to be a developer to get something out of this lesson. Plenty of business people now use Codex for small, useful things: a script that cleans up a spreadsheet export, a tweak to the company website, a quick internal tool. Even if you never open it yourself, knowing what it does helps you talk to the people who do.

## What Codex actually is

**Codex is an agent for software work.** You give it a goal ("add a search box to this page", "find out why this test fails"), and it plans, reads the relevant files, makes changes, runs commands to check them, and reports back.

Three things set it apart from asking for code in a normal chat:

- **It works where the code lives.** You point it at a folder or a repository. It reads the real files instead of the snippet you pasted.
- **It acts, not just suggests.** It edits files, runs tests, installs what the project needs, and tries again when something breaks.
- **It shows its work as a diff.** Every change is laid out line by line: red for removed, green for added. You review, then keep or throw away.

OpenAI describes Codex as dedicated to "software development and technical work." That focus is the point. Work is the generalist for documents and office tasks; Codex is the specialist with a workshop full of developer tools.

## Who it is for, and why a non-coder might still care

The main audience is obvious: **developers**, who use it to build features, fix bugs, write tests, and review pull requests.

But look at who else gets value:

- **Analysts** who need a script to reshape data every week.
- **Marketers** who want a small change on the website without waiting for a sprint.
- **Product people** who want to try an idea as a working prototype.
- **Managers** who want to understand what a codebase does before a meeting.

**A worked example.** Every Monday, Sofie in finance downloads a sales export, deletes three columns, fixes the date format, and pastes the result into a template. Twenty minutes, every week, and easy to get wrong. She opens Codex on a folder with last week's export and asks for a small script that does exactly those steps and saves a clean file next to the original. Codex writes it, runs it on the sample, and shows her the result. She checks the numbers against last week's version. From then on, Monday takes one click. She never had to read the script line by line; she only had to check the output.

A reasonable rule: if the job ends in *code that runs*, Codex is worth a look. If it ends in a document, a deck, or a Site, Work is usually the better fit.

## Where you find it

Codex comes in several shapes, all signed in with the same ChatGPT account:

- **The desktop app.** Pick **Codex** from the menu at the top left. It has its own history, separate from your chats, and works with local folders, repositories, and the terminal.
- **The Codex CLI.** For people who live in a terminal. You install it, open a project folder, and type `codex`.
- **The IDE extension.** Codex inside your code editor, next to your files.
- **Codex Cloud.** Tasks run on machines OpenAI manages, so they keep going while your laptop sleeps. You can start or check them from desktop, web, or phone, once a cloud environment is set up.

<figure class="lesson-svg" aria-labelledby="chatgpt-codex-surfaces-title">
<svg viewBox="0 0 640 250" width="100%" height="auto" role="img" xmlns="http://www.w3.org/2000/svg" font-family="Inter, system-ui, sans-serif">
<title id="chatgpt-codex-surfaces-title">One agent, four places to work</title>
<desc>Four cards: the desktop app with its Codex view, the CLI in a terminal, the IDE extension in your code editor, and Codex Cloud, which keeps running when your laptop sleeps. Underneath, what they share: your ChatGPT sign-in, AGENTS.md, and permission modes.</desc>
<text x="0" y="24" font-size="20" font-weight="800" fill="var(--ink,#1F2328)">One agent, four places to work</text>
<text x="0" y="48" font-size="13.5" fill="var(--soft-gray,#6E747C)">Same Codex, same sign-in, wherever you prefer to work.</text>
<rect x="0" y="66" width="148" height="112" rx="12" fill="var(--part-tint,#F2ECFB)" stroke="var(--part,#7A50C7)"/>
<rect x="14" y="80" width="22" height="22" rx="6" fill="var(--part,#7A50C7)"/>
<text x="14" y="126" font-size="14" font-weight="800" fill="var(--part-ink,#5B37A0)">Desktop app</text>
<text x="14" y="148" font-size="12" fill="var(--med-gray,#5B6169)">Codex view, local</text>
<text x="14" y="165" font-size="12" fill="var(--med-gray,#5B6169)">folders and repos.</text>
<line x1="74.0" y1="180" x2="74.0" y2="192" stroke="var(--part,#7A50C7)" stroke-width="2" stroke-linecap="round"/>
<path d="M68.0 189 L74.0 198 L80.0 189" fill="none" stroke="var(--part,#7A50C7)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<rect x="164" y="66" width="148" height="112" rx="12" fill="#fff" stroke="var(--line,#E7E9EC)"/>
<rect x="178" y="80" width="22" height="22" rx="6" fill="var(--part,#7A50C7)"/>
<text x="178" y="126" font-size="14" font-weight="800" fill="var(--ink,#1F2328)">CLI</text>
<text x="178" y="148" font-size="12" fill="var(--med-gray,#5B6169)">In a terminal:</text>
<text x="178" y="165" font-size="12" fill="var(--med-gray,#5B6169)">type codex.</text>
<line x1="238.0" y1="180" x2="238.0" y2="192" stroke="var(--part,#7A50C7)" stroke-width="2" stroke-linecap="round"/>
<path d="M232.0 189 L238.0 198 L244.0 189" fill="none" stroke="var(--part,#7A50C7)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<rect x="328" y="66" width="148" height="112" rx="12" fill="#fff" stroke="var(--line,#E7E9EC)"/>
<rect x="342" y="80" width="22" height="22" rx="6" fill="var(--part,#7A50C7)"/>
<text x="342" y="126" font-size="14" font-weight="800" fill="var(--ink,#1F2328)">IDE extension</text>
<text x="342" y="148" font-size="12" fill="var(--med-gray,#5B6169)">Next to your files</text>
<text x="342" y="165" font-size="12" fill="var(--med-gray,#5B6169)">in your editor.</text>
<line x1="402.0" y1="180" x2="402.0" y2="192" stroke="var(--part,#7A50C7)" stroke-width="2" stroke-linecap="round"/>
<path d="M396.0 189 L402.0 198 L408.0 189" fill="none" stroke="var(--part,#7A50C7)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<rect x="492" y="66" width="148" height="112" rx="12" fill="#fff" stroke="var(--line,#E7E9EC)"/>
<rect x="506" y="80" width="22" height="22" rx="6" fill="var(--part,#7A50C7)"/>
<text x="506" y="126" font-size="14" font-weight="800" fill="var(--ink,#1F2328)">Codex Cloud</text>
<text x="506" y="148" font-size="12" fill="var(--med-gray,#5B6169)">Keeps running while</text>
<text x="506" y="165" font-size="12" fill="var(--med-gray,#5B6169)">your laptop sleeps.</text>
<line x1="566.0" y1="180" x2="566.0" y2="192" stroke="var(--part,#7A50C7)" stroke-width="2" stroke-linecap="round"/>
<path d="M560.0 189 L566.0 198 L572.0 189" fill="none" stroke="var(--part,#7A50C7)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<rect x="0" y="200" width="640" height="40" rx="10" fill="var(--part,#7A50C7)"/>
<text x="320" y="225" font-size="13" font-weight="700" fill="#fff" text-anchor="middle">Shared everywhere: your ChatGPT sign-in, AGENTS.md, permission modes</text>
</svg>
</figure>

On top of that, Codex can **review pull requests on GitHub**: automatically, or when someone asks it to in the PR. It posts comments; a human still decides what to merge.

## Getting in: your first run

The quickest start is the desktop app:

1. **Open the app and sign in** with your work ChatGPT account.
2. **Switch to Codex** and **choose where it works**: open a folder or a repository on your computer.
3. **Describe the goal** in plain words, and add any files or context it needs.
4. **Watch, answer its questions, and review** what it changes.

Prefer the terminal? Install the CLI (OpenAI's quickstart gives a one-line installer for Mac and Linux), go to your project folder, and run `codex`. The first time, choose **Sign in with ChatGPT**. A few commands to know: `/init` writes a starter AGENTS.md for the project, `/permissions` sets what Codex may do, and `/review` checks your changes without touching your files.

**One habit before you start:** use **Git**, and save a checkpoint before and after each task. OpenAI's own docs recommend it. If a change goes wrong, you roll back in seconds.

## The core loop: ask, review the diff, approve

Every Codex session runs the same loop.

**1. Ask.** Describe the outcome, not the steps. "The contact form doesn't send when the phone field is empty. Find out why and fix it. Run the existing tests after." The prompting lessons from Part 3 apply in full: goal, context, format, boundaries.

**2. It works.** Codex reads the files it needs, makes a plan, edits, and runs commands. You see what it is doing as it goes.

**3. Review the diff.** Before you keep anything, read the changes. You don't need to understand every line. Ask yourself: is it touching the files I expected? Is the change about the size I expected? Did the tests pass?

**4. Approve, or steer.** Happy? Keep it and commit. Not happy? Say what's wrong, in plain words, and let it try again. Or roll back to your checkpoint.

**Keep tasks small.** "Fix this bug" works far better than "rebuild the whole app." Small tasks give small diffs, and small diffs are easy to check.

## Permission modes: how much it may do alone

Codex works inside a **sandbox**: a boundary that decides which files and network resources it can reach. On top of that sits the **permission mode**, which you set below the message box in the app, or with `/permissions` in the CLI:

- **Ask for approval.** Codex works inside the workspace folder. It asks before editing files outside it or using the internet. **OpenAI recommends starting here for most work.**
- **Approve for me.** The same boundary, but requests to cross it go to an automatic review first. Only actions flagged as possibly unsafe come back to you.
- **Full access.** No restrictions: the internet and any file on your computer. Powerful, and rarely what you want.
- **Custom.** Rules set in a configuration file, often by your IT team.

<figure class="lesson-svg" aria-labelledby="chatgpt-codex-permissions-title">
<svg viewBox="0 0 640 300" width="100%" height="auto" role="img" xmlns="http://www.w3.org/2000/svg" font-family="Inter, system-ui, sans-serif">
<title id="chatgpt-codex-permissions-title">How far Codex may go on its own</title>
<desc>A purple box is the workspace folder where Codex works on Ask for approval. On its edge, a gate: crossing it, to the internet or files elsewhere, needs your approval, or an automatic review on Approve for me. Around it, a dashed outer area is Full access: the whole computer and the internet, without asking.</desc>
<text x="0" y="24" font-size="20" font-weight="800" fill="var(--ink,#1F2328)">How far Codex may go on its own</text>
<text x="0" y="48" font-size="13.5" fill="var(--soft-gray,#6E747C)">The sandbox is the box. The mode decides who says yes at the border.</text>
<rect x="0" y="64" width="640" height="226" rx="12" fill="#fff" stroke="var(--soft-gray,#6E747C)" stroke-width="2" stroke-dasharray="6 5"/>
<text x="20" y="90" font-size="14" font-weight="800" fill="var(--med-gray,#5B6169)">Full access</text>
<text x="20" y="110" font-size="12" fill="var(--soft-gray,#6E747C)">Whole computer and internet. Rarely needed.</text>
<rect x="40" y="124" width="360" height="150" rx="12" fill="var(--part-tint,#F2ECFB)" stroke="var(--part,#7A50C7)" stroke-width="2"/>
<text x="60" y="150" font-size="14" font-weight="800" fill="var(--part-ink,#5B37A0)">Ask for approval (start here)</text>
<text x="60" y="170" font-size="12" fill="var(--ink,#1F2328)">Works freely inside the workspace folder.</text>
<rect x="60" y="186" width="150" height="70" rx="8" fill="#fff" stroke="var(--line,#E7E9EC)"/>
<text x="76" y="212" font-size="12.5" font-weight="700" fill="var(--ink,#1F2328)">Your project</text>
<text x="76" y="232" font-size="11.5" fill="var(--med-gray,#5B6169)">files, tests, Git</text>
<rect x="386" y="176" width="28" height="60" rx="6" fill="var(--part,#7A50C7)"/>
<line x1="420" y1="206" x2="464" y2="206" stroke="var(--part,#7A50C7)" stroke-width="2.5" stroke-linecap="round"/>
<path d="M461 200 L470 206 L461 212" fill="none" stroke="var(--part,#7A50C7)" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/>
<text x="430" y="166" font-size="12.5" font-weight="800" fill="var(--part-ink,#5B37A0)">The border</text>
<text x="478" y="202" font-size="12" font-weight="700" fill="var(--ink,#1F2328)">You approve,</text>
<text x="478" y="220" font-size="12" fill="var(--med-gray,#5B6169)">or auto-review on</text>
<text x="478" y="238" font-size="12" fill="var(--med-gray,#5B6169)">Approve for me.</text>
</svg>
</figure>

A detail worth knowing: changing *who reviews* a request doesn't widen the sandbox. Approve for me still keeps Codex in your folder; it only changes who says yes at the border. Your workspace admin may also lock some modes away.

## Give it standing context: AGENTS.md, skills, and plugins

Codex starts every task fresh. Without help, you'd re-explain your project every time. Three things fix that.

**AGENTS.md** is a plain Markdown file in your project that Codex reads before it starts. Put your working agreements in it: which test command to run, which package manager to use, when to ask before adding a dependency, how you name things. Files deeper in the folder tree can add more specific rules for that part of the project. A personal one in your Codex home folder carries your own preferences everywhere. `/init` gets you a first draft.

**Skills** ([lesson 4.2](/learn/chatgpt/working-smart/skills-and-plugins)) work in Codex too: a packaged way of doing one job, like "write release notes from the last ten commits."

**Plugins and apps** ([lesson 4.5](/learn/chatgpt/working-smart/connecting-chatgpt-to-your-tools)) connect Codex to the rest of your tools: GitHub, an issue tracker, your documentation.

## Where it fits: Chat, Work, or Codex

A quick way to choose:

- **Chat** for a question, an explanation, or a short snippet you'll paste yourself. "What does this error mean?"
- **Work** for multi-step jobs that end in a document, spreadsheet, deck, report, or Site. "Turn these survey results into a summary deck."
- **Codex** for jobs that end in **code that runs**, inside a real codebase, with tests, diffs, and Git. "Add CSV export to our reporting page and write a test for it."

They overlap at the edges. Work can build a Site; Codex can write a document. Pick the one whose tools match the job.

## Staying safe and in control

An agent that edits files and runs commands deserves the same care as a new colleague with access to your laptop. The habits:

- **Start on Ask for approval** and loosen only with good reason.
- **Use Git checkpoints** so every task can be undone.
- **Read the diff** before you keep anything. Check the tests ran.
- **Keep secrets out.** No passwords or API keys in prompts or in AGENTS.md.
- **Be careful with outside content.** Web pages, issues, or files from strangers can carry hidden instructions: the **prompt injection** risk from lesson 4.4. Scope tasks and stay within trusted sources.
- **Follow your company's rules** on which repositories may be opened with AI, and on Codex Local versus Codex Cloud, which admins control separately.

## Cost and plans

Codex comes with your ChatGPT plan: signing in with ChatGPT uses your plan's **usage allowance**, the same pool as Work. How much a task uses depends on its size, the length of what goes in and out, the reasoning level, and the speed setting. Bigger models and faster settings use the allowance faster. On **Business**, Premium seats get the most room; Standard seats include a limited amount of the strongest model, with optional credits after that. Developers can also sign in with an **API key**, which is billed at API prices instead.

## Try it

Make a new folder with one small file in it, for example a CSV export or a simple web page. Open the desktop app, switch to **Codex**, and point it at that folder. Leave it on **Ask for approval**.

Ask for something small and checkable: **"Write a short script that reads this CSV and prints the total of the amount column. Explain how to run it."** Watch what it does, read the diff, run the script, and check the total yourself. That first small win is how everyone starts.

*(General exercise. Role and industry versions come once accounts are in.)*

## Key terms

[Codex](/glossary#codex), [AGENTS.md](/glossary#agents-md), [Diff](/glossary#diff), [Sandbox](/glossary#sandbox), [Prompt injection](/glossary#prompt-injection), [ChatGPT Work](/glossary#chatgpt-work)
