To leave the Codex CLI running and walk away safely, do four things before you go: keep the computer from sleeping, set the sandbox and approvals so Codex can do routine work without stopping at every prompt, give it a clear task with a definition of done, and set up a way to hear from it when it finishes or needs a decision. With a phone paired to a tool like Notifier for Codex, you can then approve, answer or send the next instruction from wherever you are, on Mac, Windows and Linux.
011. Keep the computer awake
Codex runs on your machine, so a sleeping laptop stops it. Options:
- Codex itself: turn on Prevent sleep while running in
/experimental, or setprevent_idle_sleep = trueunder[features]in~/.codex/config.toml. It keeps the machine awake while a turn is actively running. It's experimental and off by default. - macOS: start Codex under
caffeinate, for examplecaffeinate -i codex. Keep a laptop on power. - Windows: set Sleep to Never while plugged in, under Settings > System > Power.
- Linux:
systemd-inhibit codexholds off sleep for as long as Codex runs.
On a server, none of this matters; run Codex inside tmux so it survives a dropped connection (see the tmux guide).
022. Set the sandbox so routine work doesn't stop
Most interruptions are approvals. The default Auto preset (workspace-write sandbox, on-request approvals) already lets Codex read, edit and run commands inside the project without asking. It asks when it needs to leave the sandbox: network access, files outside the workspace, some tool calls.
Think about what the task will need:
- Installing packages or calling APIs? Allow network access inside the sandbox for this run:
codex -c 'sandbox_workspace_write.network_access=true'. That removes the most common prompt without dropping the sandbox. - Many approvals of a routine kind?
approvals_reviewer = "auto_review"routes eligible requests to a reviewer agent instead of you. It uses extra model calls, and it denies what it judges risky. - Avoid
--yolo(--dangerously-bypass-approvals-and-sandbox) on your own machine. It removes the sandbox and every prompt, and OpenAI intends it only for environments that are already isolated.
The approval modes guide explains each setting. The goal is not zero approvals: the ones that remain are the decisions worth sending to your phone.
033. Give a task with a definition of done
Unclear tasks end early with a question, or run long in the wrong direction. Before you leave:
- Say what "finished" means: "all tests in
billing/pass andpnpm lintis clean". - Name the boundaries: "don't touch the migrations folder".
- For a big change, start in plan mode (
/plan), agree the plan, then let Codex work through it. - Commit first, so you can review and roll back with
git. - For a longer target,
/goalattaches an objective to the chat that Codex keeps track of while it works.
044. Set up a way to hear from it
You need to know two things while you're away: Codex has finished, and Codex is waiting on you.
Free, one-way: a Stop hook and a PermissionRequest hook that post to ntfy or a chat app. You'll know when to come back.
Two-way, with Notifier for Codex: pair your phone (see connecting your phone) and you get pushes for "finished", approvals and questions, and you can answer them. When you're away from the keyboard:
- approval requests wait for your answer, up to 10 minutes by default (
codex-notifier config set hold_ceiling_seconds 1800for 30); - Codex's questions do the same;
- after each turn you have two minutes (
stop_hold_seconds) to send the next instruction from the phone, and Codex picks it up straight away.
If you don't answer in time, nothing is approved for you: Codex shows the normal prompt in the terminal and waits there. When you come back and touch the keyboard, any wait ends at once.
On iPhone, a lock screen card can show the files being edited and the plan step Codex is on.
05A routine that works
- Commit, start
codexinsidetmux(or undercaffeinateon a Mac). - Plan with
/plan, agree it, then tell Codex to carry out the plan and what done means. - Allow network access for this run if it will install or download anything.
- Check the phone is paired:
codex-notifier test. - Walk away. Approve, answer or redirect from the phone.
- When you get "Codex has finished", read the summary, and either send the next step from the phone or review the diff when you're back.
06Scripted runs with codex exec
For work that needs no conversation, codex exec runs Codex non-interactively and exits. It uses a read-only sandbox by default; add --sandbox workspace-write to let it edit. Hooks run for codex exec too, so a Stop hook tells you when it's done, and --json streams events if you want to watch progress from a script. --full-auto is no longer supported; use --sandbox workspace-write instead.
07FAQ
What happens if Codex asks for approval and I'm asleep?
With Notifier for Codex, the request waits up to your hold limit, then the hook steps aside and the normal prompt appears in the terminal. Codex waits there until you answer. Set quiet hours if you don't want night-time pushes at all.
Can I just use --yolo for long tasks?
On a throwaway VM or container, maybe. On your own computer, no: it gives Codex unrestricted access with no prompts at all. Allowing network access inside the sandbox removes most prompts without that risk.
Will my laptop lid closing stop Codex?
Usually, yes, because the laptop sleeps. Keep it open and on power, or run Codex on a desktop or server.
Does the phone get a push for every turn?
Yes, one "finished" push per turn while you're away. If you're at the keyboard in that terminal, the phone gets nothing.