Episode 2 of 11

Running Cloud Tasks

Discover how to execute Codex tasks in secure cloud containers — offload builds, tests, and heavy operations without slowing down your local machine.

Why Run Tasks in the Cloud?

Running AI-powered coding tasks locally can be resource-intensive and potentially risky — the agent may need to install dependencies, run builds, or execute arbitrary commands. Cloud execution solves both problems:

  • Performance — Cloud containers have dedicated CPU, memory, and storage
  • Security — Tasks run in isolated Docker containers that are destroyed after completion
  • Consistency — Every task starts from a clean environment, eliminating "works on my machine" issues
  • Parallel work — Your local machine stays free while the cloud handles heavy lifting

Starting a Cloud Task

Add the --cloud flag to any Codex command to push execution to a remote server:

# Run a build task in the cloud
codex run "Build the Next.js app and report errors" --cloud

# Run tests remotely
codex run "Run the full test suite and fix any failures" --cloud

# Perform a migration in a safe environment
codex run "Migrate the database schema to v2" --cloud

Monitoring the Process

Once a cloud task starts, the CLI streams live logs directly to your terminal. You can watch the agent work in real time:

☁️  Cloud task started (container: codex-abc123)
📂  Reading project files...
🔍  Analyzing package.json...
📦  Installing dependencies...
🔨  Running: npm run build
✅  Build completed successfully — 0 errors, 2 warnings
📋  Report saved to ./build-report.md

You'll be notified when the compilation finishes, and any errors are highlighted clearly.

Retrieving Results

Any artifacts, code fixes, or generated files from the cloud agent are automatically synced back to your local workspace. You don't need to manually download anything.

The sync happens via a secure channel, and only files within your project directory are affected. System files and environment configurations remain untouched.

Best Practices

  • Use cloud for builds and tests — These are the most resource-intensive tasks
  • Review synced changes — Always review the code changes before committing
  • Use --dry-run first — Test your prompt locally before sending to the cloud
  • Check cloud status — Use codex cloud status to monitor running tasks

What's Next

In the next episode, we'll learn how to use Codex for automated code review — catching security vulnerabilities, performance issues, and style violations before they reach production.