> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/openai/codex/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Overview

> Complete reference for all Codex CLI commands

Codex CLI provides a powerful command-line interface for interacting with the Codex coding agent. You can run Codex interactively, execute tasks non-interactively, manage authentication, configure MCP servers, and more.

## Interactive vs Non-Interactive

**Interactive Mode** (default):

```bash theme={null}
codex
codex "create a todo app"
```

**Non-Interactive Mode** (exec command):

```bash theme={null}
codex exec "explain this codebase"
codex exec --json "run tests"
```

## Core Commands

<CardGroup cols={3}>
  <Card title="codex" icon="terminal" href="/cli/codex">
    Run Codex interactively or with a prompt
  </Card>

  <Card title="exec" icon="play" href="/cli/exec">
    Run Codex non-interactively for automation
  </Card>

  <Card title="review" icon="code-review" href="/cli/review">
    Run code reviews on commits or branches
  </Card>
</CardGroup>

## Session Management

<CardGroup cols={3}>
  <Card title="apply" icon="file-code" href="/cli/apply">
    Apply latest diff from Codex to working tree
  </Card>

  <Card title="resume" icon="rotate-right" href="/cli/resume">
    Resume a previous interactive session
  </Card>

  <Card title="fork" icon="code-fork" href="/cli/fork">
    Fork a previous interactive session
  </Card>
</CardGroup>

## Authentication

<CardGroup cols={2}>
  <Card title="login" icon="sign-in" href="/cli/login">
    Authenticate with ChatGPT or API key
  </Card>

  <Card title="logout" icon="sign-out" href="/cli/logout">
    Remove stored credentials
  </Card>
</CardGroup>

## Integration & Tooling

<CardGroup cols={3}>
  <Card title="mcp" icon="server" href="/cli/mcp">
    Manage external MCP servers
  </Card>

  <Card title="mcp-server" icon="network-wired" href="/cli/mcp-server">
    Run Codex as an MCP server (stdio)
  </Card>

  <Card title="app-server" icon="network" href="/cli/app-server">
    Start Codex as an app server for IDEs
  </Card>
</CardGroup>

## Utilities

<CardGroup cols={3}>
  <Card title="completion" icon="terminal" href="/cli/completion">
    Generate shell completion scripts
  </Card>

  <Card title="sandbox" icon="shield" href="/cli/sandbox">
    Run commands within Codex sandbox
  </Card>

  <Card title="features" icon="flag" href="/cli/features">
    Inspect and manage feature flags
  </Card>

  <Card title="feedback" icon="message" href="/cli/feedback">
    Submit feedback about Codex
  </Card>

  <Card title="debug" icon="bug" href="/cli/debug">
    Debugging tools for app server
  </Card>
</CardGroup>

## Global Flags

These flags work with most commands:

* `-c, --config <KEY=VALUE>` - Override config.toml settings
* `-p, --profile <NAME>` - Use a specific config profile
* `-m, --model <MODEL>` - Specify the AI model to use
* `--oss` - Use open-source/local model providers
* `--enable <FEATURE>` - Enable a feature flag
* `--disable <FEATURE>` - Disable a feature flag

## Common Usage Patterns

### Quick One-Off Tasks

```bash theme={null}
codex exec "add error handling to utils.ts"
codex exec --json "list all API endpoints" > endpoints.json
```

### Code Reviews

```bash theme={null}
codex review --uncommitted
codex review --base main
codex review --commit abc123
```

### Using Different Models

```bash theme={null}
codex -m gpt-4.1 "complex refactoring task"
codex --oss --local-provider ollama "local task"
```

### Configuration Overrides

```bash theme={null}
codex -c sandbox_mode=workspace_write "build a CLI tool"
codex -p production exec "deploy to staging"
```

## Exit Codes

Codex CLI uses standard exit codes:

* `0` - Success
* `1` - Error occurred during execution

## Next Steps

Explore individual command documentation for detailed usage, flags, and examples.
