Cloud, worktrees, and automation
Scale Codex with isolated worktrees, cloud tasks, scheduled automations, GitHub workflows, and the SDK.
Codex supports parallel and recurring work across three execution locations:
| Location | Characteristics |
|---|---|
| Local checkout | Directly changes the files you are using. |
| Worktree | Isolated Git checkout for parallel local work. |
| Cloud | OpenAI-managed container connected to a GitHub repository. |
Worktrees in the app
The desktop app can create a Worktree thread so an experiment does not collide
with unfinished local changes. Codex keeps managed worktrees under
$CODEX_HOME/worktrees and supports handoff between Local and Worktree
threads.
Use worktrees for parallel feature attempts, risky upgrades, and automations that may create patches. Review and integrate the resulting branch as normal Git work; see Worktrees.
Cloud tasks
Cloud tasks run in isolated containers and can work in the background, create pull requests, and hand changes back to local tools.
codex cloud exec --env <environment-id> --attempts 3 \
"Implement the agreed pagination plan and run the test suite."
codex apply <task-id>The cloud service is current, but the codex cloud CLI surface can be marked
Experimental. Verify the live
feature maturity
before scripting it into CI.
Cloud environments separate dependency setup from the agent phase. Network is off during agent work by default, and setup secrets are removed before that phase begins. See Cloud and environments.
Scheduled automations
The desktop app can run recurring tasks against a local checkout or an isolated worktree. Automations can invoke skills and plugins:
$pr-babysitter check the pull request, summarize new CI or review feedback, and
fix only issues with a clear reproduction.Project automations are local automation, not cloud cron: the computer must be awake, the app must be running, and the project must remain available. Use a worktree when the automation may modify code. See Automations.
GitHub and CI
@codex reviewrequests a Codex review on a connected pull request.- Another
@codexPR comment can start a cloud task. openai/codex-action@v1runs Codex in GitHub Actions.
Review repository access, action permissions, sandbox settings, and the exact credentials available to CI before enabling write actions. See GitHub and the GitHub Action.
SDK
Use the Codex SDK when a coding-focused Codex thread belongs inside your own automation:
npm install @openai/codex-sdk
pip install openai-codexThe TypeScript SDK is current; the Python SDK is Beta. Both should use the
narrowest suitable sandbox (read_only or workspace_write). Enforce limits
externally with cancellation, timeouts, and host-side usage tracking; the SDKs
do not currently document built-in turn or budget limits. See
Codex SDK.