Applied AI for Public Policy Β· Week 2

Get Codex running on your laptop

By the end of this page you will have an AI coding agent installed, signed in, and waiting for its first task. Follow it at your own pace; every command is one you can copy.

Time  ~15 minutes Cost  free for students Works on  Mac & Windows

00 β€” Orientation

What you are installing, in one minute

Codex is a coding agent. Underneath it is the same kind of model as a chatbot, but with a machine built around it so it can act, not just answer.

A chat window can only hand you text. An agent can open your files, run your code, read what happened, and fix it, pausing for your approval along the way. That is the whole difference, and it is why the setup below is worth fifteen minutes.

The mental model

Think of a fast, very literal research assistant sitting at your computer. It types the commands; you make the decisions and check the result. Nothing happens on your machine without your yes.

01 β€” The one distinction that matters

What can it touch?

Every way of using AI differs mainly in what it is allowed to reach. Where the work runs is also where your data goes, so this is a privacy question as much as a convenience one.

How you use itYour filesRun your codeWhere it runs
Chat windowchatgpt.com β€” noneβ€” you run ityour browser
Codex, on your laptopterminal or app βœ“ reads & editsβœ“ runs & checksyour machine
Codex Cloudchatgpt.com/codex a copy on GitHubβœ“ on serversOpenAI's servers

This guide sets up the middle row β€” Codex on your own laptop, in the terminal or in the app β€” and describes the other two rows.

02 β€” Access

Getting Codex for free

You need a (free) OpenAI account and a way to pay for usage. As a student, you have one without spending anything.

Option A β€” the student credits (recommended)

Verified university students in the US and Canada can claim $100 in free Codex credits, and they work even on a free ChatGPT account. That is enough to run everything this course asks of you.

Do this first

Sign in at chatgpt.com with your school email, then claim the student credits from OpenAI's Codex-for-students page. Verification can take a little time, so start it before class.

Option B β€” a plan you already pay for

If you already pay for ChatGPT Plus ($20/month, which includes Codex), just sign in with that. A paid plan gives you higher ongoing limits than the one-time credit bucket, so you will not have to think about running out.

You do not need both. Pick the free credits or your existing plan and move on.

03 β€” Install

Codex in the terminal

Codex comes in two forms, the terminal program and the app, and either one works for this course. This section installs the terminal program; the next section installs the app. The terminal is a plain text window where you type one line, press Enter, and the computer does it. It is already on your machine. You only need it to start Codex; after that you talk in plain English.

  1. Open the Terminal app

    Press ⌘ Command + Space, type Terminal, and press Enter. A small text window opens. That is it.

    Screenshot
    Capture: Spotlight search showing "Terminal", or the empty Terminal window once open.Take this on a real Mac during setup.
  2. Install Codex with one line

    Copy the line below, paste it into Terminal, and press Enter. It downloads Codex as a single small program. Nothing else is required.

    $ curl -fsSL https://chatgpt.com/codex/install.sh | sh
    Terminal β€” zsh
    $ curl -fsSL https://chatgpt.com/codex/install.sh | sh
    Downloading codex… installed to /usr/local/bin/codex
    # when it finishes, you get your prompt back

    Approximate output β€” the exact wording may differ.

  3. Start Codex and sign in

    Type codex and press Enter. The first time, choose Sign in with ChatGPT; your browser opens, you approve, and you are back.

    $ codex
    Screenshot
    Capture: the "Sign in with ChatGPT" prompt on first launch, and the browser "authorize" screen.Two images; take on a real machine.
If you have seen "npm install" online

Many guides say to run npm install -g @openai/codex. That works too, but it first needs another program called Node.js. You do not need that path β€” the one-line installer above gets you the exact same Codex.

04 β€” The app

Codex in an app

The same Codex comes in two app forms. You click instead of type, and the tasks in this course work the same way in either. Pick the form you prefer.

In your editor (VS Code)

This keeps your files in a sidebar and Codex in a panel beside them; changes are highlighted in the code and you approve them with a click.

  1. Install VS Code

    Download it from code.visualstudio.com. It is the same on Mac and Windows.

  2. Add the Codex extension

    Open the Extensions panel on the left, search for Codex, and install the one published by OpenAI (id openai.chatgpt). A Codex icon appears in the sidebar.

    Screenshot
    Capture: the Extensions search showing the OpenAI Codex extension, and the Codex icon in the sidebar.
  3. Sign in

    Click Continue with ChatGPT, using the same account as before. You are ready.

In the browser (Codex Cloud)

Nothing to install. You hand Codex a task and it works on OpenAI's servers, then gives you back a pull request. Best when your project already lives on GitHub, or when you want to delegate and check back later.

  1. Open Codex Cloud

    Go to chatgpt.com/codex and sign in with your ChatGPT account.

  2. Connect GitHub and send a task

    Connect your GitHub account, pick the project Codex may see, describe the task in plain English, and send it. Review the result and open a pull request when you are happy.

    Screenshot
    Capture: the "connect GitHub" step and a finished task showing its diff.
Policy note

Codex Cloud runs your code on OpenAI's servers, not your laptop. For sensitive or restricted data, keep the work local (the terminal or editor version) instead.

05 β€” Staying in control

The three permission modes

Codex runs in one of three permission modes. You set it when you start, or change it mid-session with the /permissions command (OpenAI's permission modes page). In the ChatGPT desktop app and the IDE extension, use the permissions control below the composer. The question behind all three: how much would you let a brand-new assistant do unsupervised?

Ask for approval Β· default

asks before it acts

Reads your files and answers questions. It asks you before every edit and every command.

Best for exploring unfamiliar code, or reading the plan first. Start here.

Approve for me

acts inside your folder

Edits and runs inside your project without asking each time, but stops before touching the network or anything outside it.

Best for everyday work on your own project once you trust it.

Full access

no guardrails

Edits, runs, and reaches the network with no approval prompts. Powerful and easy to regret.

Best for rare, trusted tasks β€” and only when you know why you need it.

The default is Ask for approval. Move to Approve for me once you trust the agent on your own project.

06 β€” Try it

Your first task

Do not save it for a real project. Point it at a small folder you do not mind experimenting on, and ask for something concrete. In the app, open the same folder and give the same request.

codex β€” your-project
$ cd my-first-project
$ codex
β€Ί explain what the files in this folder do
Codex reads the folder, then answers β€” and waits for your
approval before it changes or runs anything.

Good first asks

"Explain what this script does." Β· "Add comments to this file." Β· "What columns are in this data?"

The habit to build

Read the change it proposes and approve it only once you understand it. An unverified result is not a result.

07 β€” When something breaks

Something will break. That is fine.

Errors during setup are normal and are never a sign you are behind. The reflex to build:

  1. Read the last line

    The final line of an error usually says what went wrong. Start there.

  2. Paste it to Codex

    Copy the full error message, paste it in, and read the explanation before you try the fix.

  3. Ask for help early

    Stuck past 15 minutes? Post to the course board or raise your hand in the build block. Do not debug alone for ten minutes.

No-install fallback

If the install truly will not cooperate today, use the browser-based Codex Cloud so you are not blocked. We will sort the local install in office hours.