Back to AI Tools & Agents

Codex CLI Bridge

ai-agentscodexautomationcli-toolsinteroperability
4.6 (194)802📄 MIT🕒 2025-11-12Source ↗

Install this skill

npx skills add alirezarezvani/claude-code-skill-factory

Works across Claude Code, Cursor, Codex, Copilot & Antigravity

What this skill does

  • Generates AGENTS.md from CLAUDE.md project documentation without file duplication
  • Wraps Codex CLI commands into modular Python execution functions
  • Performs automatic environment verification and Codex CLI installation checks
  • Translates Claude Code skills into reference-based prompts compatible with Codex CLI
  • Manages secure sandbox modes including read-only analysis and workspace-write editing

When to use it

  • When you need to synchronize project-specific skills between Claude Code and Codex CLI
  • When you want to maintain a single source of truth for agent documentation in a multi-AI tool workspace
  • When automating routine code analysis or editing tasks that require consistent CLI execution flags
  • When setting up new developers with automated environment initialization for AI-assisted workflows

When not to use it

  • If your project exclusively uses Claude Code and does not require OpenAI Codex CLI integration
  • For simple projects that do not require external skill documentation or automated command wrappers

How to invoke it

Example prompts that trigger this skill:

  • Generate AGENTS.md for this project
  • Use Codex to perform a read-only analysis of the current directory
  • Run a workspace-write edit task using the Codex execution helper
  • Initialize project documentation and validate my Codex CLI environment
  • Find and execute the relevant skill for project refactoring via Codex

Example workflow

  1. Initialize the bridge in the project root directory
  2. Trigger the agent to parse the existing CLAUDE.md and local skill files
  3. Review the newly generated AGENTS.md for accuracy
  4. Execute a specific analysis task using the codex-cli-bridge Python helper
  5. Verify the command output and session ID from the executor

Prerequisites

  • OpenAI Codex CLI installed and authenticated
  • Python 3.x installed
  • CLAUDE.md file present in the project root

Pitfalls & limitations

  • !Requires manual maintenance of the underlying CLAUDE.md structure to ensure accurate AGENTS.md generation
  • !If the Codex CLI path is not correctly configured in the system environment, the bridge will fail during initialization
  • !Relies on 'codex exec' command patterns, which may change if the underlying CLI interface is updated

FAQ

Does this tool duplicate my code files?
No, it uses reference-based links in the generated AGENTS.md to point to existing files rather than copying content.
What happens if CLAUDE.md is missing?
The safety mechanism will automatically attempt to run the initialization process to generate the necessary files.
Why is 'codex exec' used instead of plain 'codex'?
Using 'codex exec' ensures that all tasks are routed through the correct execution context, which is required for reliable integration with Claude Code workflows.

How it compares

Unlike manual documentation or basic CLI wrappers, this tool provides an automated, programmatic mapping between two distinct AI agent standards, ensuring consistency across different toolsets without manual synchronization.

Source & trust

802 stars📄 MIT🕒 Updated 2025-11-12🛡 runs-shell, network

From the source: “# Codex CLI Bridge Skill ## Purpose This skill creates a comprehensive bridge between **Claude Code** and **OpenAI's Codex CLI**, enabling seamless interoperability through: 1. **Documentation Translation**: Converts CLAUDE.md → AGENTS.md (reference-based, no file duplication) 2. **Execution Helpers…”

View the full SKILL.md source

# Codex CLI Bridge Skill

## Purpose

This skill creates a comprehensive bridge between **Claude Code** and **OpenAI's Codex CLI**, enabling seamless interoperability through:

1. **Documentation Translation**: Converts CLAUDE.md → AGENTS.md (reference-based, no file duplication)
2. **Execution Helpers**: Python wrappers for Codex CLI commands (always uses `codex exec`)
3. **Skill Documentation**: Makes Claude Skills accessible to Codex CLI users

## Key Capabilities

### 1. CLAUDE.md → AGENTS.md Generation
- Parses CLAUDE.md and project structure
- Scans `.claude/skills/`, `.claude/agents/`, `documentation/` folders
- Generates comprehensive AGENTS.md with file path references
- **Reference-based**: No file duplication, only links to existing files
- Documents Skills with most relevant usage method (bash scripts vs prompt references)

### 2. Safety Mechanism
- **Auto-checks Codex CLI installation** (`codex --version`)
- **Auto-runs `/init`** if CLAUDE.md missing (with user notification)
- Validates authentication and environment
- User-friendly error messages

### 3. Codex CLI Execution Helpers
- `exec_analysis()` - Read-only analysis tasks (gpt-5, read-only sandbox)
- `exec_edit()` - Code editing tasks (gpt-5-codex, workspace-write)
- `exec_with_search()` - Web search-enabled tasks
- `resume_session()` - Continue last Codex session
- **Always uses `codex exec`** (never plain `codex` - critical for Claude Code)

### 4. Skill Documentation for Codex CLI
- **Prompt-only skills**: Show how to reference in Codex prompts
- **Functional skills**: Show how to execute Python scripts directly
- **Complex skills**: Show both methods
- Includes proper `codex exec` command syntax
- Model selection guidance (gpt-5 vs gpt-5-codex)

## Input Requirements

### For AGENTS.md Generation
```json
{
  "action": "generate-agents-md",
  "project_root": "/path/to/project",
  "options": {
    "validate_codex": true,
    "auto_init": true,
    "include_mcp": true,
    "skill_detail_level": "relevant"
  }
}
```

### For Codex Execution
```json
{
  "action": "codex-exec",
  "task_type": "analysis|edit|search",
  "prompt": "Your task description",
  "model": "gpt-5|gpt-5-codex",
  "sandbox": "read-only|workspace-write|danger-full-access"
}
```

## Output Formats

### AGENTS.md Structure
```markdown
# AGENTS.md

## Project Overview
[From CLAUDE.md]

## Available Skills
### Skill Name
**Location**: `path/to/skill/`
**Using from Codex CLI**: [Most relevant method]

## Workflow Patterns
[Slash commands → Codex equivalents]

## MCP Integration
[MCP server references]

## Command Reference
| Claude Code | Codex CLI |
|-------------|-----------|
[Mappings]
```

### Execution Helper Output
```python
{
  "status": "success|error",
  "output": "Command output",
  "session_id": "uuid",
  "model_used": "gpt-5|gpt-5-codex",
  "command": "codex exec ..."
}
```

## Python Scripts

### safety_mechanism.py
- Check Codex CLI installation
- Validate CLAUDE.md exists (auto-run /init if missing)
- Environment validation
- User notifications

### claude_parser.py
- Parse CLAUDE.md sections
- Scan skills, agents, commands
- Extract quality gates and MCP configuration
- Return file paths only (no content duplication)

### project_analyzer.py
- Auto-detect project structure
- Discover all Claude Code assets
- Generate project metadata
- Build reference map

### agents_md_generator.py
- Template-based AGENTS.md generation
- File path references (no duplication)
- Skill documentation (most relevant method)
- Workflow translation (Claude → Codex)

### skill_documenter.py
- Document skills for Codex CLI users
- Determine most relevant usage method per skill type
- Generate bash examples for Python scripts
- Create Codex prompt templates

### codex_executor.py
- Python wrappers for Codex CLI commands
- Intelligent model selection (gpt-5 vs gpt-5-codex)
- Sandbox mode helpers
- Session management
- **Always uses `codex exec`**

## Usage Examples

### Example 1: Generate AGENTS.md

**User prompt**:
```
Generate AGENTS.md for this project
```

**What happens**:
1. Safety mechanism checks Codex CLI installed
2. Checks CLAUDE.md exists (auto-runs /init if missing)
3. Parses CLAUDE.md and project structure
4. Generates AGENTS.md with file references
5. Documents all skills with most relevant usage method

**Output**: Complete AGENTS.md file in project root

---

### Example 2: Execute Codex Analysis Task

**User prompt**:
```
Use Codex to analyze this codebase for security vulnerabilities
```

**What happens**:
```python
from codex_executor import CodexExecutor

executor = CodexExecutor()
result = executor.exec_analysis(
    "Analyze this codebase for security vulnerabilities",
    model="gpt-5"
)
```

**Executes**:
```bash
codex exec -m gpt-5 -s read-only \
  -c model_reasoning_effort=high \
  "Analyze this codebase for security vulnerabilities"
```

---

### Example 3: Execute Codex Code Editing

**User prompt**:
```
Use Codex to refactor main.py for better async patterns
```

**What happens**:
```python
executor = CodexExecutor()
result = executor.exec_edit(
    "Refactor main.py for better async patterns",
    model="gpt-5-codex"
)
```

**Executes**:
```bash
codex exec -m gpt-5-codex -s workspace-write \
  -c model_reasoning_effort=high \
  "Refactor main.py for better async patterns"
```

---

### Example 4: Resume Codex Session

**User prompt**:
```
Continue the previous Codex session
```

**What happens**:
```python
executor = CodexExecutor()
result = executor.resume_session()
```

**Executes**:
```bash
codex exec resume --last
```

## Best Practices

### For AGENTS.md Generation
1. **Always run on projects with CLAUDE.md** (or let auto-init create it)
2. **Validate Codex CLI installed first**
3. **Keep skills documented with most relevant method** (bash vs prompt)
4. **Use reference-based approach** (no file duplication)

### For Codex Execution
1. **Use `codex exec` always** (never plain `codex` in Claude Code)
2. **Choose correct model**:
   - `gpt-5`: General reasoning, architecture, analysis
   - `gpt-5-codex`: Code editing, specialized coding tasks
3. **Choose correct sandbox**:
   - `read-only`: Safe analysis (default)
   - `workspace-write`: File modifications
   - `danger-full-access`: Network access (rarely needed)
4. **Enable search when needed** (`--search` flag)

### For Skill Documentation
1. **Prompt-only skills**: Reference in Codex prompts
2. **Functional skills**: Execute Python scripts directly
3. **Complex skills**: Show both methods
4. **Always provide working examples**

## Command Integration

This skill integrates with existing Claude Code commands:

- **`/init`**: Auto-generates AGENTS.md after CLAUDE.md creation
- **`/update-claude`**: Regenerates AGENTS.md when CLAUDE.md changes
- **`/check-docs`**: Validates AGENTS.md exists and is in sync
- **`/sync-agents-md`**: Manual AGENTS.md regeneration
- **`/codex-exec <task>`**: Wrapper using codex_executor.py

## Installation

### Prerequisites
1. **Codex CLI installed**:
   ```bash
   codex --version  # Should show v0.48.0 or higher
   ```

2. **Codex authenticated**:
   ```bash
   codex login
   ```

3. **Claude Code v1.0+**

### Install Skill

**Option 1: Copy to project**
```bash
cp -r generated-skills/codex-cli-bridge ~/.claude/skills/
```

**Option 2: Use from this repository**
```bash
# Skill auto-discovered when Claude Code loads this project
```

## Troubleshooting

### Error: "Codex CLI not found"
**Solution**: Install Codex CLI and ensure it's in PATH
```bash
which codex  # Should return path
codex --version  # Should work
```

### Error: "CLAUDE.md not found"
**Solution**: Skill auto-runs `/init` with notification. If it fails:
```bash
# Manually run /init
/init
```

### Error: "stdout is not a terminal"
**Solution**: Always use `codex exec`, never plain `codex`
```bash
❌ codex -m gpt-5 "task"
✅ codex exec -m gpt-5 "task"
```

### AGENTS.md Out of Sync
**Solution**: Regenerate manually
```bash
/sync-agents-md
```

## References

- **Codex CLI Docs**: `openai-codex-cli-instructions.md`
- **Claude Skills Docs**: `claude-skills-instructions.md`
- **Example Skills**: `claude-skills-examples/codex-cli-skill.md`
- **AGENTS.md Spec**: https://agents.md/

## Version

**v1.0.0** - Initial release (2025-10-30)

## License

Apache 2.0

---

**Created by**: Claude Code Skills Factory
**Maintained for**: Cross-tool team collaboration (Claude Code ↔ Codex CLI)
**Sync Status**: Reference-based bridge (one-way sync: CLAUDE.md → AGENTS.md)

Quoted from alirezarezvani/claude-code-skill-factory for reference — see the original for the authoritative, latest version.

📄 Full skill instructions — original source: alirezarezvani/claude-code-skill-factory
The Codex CLI Bridge serves as an interoperability layer between Claude Code and the OpenAI Codex CLI. It enables developers to manage cross-tool workflows by translating project documentation, automating environment checks, and wrapping execution commands into standard Python helpers. By converting CLAUDE.md into a structured AGENTS.md, the tool allows Codex CLI to recognize and invoke existing Claude-based skill sets without duplicating codebase files. This utility ensures that agents configured for one environment remain accessible and functional within the other, providing a unified command interface. It is particularly useful for developers who maintain hybrid project setups where task-specific analysis or editing requires the distinct execution modes provided by the Codex CLI while adhering to standard Claude Code structural conventions.

How to Use This Skill Unit

Option A: Project-Specific (Recommended)

  1. Click "Download" above
  2. In your project, create the directory: .agent/skills/codex-cli-bridge/
  3. Save the file as SKILL.md
  4. The agent will automatically discover the skill based on its description.

Option B: Global Installation (All Agents)

Save the file to these locations to make it available across all projects:

  • Claude Code: ~/.claude/skills/alirezarezvani/claude-code-skill-factory/codex-cli-bridge/SKILL.md
  • Cursor: ~/.cursor/skills/alirezarezvani/claude-code-skill-factory/codex-cli-bridge/SKILL.md
  • Antigravity: ~/.gemini/antigravity/skills/alirezarezvani/claude-code-skill-factory/codex-cli-bridge/SKILL.md

🚀 Install with CLI:
npx skills add alirezarezvani/claude-code-skill-factory

Read the Master Guide: Mastering Agent Skills

Recommended Rules

View more rules

Recommended Workflows

View more workflows

Recommended MCP Servers

View more MCP servers

Take It Further

Maximize your productivity with these powerful resources

📋

Define Your Standards

Set up coding standards to ensure this workflow produces consistent, high-quality results.

Browse Rules Library
📖

Master Workflows

Learn how to create custom workflows, use Turbo Mode, and build your automation library.

Complete Guide

How to use this Skill in Claude Code & Cursor

For Claude Code (CLI)

To use this skill in Claude Code, copy the rule content into your project's custom instructions or follow our Add-Skill CLI guide. This ensures Claude follows your standards during every code generation.

For Cursor & Windsurf

For Cursor or Windsurf, individual skills are best used in the "Rules for AI" section. This specific unit helps the agent avoid ai tools & agents issues, leading to cleaner, more efficient code.

Why the skill format matters: the standardized Agent Skills format lets your AI agent load detailed instructions only when they are relevant, keeping your prompt clean while improving results.

Source & attribution

This skill is categorized under AI Tools & Agents and is published by alirezarezvani, maintained in alirezarezvani/claude-code-skill-factory.

← Browse All Agent Skills
Sponsored AI assistant. Recommendations may be paid.