Codex CLI¶
OpenAI's code-focused CLI tool optimized for code generation and programming tasks.
Overview¶
Codex CLI is OpenAI's command-line tool focused on code generation and programming assistance. It excels at:
- Rapid code generation
- Writing tests and boilerplate
- Code transformations
- Quick programming tasks
Installation¶
Install Codex CLI from OpenAI:
Basic Usage¶
# Use Codex with clinvk
clinvk --backend codex "implement a REST API handler"
clinvk -b codex "generate unit tests for user.go"
Models¶
| Model | Description |
|---|---|
o3 |
Latest and most capable model |
o3-mini |
Faster, lighter model |
Specify a model:
Configuration¶
Configure Codex in ~/.clinvk/config.yaml:
backends:
codex:
# Default model
model: o3
# Enable/disable this backend
enabled: true
# Extra CLI flags
extra_flags: []
Environment Variable¶
Session Management¶
Codex resumes sessions via the codex exec resume subcommand (handled automatically by clinvk):
Unified Options¶
These options work with Codex:
| Option | Description |
|---|---|
model |
Model to use |
max_tokens |
Maximum response tokens |
max_turns |
Maximum agentic turns |
Extra Flags¶
Pass additional flags to Codex:
Common flags:
| Flag | Description |
|---|---|
--quiet |
Reduce output verbosity |
Best Practices¶
Use for Code Generation
Codex is optimized for generating code quickly. It's great for boilerplate and repetitive tasks.
Combine with Other Backends
Use Codex to generate code, then Claude to review it - leverage the chain command.
Batch Similar Tasks
Run multiple code generation tasks in parallel for efficiency.
Use Cases¶
Generate Boilerplate¶
Write Tests¶
Code Transformation¶
Quick Implementations¶
Comparison with Claude¶
| Aspect | Codex | Claude |
|---|---|---|
| Speed | Faster | More thorough |
| Best for | Code generation | Complex reasoning |
| Context | Good | Excellent |
| Safety focus | Standard | High |
Workflow Example¶
Use Codex and Claude together:
{
"steps": [
{
"name": "generate",
"backend": "codex",
"prompt": "implement user authentication"
},
{
"name": "review",
"backend": "claude",
"prompt": "review this code for security: {{previous}}"
}
]
}
Troubleshooting¶
Backend Not Available¶
Model Errors¶
If a model isn't available:
# List available models
codex models list
# Update config to use available model
clinvk config set backends.codex.model o3