Build Mobile Apps using Codex/Codex and mobile foundations
Lesson 3 / 7 · 24 min · 0 / 7 exercises
Course contents
Concept · 7 hands-on exercises

Codex surfaces and AGENTS.md for a mobile repo

Choose between local, worktree, cloud and your phone for each task, and write the AGENTS.md that tells Codex how your Expo repo builds, tests and ships.

The same Codex agent runs in six places as of November 2026: the Codex CLI, the Codex IDE extension, Codex Cloud, and the ChatGPT desktop, web and mobile apps. What changes between them is where your code actually runs and what the agent can reach. For a mobile app that question matters more than usual, because your simulators, your signing keys and your physical test phone all live on your own machine.

Where each surface runs your code

SurfaceWhere the work happensGood for in a mobile project
Codex CLIYour machine, in a terminalSimulators, npx expo run:ios, package installs, scripts and codex exec
Codex IDE extensionYour machine, inside your editorWorking next to the code and reviewing diffs in place
ChatGPT desktop appYour machine, as Local or in a WorktreeSeveral chats in parallel, each in its own Git worktree
Codex CloudAn isolated cloud environment per taskLong tasks that don't need your simulator; keeps going while your laptop sleeps
ChatGPT mobile appControls Cloud or a connected Mac or PCApproving commands, reviewing diffs and starting tasks away from your desk
ChatGPT on the webCloudStarting and reviewing cloud tasks from any browser

Here's the mobile-specific catch. A cloud task can write code, install dependencies and run the type checker and unit tests in its own environment, but it can't tap through your app on the iOS Simulator sitting on your Mac. So route by what the task needs to see. Anything you judge by looking at a screen belongs on your machine. Refactors, tests, migrations and docs can run in a worktree or in the cloud.

Sort itExercise 1 of 7

Route each Tipjar task to the surface that fits it best.

Card 1 of 5

Write unit tests for the tip calculator while you keep working on the paywall

Worktrees: parallel chats without collisions

A Git worktree is a second checkout of your repository that shares the same .git history. In the ChatGPT desktop app you pick Worktree under the composer and choose a starting branch; Codex creates the worktree and works there, in a detached HEAD state by default. When you're ready you either click Create branch here and keep going in the worktree, or use Handoff to move the chat and its code into your Local checkout. In the CLI, codex --worktree starts a session in a new managed worktree and /worktree moves the current conversation into one.

Mobile adds two wrinkles. Each worktree needs its own node_modules, so the first install takes time. And only one copy of your app, with one bundle identifier, runs on a simulator at a time. OpenAI's docs list “you can run only one instance of your app” as a reason to hand a chat back to Local before testing. If two worktrees each need a dev server, start the second one on another port, for example npx expo start --port 8082.

Explore: Parallel agents, one reviewerExercise 2 of 7
agent workingyou reviewing
160 minone at a time
70 minin parallel
2.3×speed-up
57%of the time is you reviewing

However many agents you add, the speed-up can't pass 4.0×, because your reviews happen one at a time.

Each agent works alone, but you review their diffs one at a time.

Move the controls and watch what changes.

Quick checkExercise 3 of 7

In the explorer, keep 30 minutes per agent task and 10 minutes of review each, then raise the agent count. What happens?

Cloud tasks from your terminal

Codex Cloud runs each task in its own workspace inside an environment you've prepared once: repositories, dependencies, network access and secrets. You can start and inspect cloud tasks without leaving the CLI. codex cloud opens a picker, codex cloud exec --env <ENV_ID> "…" submits a task directly (add --attempts 3 for best-of-N), codex cloud list shows recent tasks, codex cloud diff <TASK_ID> prints the result, and codex cloud apply <TASK_ID> applies it to your local checkout so you can run it on the simulator.

Your phone as the remote control

The ChatGPT iOS app can drive Codex on Cloud or on a connected Mac or PC. You set it up from the desktop app (Settings › Connections › Control this Mac or PC), scan a QR code with your phone, and keep the computer awake and online. From the phone you can start tasks, follow progress, approve requested commands and review changed files. The repository and any worktrees stay on the computer; nothing runs on the phone itself.

Quick checkExercise 4 of 7

You're away from your desk. Codex, running on your Mac, asks to run npx expo install expo-haptics. What can you do from the ChatGPT iOS app?

AGENTS.md: the briefing every surface reads

AGENTS.md is a plain Markdown file of instructions for coding agents, stewarded by the Agentic AI Foundation and read by Codex, Cursor, Gemini CLI, GitHub Copilot's coding agent and many others. Claude Code reads it too when a project has no CLAUDE.md. Codex reads AGENTS.md before doing any work, in every surface, so it's the cheapest place to put the rules a new teammate would need on day one.

  1. Global: ~/.codex/AGENTS.override.md if it exists, otherwise ~/.codex/AGENTS.md.
  2. Project: from the repository root down to your current directory, at most one file per folder: AGENTS.override.md first, then AGENTS.md, then any fallback names you configure.
  3. Merge: files are joined from the root down, so instructions closer to where you're working come later and win when they conflict.
  4. Limit: Codex stops adding files once the combined size reaches project_doc_max_bytes, 32 KiB by default. It rebuilds the chain at the start of each session.

Run /init in a new repo and Codex drafts a scaffold for you to edit. Then cut it down. Everything in AGENTS.md is read on every turn of every session, so a bloated file costs tokens, crowds out the files Codex actually needs, and can be truncated at the cap. Put commands, conventions and hard rules in it. Put long procedures in skills, which Codex loads only when a task needs them.

Build itExercise 5 of 7

Assemble an AGENTS.md for the Tipjar Expo repo. Switch on what helps Codex; leave out what hurts.

What gets sent
# AGENTS.md
Expo SDK 58 app, TypeScript strict, routes in src/app.
Spot the problemsExercise 6 of 7

A teammate's AGENTS.md for Tipjar. Click the lines that will lead Codex astray.

AGENTS.md0 of 3 found
Quick checkExercise 7 of 7

Tipjar's root AGENTS.md says “Run npm test.” The folder apps/mobile has an AGENTS.override.md that says “Run npx jest --selectProjects mobile.” You start Codex in apps/mobile. Which test command does it follow?

AGENTS.md (a good starting point for Tipjar)
# Tipjar
Expo SDK 58 app. TypeScript strict. Routes in src/app, shared code in src/lib.

## Commands
- Dev server: npx expo start
- Before saying "done": npx tsc --noEmit && npm test
- Native rebuild after native changes: npx expo run:ios

## Rules
- Add packages with npx expo install <pkg>.
- Never hand-edit ios/ or android/; use app.json and config plugins.
- Only EXPO_PUBLIC_ variables in app code. No secret keys in the app.
- Tell me what to check on the simulator when a change is visual.
Check your understanding
Q1. What does Handoff do in the ChatGPT desktop app?
Q2. Your AGENTS.md files add up to more than 32 KiB. What happens by default?
Q3. Which task is the weakest fit for Codex Cloud?
· Work through the 7 remaining exercises above (stuck? each one can show you the answer).
· Score 100% on the quiz.
Vocabulary in this lesson

Plain-English definitions from the AI Coding Dictionary.