OpenAI Codex CLI — AI Coding Agent in Your Terminal

You are an expert in OpenAI's Codex CLI, the open-source terminal-based coding agent that reads your codebase, generates and edits code, runs shell commands, and applies changes — all within your terminal. You help developers use Codex CLI for code generation, refactoring, debugging, and automation with configurable approval modes (suggest, auto-edit, full-auto) and sandboxed execution for safety.

25 stars

Best use case

OpenAI Codex CLI — AI Coding Agent in Your Terminal is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

You are an expert in OpenAI's Codex CLI, the open-source terminal-based coding agent that reads your codebase, generates and edits code, runs shell commands, and applies changes — all within your terminal. You help developers use Codex CLI for code generation, refactoring, debugging, and automation with configurable approval modes (suggest, auto-edit, full-auto) and sandboxed execution for safety.

Teams using OpenAI Codex CLI — AI Coding Agent in Your Terminal 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

$curl -o ~/.claude/skills/openai-codex-cli/SKILL.md --create-dirs "https://raw.githubusercontent.com/ComeOnOliver/skillshub/main/skills/TerminalSkills/skills/openai-codex-cli/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/openai-codex-cli/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How OpenAI Codex CLI — AI Coding Agent in Your Terminal Compares

Feature / AgentOpenAI Codex CLI — AI Coding Agent in Your TerminalStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

You are an expert in OpenAI's Codex CLI, the open-source terminal-based coding agent that reads your codebase, generates and edits code, runs shell commands, and applies changes — all within your terminal. You help developers use Codex CLI for code generation, refactoring, debugging, and automation with configurable approval modes (suggest, auto-edit, full-auto) and sandboxed execution for safety.

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 — AI Coding Agent in Your Terminal

You are an expert in OpenAI's Codex CLI, the open-source terminal-based coding agent that reads your codebase, generates and edits code, runs shell commands, and applies changes — all within your terminal. You help developers use Codex CLI for code generation, refactoring, debugging, and automation with configurable approval modes (suggest, auto-edit, full-auto) and sandboxed execution for safety.

## Core Capabilities

### Basic Usage

```bash
# Install
npm install -g @openai/codex

# Interactive mode
codex

# One-shot with a prompt
codex "Add input validation to all API endpoints in src/routes/"

# With specific model
codex --model o4-mini "Refactor the auth module to use JWT refresh tokens"

# Approval modes
codex --approval-mode suggest "Fix the failing tests"     # Show changes, ask before applying
codex --approval-mode auto-edit "Update all imports"       # Auto-apply edits, ask for commands
codex --approval-mode full-auto "Run tests and fix failures"  # Full autonomous mode
```

### Configuration

```yaml
# ~/.codex/config.yaml
model: o4-mini                            # Default model
approval_mode: suggest                    # suggest | auto-edit | full-auto
providers:
  - name: openai
    api_key_env: OPENAI_API_KEY
  - name: anthropic                       # Works with Claude too
    api_key_env: ANTHROPIC_API_KEY
sandbox:
  enabled: true                           # Run commands in sandbox
  network: false                          # No network access in sandbox
  writable_paths:                         # Only these paths are writable
    - ./src
    - ./tests
```

### Project Instructions

```markdown
# codex.md — Project-level instructions (checked into repo)

## Project Overview
This is a Next.js 14 app with tRPC, Drizzle ORM, and Tailwind.

## Conventions
- Use server components by default
- All database queries go through src/server/db/queries/
- Tests use Vitest with MSW for API mocking
- Commit messages follow Conventional Commits

## Do NOT
- Modify the database schema without creating a migration
- Use `any` type in TypeScript
- Install new dependencies without asking
```

### Common Workflows

```bash
# Fix failing tests
codex "The test suite is failing. Read the error output, find the broken tests, and fix them."

# Add a feature
codex "Add a /api/webhooks/stripe endpoint that handles subscription.created and subscription.deleted events. Update the user's plan in the database."

# Refactor
codex "Migrate all useState + useEffect patterns in src/components/ to use TanStack Query for data fetching."

# Documentation
codex "Generate JSDoc comments for all exported functions in src/lib/"

# Security audit
codex "Review src/server/ for SQL injection, XSS, and authentication bypass vulnerabilities. Fix any issues found."
```

## Installation

```bash
npm install -g @openai/codex
# Requires: OPENAI_API_KEY environment variable
# Works with: GPT-4o, o4-mini, o3 models
```

## Best Practices

1. **Start with suggest mode** — Review changes before applying; switch to auto-edit once you trust the patterns
2. **codex.md for context** — Add project-level instructions; Codex reads them automatically for every session
3. **Sandbox for safety** — Enable sandboxing to prevent unintended file deletions or network calls
4. **Specific prompts** — "Fix the pagination bug in posts.ts" beats "fix bugs"; include file paths and expected behavior
5. **Full-auto for CI** — Use `full-auto` mode in CI pipelines for automated test fixing and code generation
6. **Writable paths** — Restrict writable paths in sandbox config; Codex can only modify files you allow
7. **Multiple providers** — Configure both OpenAI and Anthropic; switch models based on task complexity
8. **Git integration** — Codex respects `.gitignore`; changes are uncommitted so you can review diffs before committing

Related Skills

rigorous-coding

25
from ComeOnOliver/skillshub

Apply rigorous coding standards. Use when writing, implementing, or reviewing code.

write-coding-standards-from-file

25
from ComeOnOliver/skillshub

Write a coding standards document for a project using the coding styles from the file(s) and/or folder(s) passed as arguments in the prompt.

stream-coding

25
from ComeOnOliver/skillshub

Documentation-first development methodology. The goal is AI-ready documentation - when docs are clear enough, code generation becomes automatic. Triggers on "Build", "Create", "Implement", "Document", or "Spec out". Version 3.5 adds Phase 2.5 Adversarial Review and renames internal verification to Spec Gate (structural completeness). Clarity Gate is now a separate standalone tool for epistemic quality.

OpenAI Whisper API (curl)

25
from ComeOnOliver/skillshub

Transcribe an audio file via OpenAI’s `/v1/audio/transcriptions` endpoint.

OpenAI Image Gen

25
from ComeOnOliver/skillshub

Generate a handful of “random but structured” prompts and render them via the OpenAI Images API.

Coding Agent (bash-first)

25
from ComeOnOliver/skillshub

Use **bash** (with optional background mode) for all coding agent work. Simple and effective.

terminal-session

25
from ComeOnOliver/skillshub

tmux 持久化终端会话控制。通过向 tmux 发送按键、读取输出,管理 Claude Code、Codex、SSH 等长时间运行的交互式进程。跨多轮对话保持进程状态。需预装 tmux(Linux/macOS 默认提供;Windows 用户需 WSL2)。

codex-cli-bridge

25
from ComeOnOliver/skillshub

Bridge between Claude Code and OpenAI Codex CLI - generates AGENTS.md from CLAUDE.md, provides Codex CLI execution helpers, and enables seamless interoperability between both tools

copilot-coding-agent

25
from ComeOnOliver/skillshub

GitHub Copilot Coding Agent automation. Apply the ai-copilot label to an issue → GitHub Actions auto-assigns Copilot via GraphQL → Copilot creates a Draft PR. One-click issue-to-PR pipeline.

codex

25
from ComeOnOliver/skillshub

Use when the user asks to run Codex CLI (codex exec, codex resume) or references OpenAI Codex for code analysis, refactoring, or automated editing. Uses GPT-5.2 by default for state-of-the-art software engineering.

codex-review

25
from ComeOnOliver/skillshub

Professional code review with auto CHANGELOG generation, integrated with Codex AI

cc-skill-coding-standards

25
from ComeOnOliver/skillshub

Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development.