OpenAI Codex CLI is a lightweight coding agent that runs locally, providing multimodal inputs, rich approvals workflow, and terminal-based AI-assisted development
The execution mode allows running Codex non-interactively with a single prompt, ideal for CI/CD pipelines and scripted workflows.
codex exec [OPTIONS] <PROMPT>
codex e [OPTIONS] <PROMPT><PROMPT> # The prompt text to execute-m, --model <MODEL> # Specify AI model to use
--oss # Use open source models
-p, --profile <PROFILE> # Use specific config profile
-c, --config <KEY=VALUE> # Runtime configuration overrides
-s, --sandbox <MODE> # Set sandbox mode
--full-auto # Enable full automation mode
--dangerously-bypass-approvals-and-sandbox # Bypass safety controls (dangerous)
-C, --cd <DIRECTORY> # Set working directory
--skip-git-repo-check # Allow running outside Git repository
--color <WHEN> # Color settings (always, never, auto)
--json # Print events to stdout as JSONL
--output-last-message <FILE> # File to write last agent message
-i, --image <FILE> # Include image files (comma-separated)
[PROMPT] # Prompt text (or "-" for stdin)Resume a previous session in exec mode.
codex exec resume [OPTIONS] [SESSION_ID]
codex e resume [OPTIONS] [SESSION_ID][SESSION_ID] # Session UUID to resume (optional)
--last # Resume most recent session
[PROMPT] # Additional prompt after resuming# Basic non-interactive execution
codex exec "Fix the TypeScript errors in src/components"
# Use short alias
codex e "Create a README file for this project"
# Execute with full automation
codex exec --full-auto "Run tests and fix any failing tests"
# Execute with specific model and sandbox
codex exec -m gpt-4 -s workspace-write "Refactor the database layer"
# Execute with images and context
codex exec -i "wireframe.png,current-ui.png" "Implement the UI shown in wireframe.png"
# Execute in specific directory
codex exec -C /path/to/project "Add error handling to all API calls"
# Execute with JSON output
codex exec --json "Analyze the codebase structure" > analysis.jsonl
# Execute with colored output
codex exec --color always "Review code quality"
# Execute from stdin
echo "Fix all TypeScript errors" | codex exec -
# Resume exec session
codex exec resume --last "Continue with the implementation"
# Resume specific session with new prompt
codex exec resume 550e8400-e29b-41d4-a716-446655440000 "Add unit tests"# Enable full automation (minimal prompts)
codex exec --full-auto "Deploy the application to staging"Full auto mode:
# Different sandbox levels
codex exec -s none "Review code quality"
codex exec -s network-none "Process local data files"
codex exec -s workspace-read "Analyze project structure"
codex exec -s workspace-write "Fix linting issues"# Use production config profile
codex exec -p production "Deploy to production"
# Override multiple config values
codex exec -c model=gpt-4 -c sandbox_mode=workspace-write -c approval_policy=never "Automated code cleanup"
# Complex execution with all options
codex exec \
-m gpt-4 \
-s workspace-write \
--full-auto \
--json \
-C /path/to/project \
-i "requirements.txt,architecture.md" \
--output-last-message result.txt \
"Implement the features described in architecture.md according to requirements.txt"Execution mode is designed for integration with automated workflows:
# In a CI/CD pipeline
codex exec --full-auto -s workspace-write "Run all tests and fix any failures"
# With exit code handling
if codex exec "Check code quality and suggest improvements"; then
echo "Code quality check passed"
else
echo "Code quality issues found"
exit 1
fi-i for images and -C for working directoryInstall with Tessl CLI
npx tessl i tessl/npm-openai--codex