Complete guide to using the Codex CLI Bridge skill for seamless interoperability between Claude Code and OpenAI's Codex CLI.
- Quick Start
- Prerequisites
- Installation
- Basic Usage
- Advanced Usage
- Codex Execution Helpers
- Troubleshooting
- Examples
Generate AGENTS.md for your project in 3 steps:
# 1. Navigate to your Claude Code project
cd /path/to/your/project
# 2. Run the bridge
python /path/to/codex-cli-bridge/bridge.py
# 3. Done! AGENTS.md created-
Codex CLI installed and authenticated:
codex --version # Should show v0.48.0 or higher codex login # If not authenticated
-
Python 3.7+ with PyYAML:
python3 --version pip3 install PyYAML
-
Claude Code project (or skill will auto-create minimal CLAUDE.md)
- Claude Code CLI (for /init, /update-claude commands)
- Git (for version control)
No installation needed - just run the bridge script:
python /path/to/codex-cli-bridge/bridge.py --project /path/to/your/project# Copy entire skill to Claude skills directory
cp -r codex-cli-bridge ~/.claude/skills/
# Or to project-specific skills
cp -r codex-cli-bridge /your/project/.claude/skills/# Add bridge.py to your PATH
export PATH="$PATH:/path/to/codex-cli-bridge"
# Then use anywhere
bridge.py --project /any/projectDefault (current directory):
python bridge.pySpecific project:
python bridge.py --project /path/to/projectOutput:
- Creates
AGENTS.mdin project root - Reference-based (links to existing files, no duplication)
- Documents all skills with Codex CLI usage examples
Check if everything is ready without generating:
python bridge.py --validateChecks:
- ✅ Codex CLI installed
- ✅ CLAUDE.md exists (or can be created)
- ✅ Python dependencies
python bridge.py --statusShows:
- Project root
- CLAUDE.md status
- Codex CLI version
- Authentication status
By default, if CLAUDE.md is missing, the skill auto-runs /init. To disable:
python bridge.py --no-auto-initAfter updating CLAUDE.md:
python bridge.py # Overwrites existing AGENTS.mdKeep in sync:
# Update CLAUDE.md
vim CLAUDE.md
# Regenerate AGENTS.md
python bridge.pyGREENFIELD_NEW (default):
python bridge.py --project /new/projectENTERPRISE_REFACTOR:
# Project type auto-detected from CLAUDE.md
python bridge.py --project /existing/enterprise/projectLEGACY_MODERNIZATION:
# Auto-detected if CLAUDE.md mentions legacy modernization
python bridge.py --project /legacy/projectThe skill provides Python wrappers for Codex CLI commands.
from codex_executor import CodexExecutor, CodexModel
executor = CodexExecutor()
# Read-only analysis (safe)
result = executor.exec_analysis(
prompt="Analyze this codebase for security vulnerabilities",
model=CodexModel.GPT5
)
print(result.stdout)# Code editing with gpt-5-codex (specialized)
result = executor.exec_edit(
prompt="Refactor main.py to use async patterns",
model=CodexModel.GPT5_CODEX
)
if result.success:
print("✅ Code edited successfully")
else:
print(f"❌ Error: {result.stderr}")# Resume last Codex session
result = executor.resume_session()# Enable web search for tasks needing latest info
result = executor.exec_with_search(
prompt="Research latest Python async patterns and apply them"
)from codex_executor import SandboxMode, ReasoningEffort
cmd = executor.generate_command_string(
prompt="Your task",
model=CodexModel.GPT5,
sandbox=SandboxMode.READ_ONLY,
reasoning=ReasoningEffort.HIGH
)
print(cmd)
# Output:
# codex exec -m gpt-5 -s read-only \
# -c model_reasoning_effort=high \
# --skip-git-repo-check \
# "Your task"Symptom:
❌ Codex CLI not found!
Solution:
# Check if Codex is in PATH
which codex
# If not, install Codex CLI
# (See https://github.com/openai/codex)
# Verify installation
codex --versionSymptom:
⚠️ CLAUDE.md not found
Solution 1 (Auto-init enabled by default):
# Skill auto-runs /init and creates CLAUDE.md
python bridge.py # Just run normallySolution 2 (Manual):
# Run /init manually
/init
# Then run bridge
python bridge.pySolution 3 (Minimal CLAUDE.md):
# Skill creates minimal CLAUDE.md automatically
python bridge.py # With auto-init enabledSymptom:
ModuleNotFoundError: No module named 'yaml'
Solution:
# Install PyYAML
pip3 install PyYAML
# Or with user flag
pip3 install --user PyYAML
# Or with system packages (if needed)
pip3 install PyYAML --break-system-packagesSymptom: CLAUDE.md was updated but AGENTS.md is stale
Solution:
# Regenerate AGENTS.md
python bridge.py
# Or use command integration (if installed)
/sync-agents-mdSymptom:
Error: stdout is not a terminal
Cause: Using plain codex instead of codex exec
Solution:
# ❌ WRONG
codex -m gpt-5 "task"
# ✅ CORRECT
codex exec -m gpt-5 "task"Note: This skill ALWAYS uses codex exec (never plain codex).
# 1. Create new project
mkdir my-project && cd my-project
# 2. Initialize with Claude Code (optional)
/init
# 3. Generate AGENTS.md
python /path/to/codex-cli-bridge/bridge.py
# Result:
# - CLAUDE.md created (if didn't exist)
# - AGENTS.md generated
# - Ready for both Claude Code and Codex CLI# You have a Claude Code project with:
# - CLAUDE.md
# - .claude/skills/
# - .claude/agents/
# Generate AGENTS.md for Codex CLI users
cd /your/project
python /path/to/codex-cli-bridge/bridge.py
# Result:
# - AGENTS.md created
# - All skills documented with Codex usage examples
# - Team can use Claude Code OR Codex CLI# In CI/CD pipeline, validate environment
python bridge.py --validate
if [ $? -eq 0 ]; then
echo "✅ Environment valid, proceed with deployment"
else
echo "❌ Environment validation failed"
exit 1
fi#!/bin/bash
# auto-sync.sh - Keep AGENTS.md in sync with CLAUDE.md
# Watch for CLAUDE.md changes
fswatch -o CLAUDE.md | while read; do
echo "CLAUDE.md changed, regenerating AGENTS.md..."
python /path/to/bridge.py
echo "✅ AGENTS.md updated"
doneScenario: Team uses both Claude Code and Codex CLI
Setup:
# 1. Maintain CLAUDE.md as source of truth (Claude Code users)
vim CLAUDE.md
# 2. Generate AGENTS.md for Codex CLI users
python bridge.py
# 3. Commit both files
git add CLAUDE.md AGENTS.md
git commit -m "docs: Update project configuration"
git pushResult:
- Claude Code users: Use CLAUDE.md
- Codex CLI users: Use AGENTS.md
- Both files reference same skills, agents, documentation
| Command | Description |
|---|---|
bridge.py |
Generate AGENTS.md for current directory |
bridge.py --project /path |
Generate for specific project |
bridge.py --validate |
Validate environment only |
bridge.py --no-auto-init |
Don't auto-run /init if CLAUDE.md missing |
bridge.py --status |
Show status report |
bridge.py --help |
Show help |
✅ DO:
- Edit CLAUDE.md
- Regenerate AGENTS.md
- Commit both files
❌ DON'T:
- Edit AGENTS.md directly (will be overwritten)
- Keep AGENTS.md without regenerating
Regenerate when:
- Added new skills
- Updated CLAUDE.md sections
- Changed project structure
- Added/removed agents
# .github/workflows/sync-agents-md.yml
name: Sync AGENTS.md
on:
push:
paths:
- 'CLAUDE.md'
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Generate AGENTS.md
run: python /path/to/bridge.py
- name: Commit if changed
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add AGENTS.md
git commit -m "docs: Auto-sync AGENTS.md" || exit 0
git pushGood SKILL.md = Good AGENTS.md section
SKILL.md should include:
- Clear description
- Usage examples
- Python script documentation
- Input/output formats
After generating, test commands:
# Test a documented command from AGENTS.md
codex exec -m gpt-5 -s read-only "Test task"
# Verify skill references work
codex exec "Using skill at path/to/SKILL.md, do task"- SKILL.md: Complete skill reference
- AGENTS.md: Example output (this repository)
- Codex CLI Docs: https://github.com/openai/codex
- Claude Code Docs: https://docs.claude.com/claude-code
Version: 1.0.0 Last Updated: 2025-10-30 Maintained For: Cross-tool team collaboration (Claude Code ↔ Codex CLI)