openai-codex
OpenAI Codex CLI usage patterns, configuration, sandboxing, and best practices for AI-assisted development.
Best use case
openai-codex is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
OpenAI Codex CLI usage patterns, configuration, sandboxing, and best practices for AI-assisted development.
Teams using openai-codex should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/openai-codex/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How openai-codex Compares
| Feature / Agent | openai-codex | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
OpenAI Codex CLI usage patterns, configuration, sandboxing, and best practices for AI-assisted development.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# OpenAI Codex CLI Development
> **Source:** https://github.com/openai/codex
Codex CLI is OpenAI's AI-powered coding agent that runs locally. This skill provides quick reference for effective usage, configuration, and integration.
## Best Practices
### Getting Started
- **Install via npm**: `npm install -g @openai/codex` or `brew install --cask codex`
- **Authenticate with ChatGPT** - Sign in with your ChatGPT Plus/Pro/Team account
- **Create an AGENTS.md** in project roots with project-specific context
- **Use trusted directories** to grant file system access
### Effective Usage
- **Be specific with requests** - "Refactor Dashboard to React Hooks" beats "fix code"
- **Use resume for long tasks** - `codex resume --last` continues previous sessions
- **Leverage non-interactive mode** - `codex exec "..."` for automation
### Model Selection
Codex uses GPT-4o by default. Override with `--model`:
```bash
codex --model gpt-4o # Default, balanced
codex --model gpt-4o-mini # Faster, cheaper
codex --model o1-preview # Advanced reasoning
```
### Configuration
Configuration lives in `~/.codex/config.toml`:
```toml
[model]
name = "gpt-4o"
[sandbox]
enabled = true
permissions = ["read", "write", "execute"]
[mcp_servers]
my-server = { command = "node", args = ["./server.js"] }
```
### AGENTS.md Files
Create project context files:
```markdown
<!-- AGENTS.md -->
# Project Context
This is a React TypeScript project using:
- Vite for bundling
- Tailwind CSS for styling
- React Query for data fetching
## Conventions
- Use functional components with hooks
- Place components in src/components/
- Run `npm test` before committing
```
### Sandbox & Security
- **Sandbox mode** restricts file system and network access
- **Execpolicy** defines rules for allowed commands
- **Approval modes**: `suggest` (default), `auto-edit`, `full-auto`
```bash
# Run with auto-approval for safe commands
codex --approval-mode auto-edit
# Strict sandbox mode
codex --sandbox
```
### Non-Interactive Mode
Use `codex exec` for automation and CI/CD:
```bash
# Single command
codex exec "fix lint errors in src/"
# With specific model
codex exec -m gpt-4o-mini "add TypeScript types to utils/"
# JSON output for scripting
codex exec --json "list all TODO comments"
```
## Quick Reference
### Common Commands
```bash
# Interactive session
codex
# With initial prompt
codex "explain this codebase"
# Non-interactive
codex exec "fix the bug in auth.ts"
# Resume previous session
codex resume --last
codex resume <SESSION_ID>
# Show status
codex status
```
### Slash Commands
| Command | Purpose |
|---------|---------|
| `/help` | Show available commands |
| `/clear` | Clear conversation |
| `/status` | Show session info |
| `/compact` | Compress context |
| `/model` | Change model |
| `/bug` | Report a bug |
### Keyboard Shortcuts
| Shortcut | Action |
|----------|--------|
| `Ctrl+C` | Cancel operation |
| `Ctrl+D` | Exit CLI |
| `Ctrl+L` | Clear screen |
| `Enter` | Send message |
| `Shift+Enter` | New line |
### Environment Variables
```bash
OPENAI_API_KEY # API key (if using API billing)
CODEX_MODEL # Default model
CODEX_SANDBOX # Enable sandbox (true/false)
CODEX_HOME # Config directory (~/.codex)
```
## Documentation Index
Detailed documentation synced from the official GitHub repository.
### Getting Started
| Resource | When to Consult |
|----------|-----------------|
| [readme.md](resources/readme.md) | Overview, installation, quickstart |
| [getting-started.md](resources/getting-started.md) | CLI usage, tips, example prompts |
| [install.md](resources/install.md) | Installation options |
| [authentication.md](resources/authentication.md) | Auth methods, API keys, headless login |
### Configuration
| Resource | When to Consult |
|----------|-----------------|
| [config.md](resources/config.md) | Full configuration reference |
| [example-config.md](resources/example-config.md) | Example configurations |
| [agents-md.md](resources/agents-md.md) | Root AGENTS.md file |
| [agents-md-guide.md](resources/agents-md-guide.md) | Writing effective AGENTS.md |
### Security & Sandboxing
| Resource | When to Consult |
|----------|-----------------|
| [sandbox.md](resources/sandbox.md) | Sandbox mode, permissions |
| [execpolicy.md](resources/execpolicy.md) | Command execution policies |
| [platform-sandboxing.md](resources/platform-sandboxing.md) | Platform-specific sandboxing |
| [windows-sandbox.md](resources/windows-sandbox.md) | Windows sandbox security |
| [zero-data-retention.md](resources/zero-data-retention.md) | ZDR mode |
### Features
| Resource | When to Consult |
|----------|-----------------|
| [exec.md](resources/exec.md) | Non-interactive mode |
| [prompts.md](resources/prompts.md) | Custom prompts |
| [skills.md](resources/skills.md) | Codex skills |
| [slash-commands.md](resources/slash-commands.md) | Slash commands |
| [advanced.md](resources/advanced.md) | MCP, tracing, advanced features |
### Reference
| Resource | When to Consult |
|----------|-----------------|
| [faq.md](resources/faq.md) | Frequently asked questions |
| [changelog.md](resources/changelog.md) | Version history |
| [contributing.md](resources/contributing.md) | Contributing guidelines |
| [sdk/typescript.md](resources/sdk/typescript.md) | TypeScript SDK |
## Syncing Documentation
Resources are synced from the official OpenAI Codex GitHub repository:
```bash
cd skills/openai-codex
bun run scripts/sync-docs.ts
```Related Skills
prompt-engineering-openai-api-f7c24501
Log in [Sign up](https://platform.openai.com/signup)
openai-knowledge
Use when working with the OpenAI API (Responses API) or OpenAI platform features (tools, streaming, Realtime API, auth, models, rate limits, MCP) and you need authoritative, up-to-date documentation (schemas, examples, limits, edge cases). Prefer the OpenAI Developer Documentation MCP server tools when available; otherwise guide the user to enable `openaiDeveloperDocs`.
openai-docs
Use when the user asks how to build with OpenAI products or APIs and needs up-to-date official documentation with citations (for example: Codex, Responses API, Chat Completions, Apps SDK, Agents SDK, Realtime, model capabilities or limits); prioritize OpenAI docs MCP tools and restrict any fallback browsing to official OpenAI domains.
openai-docs-skill
Query the OpenAI developer documentation via the OpenAI Docs MCP server using CLI (curl/jq). Use whenever a task involves the OpenAI API (Responses, Chat Completions, Realtime, etc.), OpenAI SDKs, ChatGPT Apps SDK, Codex, MCP integrations, endpoint schemas, parameters, limits, or migrations and you need up-to-date official guidance.
naiba-openai-sales
ChatGPT use cases and prompts for sales teams | Part of naiba-openai-work-assistant
naiba-openai-product
ChatGPT use cases and prompts for product teams | Part of naiba-openai-work-assistant
naiba-openai-managers
ChatGPT use cases and prompts for managers | Part of naiba-openai-work-assistant
naiba-openai-it
ChatGPT use cases and prompts for IT teams | Part of naiba-openai-work-assistant
naiba-openai-hr
ChatGPT use cases and prompts for HR teams | Part of naiba-openai-work-assistant
naiba-openai-government-it-staff
A quick-start guide for IT teams at any level of government who just received ChatGPT access | Part of naiba-openai-work-assistant
naiba-openai-executives
ChatGPT use cases and prompts for executives | Part of naiba-openai-work-assistant
naiba-openai-engineers
ChatGPT use cases and prompts for engineering teams | Part of naiba-openai-work-assistant