All tutorials / Codex/8 min/Advanced

Codex tutorial

How to use Codex YOLO mode safely

Use Codex with skipped approvals in a controlled workspace, keep sandbox rails, and review every diff before keeping changes.

4 stepsYOLO modeSandboxed
Interactive tutorial

Quick command sequence

$ mkdir -p /tmp/codex-yolo-lab && cd /tmp/codex-yolo-lab && git init && codex exec --approval-mode never --sandbox workspace-write "Implement the requested change and run tests"

/en/tutorials/how-to-use-codex-yolo-mode-safely

Interactive command lab

1/4

Step 1

Create a disposable workspace

YOLO-style runs are useful for speed, but they should start in a disposable or clean Git-controlled workspace.

Checkpoint

If it is not committed or disposable, it is not YOLO-safe.

zsh — tutorial-lab

Command tray

$ mkdir -p /tmp/codex-yolo-lab && cd /tmp/codex-yolo-lab && git init

Initialized empty Git repository

Step-by-step instructions

  1. 1

    Step

    Create a disposable workspace

    YOLO-style runs are useful for speed, but they should start in a disposable or clean Git-controlled workspace.

    mkdir -p /tmp/codex-yolo-lab && cd /tmp/codex-yolo-lab && git init
  2. 2

    Step

    Start with a narrow task

    Even in permissive mode, a narrow task reduces surprise edits and makes review faster.

    codex exec --skip-git-repo-check "Create a tiny hello.ts script and run it"
  3. 3

    Step

    Use approval skipping only when you accept the risk

    Approval skipping trades safety for speed. Keep sandboxing enabled where possible and limit the working directory.

    codex exec --approval-mode never --sandbox workspace-write "Implement the requested change and run tests"
  4. 4

    Step

    Review every diff before keeping it

    Treat the diff as the source of truth. Revert anything surprising before copying changes into a real project.

    git diff --stat && git diff --check && git status --short

Why this matters

Approval skipping is powerful for fast experiments, but it removes the human checkpoint. A disposable workspace, narrow prompt, sandbox, and diff gate make it practical instead of reckless.

Troubleshooting

  • If Codex edits too many files, stop and reduce the prompt scope.
  • If tests fail, inspect the diff before running another agent pass.
  • If you need unrestricted access, use a throwaway VM or copy, not your main machine.

Related tutorials