Skip to main content
The apply command takes the most recent diff generated by the Codex agent and applies it to your local working tree using git apply.

Usage

codex apply
codex a  # Short alias

Description

When Codex generates code changes during an interactive session, it produces a diff that can be applied to your files. The apply command:
  1. Finds the latest diff from your most recent Codex session
  2. Applies it to your local working tree using git apply
  3. Reports any conflicts or issues
This is useful when you want to:
  • Apply changes after reviewing them in the TUI
  • Quickly accept Codex’s proposed changes
  • Integrate Codex changes into your current work

Examples

Basic Usage

Apply the latest diff from your most recent session:
codex apply
Using the short alias:
codex a

Exit Codes

  • 0 - Diff applied successfully
  • 1 - Error applying diff (conflicts, file not found, etc.)

codex

Run interactive Codex session

codex exec

Run non-interactive execution