Short answer
Codex typically delivers work as pull requests from a sandboxed cloud environment, so the path to production runs through your Git workflow: branch protection, CI checks, preview deployments per pull request and a deliberate promotion to production. Make AGENTS.md, the Codex environment and CI describe the same commands, and the rest is standard deployment practice.
On this page
- How Codex changes the shape of deployment
- Align the three environments Codex touches
- Protect the main branch
- Preview deployments per pull request
- Choose production hosting
- Secrets and the agent sandbox
- Post-merge checks that catch what review missed
- Operating it long term
- Launch checklist
- FAQ
- Tools from the jocapps ecosystem
How Codex changes the shape of deployment
OpenAI Codex works in two main ways: as a cloud agent that runs tasks in an isolated container and proposes changes as pull requests, and as a local CLI or IDE agent working in your checkout. Teams that build a whole app this way end up with a characteristic pattern: many small, parallel pull requests, each produced in a sandbox that may or may not resemble production.
That makes the pull request the natural control point. Instead of asking "how do I deploy what Codex built", ask "what has to be true before a Codex pull request is allowed to merge, and what happens automatically after".
Align the three environments Codex touches
There are usually three places where your app runs:
| Environment | Who configures it | Typical drift |
|---|---|---|
| Codex task container | Environment settings and setup script in Codex | Different runtime version, no real services, mocked secrets |
| CI runner | Your GitHub Actions or other CI config | Different install command or test flags |
| Production | Your hosting provider | Different env vars, real database, real traffic |
Drift between these is the main source of "it passed in Codex but broke in production". Fix it by pinning runtime versions in one place (.nvmrc, .tool-versions, a Dockerfile), using the same install, test and build commands everywhere, and documenting them in AGENTS.md so Codex runs exactly what CI runs.
A useful AGENTS.md section looks like this:
## Commands
- Install: pnpm install --frozen-lockfile
- Test: pnpm test
- Typecheck: pnpm typecheck
- Build: pnpm build
## Rules
- Every PR must pass all four commands locally before you finish.
- Do not change deployment config in /deploy or .github without an explicit task.
- Database changes require a new migration in /db/migrations.
Protect the main branch
Because Codex can open several pull requests an hour, branch protection is what keeps quality steady:
- Require the CI workflow to pass before merging.
- Require at least one human approval, and make code owners review sensitive paths such as authentication, payments and infrastructure.
- Disallow direct pushes to main, including from automation tokens.
- Require branches to be up to date before merge, so parallel Codex PRs are tested against each other's changes.
The last rule matters more with agents than with humans. Two pull requests that each pass alone can conflict logically once both are merged.
Preview deployments per pull request
The most effective habit for Codex-built apps is a preview deployment for every pull request. Platforms such as Vercel, Netlify, Render and others can build each branch at its own URL. Reviewers click through the actual change instead of reading a large diff, and you can run smoke tests or end-to-end tests against the preview.
Give previews their own database (a branch database or a seeded throwaway instance) and their own low-privilege API keys. Never point previews at production data.
Choose production hosting
Codex writes conventional code, so hosting follows the stack. A TypeScript front end with serverless functions fits edge and serverless platforms. A Python or Node API with a relational database fits a container platform or your own cloud account. If you serve European public-sector or regulated clients, a European region or your own tenancy will usually be a requirement rather than a preference.
Whichever you choose, make production deploys a separate, visible step: merge to main deploys to staging, a tag or manual approval promotes to production.
Secrets and the agent sandbox
Codex cloud tasks run in containers with configurable network access and environment variables. Treat those like any third-party CI system:
- Provide only what tasks need to build and test; never production database URLs or payment keys.
- Keep internet access for tasks restricted to what is necessary, such as package registries.
- Store production secrets only in the hosting platform's secret manager.
- Run a secret scanner on every pull request, since generated test fixtures sometimes contain realistic-looking keys.
Post-merge checks that catch what review missed
Large volumes of small agent changes make it easy for a regression to slip through. Add a few checks that run after each production deploy:
- A smoke test hitting the five most important user flows.
- Error-rate alerting that compares the last 15 minutes with the previous hour.
- A changelog generated from merged pull request titles, so you can map an incident to a specific Codex task quickly.
When an incident happens, the fix can itself be a Codex task: give it the error, the log excerpt and the suspect pull request, and review its proposal as you would any other.
Operating it long term
The pattern above works well for teams with engineering capacity to own CI, hosting and reviews. Where that capacity is missing, OnlineAppCreator takes over: our AI Code Engineers set up the environments, branch protection, previews and monitoring for Codex-built applications and run them under an SLA, while your team continues to delegate feature work to Codex. We use the same agents daily, so the workflow stays agent-first rather than reverting to manual development.
If your Codex project includes iOS or Android apps, appsubmitter.io handles store listings, submission and rejection responses in your developer accounts. Related reading: publishing a Codex app to the App Store, CI/CD for AI-built mobile apps and our comparison of Claude Code vs OpenAI Codex.
Launch checklist
- Runtime versions pinned and identical across Codex, CI and production
AGENTS.mdlists the exact install, test, typecheck and build commands- Branch protection with required checks and code owner reviews
- Preview deployments with isolated data for every pull request
- Production secrets only in the hosting secret store
- Smoke tests and error-rate alerts after each deploy
- Documented rollback, owned by a named person or by OnlineAppCreator
FAQ
Can Codex deploy my app directly?
Codex focuses on producing code changes, typically as pull requests. Deployment should run through your CI/CD pipeline after review, not from the agent's sandbox.
What is AGENTS.md used for in deployment?
It tells Codex how to install, test and build the project and which rules to follow. Keeping it identical to your CI commands is the simplest way to avoid environment drift.
How do I handle many parallel Codex pull requests?
Require branches to be up to date before merging, run CI on each, and use preview deployments so reviewers can test changes quickly. Merge in small batches and watch error rates after each deploy.
Should Codex tasks have access to production data?
No. Give tasks only test data and low-privilege keys. Production data and credentials belong exclusively to the production environment.