Codex CLI
codexExecute a prompt via Codex CLI to generate, analyze, refactor, or explain code with full project context. Supports file reading, git operations, and terminal commands.
Instructions
Execute a prompt via Codex CLI. Codex is an AI coding agent that can generate, analyze, refactor, and explain code with full project context (reads AGENTS.md/CODEX.md automatically).
Capabilities: code generation and refactoring, code analysis and explanation, file reading and modification (when sandbox allows), git operations and terminal commands, multi-turn conversations via sessionId.
When to use a different tool:
For analysis of text you already have (plans, docs, opinions), inline it directly in the prompt rather than passing file paths. The files parameter triggers full file I/O and increases timeout pressure.
Tips:
Set workingDirectory to the target repo for project-aware responses.
Use sandbox "read-only" (default) for analysis, "full-auto" for code changes.
Break complex tasks into focused prompts rather than one large request.
Resume multi-turn conversations with sessionId (returned in previous response metadata).
Include relevant files via the files parameter for targeted context (text and images supported).
Set reasoningEffort to control depth: "none" for trivial, "minimal" for lightweight, "low"/"medium" for routine, "high"/"xhigh" for deep analysis.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| files | No | File paths relative to workingDirectory. Supports line ranges: 'path:start-end' (e.g. 'src/lib.rs:900-950'). Text and images supported (images ignore line ranges). | |
| model | No | Model to use (e.g. o3, gpt-4.1) | |
| prompt | Yes | The prompt to send to Codex | |
| sandbox | No | Sandbox level: read-only (default), workspace-write, or full-auto (Codex CLI convenience mode for workspace-write with auto-approve) | read-only |
| timeout | No | Timeout in milliseconds (default: 60s no files, 180s+30s/file with files, max: 600000) | |
| sessionId | No | Session ID to resume a previous conversation | |
| resetSession | No | Clear this session's conversation history and start fresh (requires sessionId) | |
| reasoningEffort | No | Reasoning effort level (maps to -c model_reasoning_effort) | |
| workingDirectory | No | Working directory for the CLI | |
| maxResponseLength | No | Soft limit on response length in words |