alirezarezvani avatar

codex-cli-bridge

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

by alirezarezvani|Open Source

Codex CLI Bridge Skill

Bridge between Claude Code and OpenAI Codex CLI for seamless cross-tool collaboration

Version Python License


๐ŸŽฏ What is This?

The Codex CLI Bridge creates seamless interoperability between Claude Code and OpenAI's Codex CLI by:

  1. Generating AGENTS.md from CLAUDE.md - Translates Claude Code configuration to Codex CLI format
  2. Documenting Skills for Codex Users - Shows how to use Claude Skills with Codex CLI
  3. Providing Execution Helpers - Python wrappers for Codex CLI commands

The Problem: Teams using both Claude Code and Codex CLI maintain duplicate documentation and can't easily share skills/workflows.

The Solution: This bridge auto-generates AGENTS.md from CLAUDE.md with file references (no duplication), enabling both tools to work with the same project structure.


โœจ Key Features

1. Documentation Translation

  • โœ… CLAUDE.md โ†’ AGENTS.md automatic generation
  • โœ… Reference-based (links to files, no duplication)
  • โœ… One-way sync (CLAUDE.md is source of truth)

2. Skill Documentation

  • โœ… Functional skills: Bash execution examples
  • โœ… Prompt-based skills: Codex prompt templates
  • โœ… Most relevant method per skill type

3. Safety Mechanisms

  • โœ… Auto-checks Codex CLI installation
  • โœ… Auto-runs /init if CLAUDE.md missing
  • โœ… User-friendly notifications

4. Codex Execution Helpers

  • โœ… Python wrappers for Codex CLI commands
  • โœ… Always uses codex exec (not plain codex)
  • โœ… Intelligent model selection (gpt-5 vs gpt-5-codex)
  • โœ… Sandbox mode helpers (read-only, workspace-write)

๐Ÿš€ Quick Start

Prerequisites

# 1. Codex CLI installed
codex --version  # Should show v0.48.0+

# 2. Python 3.7+ with PyYAML
python3 --version
pip3 install PyYAML

# 3. Claude Code project (or auto-create)

Generate AGENTS.md in 3 Steps

# 1. Navigate to your project
cd /your/claude-code-project

# 2. Run the bridge
python /path/to/codex-cli-bridge/bridge.py

# 3. Done! โœ…
# AGENTS.md created in project root

Output:

================================================================
โœ… SUCCESS - AGENTS.MD GENERATED
================================================================

๐Ÿ“„ Output: /your/project/AGENTS.md
๐Ÿ“Š Skills documented: 13
๐Ÿค– Agents documented: 59

Next steps:
  1. Review AGENTS.md
  2. Test with Codex CLI
  3. Share with team (works in both Claude Code and Codex CLI)

๐Ÿ“ฆ What's Included

Python Modules

ModulePurpose
bridge.pyMain orchestrator (runs complete workflow)
safety_mechanism.pyEnvironment validation (Codex CLI + CLAUDE.md checks)
claude_parser.pyParse CLAUDE.md and project structure
project_analyzer.pyAnalyze project metadata and structure
agents_md_generator.pyGenerate AGENTS.md (template-based)
skill_documenter.pyDocument skills for Codex CLI users
codex_executor.pyCodex CLI execution helpers

Documentation

FileDescription
SKILL.mdComplete skill reference
README.mdThis file
HOW_TO_USE.mdComprehensive usage guide

Templates

TemplatePurpose
templates/AGENTS.md generation templates (future)

๐Ÿ“– Usage Examples

Example 1: Basic Generation

# Generate AGENTS.md for current directory
python bridge.py

Example 2: Specific Project

# Generate for a different project
python bridge.py --project /path/to/other/project

Example 3: Validate Only

# Check environment without generating
python bridge.py --validate

Example 4: Python API

from bridge import CodexCliBridge

# Create bridge
bridge = CodexCliBridge(project_root="/your/project")

# Run complete workflow
success = bridge.run()

if success:
    print("โœ… AGENTS.md generated successfully")

Example 5: Codex Execution Helper

from codex_executor import CodexExecutor, CodexModel

executor = CodexExecutor()

# Execute analysis task
result = executor.exec_analysis(
    prompt="Analyze this codebase for security issues",
    model=CodexModel.GPT5
)

print(result.stdout)

๐ŸŽ“ How It Works

Architecture

Claude Code Project
โ”œโ”€โ”€ CLAUDE.md (Source of truth)
โ”œโ”€โ”€ .claude/
โ”‚   โ”œโ”€โ”€ skills/
โ”‚   โ””โ”€โ”€ agents/
โ””โ”€โ”€ documentation/

       โ†“ bridge.py

1. Safety Check
   โ”œโ”€โ”€ Codex CLI installed? โœ…
   โ””โ”€โ”€ CLAUDE.md exists? โœ… (auto-create if missing)

2. Parse & Analyze
   โ”œโ”€โ”€ Parse CLAUDE.md sections
   โ”œโ”€โ”€ Scan skills (functional vs prompt-based)
   โ”œโ”€โ”€ Scan agents
   โ””โ”€โ”€ Analyze project structure

3. Generate AGENTS.md
   โ”œโ”€โ”€ Project overview
   โ”œโ”€โ”€ Skills documentation (Codex CLI usage)
   โ”œโ”€โ”€ Workflow patterns (slash commands โ†’ Codex)
   โ”œโ”€โ”€ MCP integration
   โ””โ”€โ”€ Command reference

4. Write AGENTS.md
   โ””โ”€โ”€ Output: AGENTS.md (reference-based, 19KB example)

Result: Claude Code & Codex CLI Interoperability โœ…

๐Ÿ”ง Configuration

Default Behavior

  • Auto-init: Yes (runs /init if CLAUDE.md missing)
  • Output: AGENTS.md in project root
  • Approach: Reference-based (no file duplication)
  • Sync: One-way (CLAUDE.md โ†’ AGENTS.md)

Customize Behavior

# Disable auto-init
python bridge.py --no-auto-init

# Show status only
python bridge.py --status

# Validate only (no generation)
python bridge.py --validate

๐Ÿงช Testing

Test on This Repository

# Navigate to codex-cli-bridge folder
cd generated-skills/codex-cli-bridge

# Generate AGENTS.md for claude-code-skills-factory
python bridge.py --project ../..

# Check output
cat ../../AGENTS.md

Expected Results:

  • โœ… AGENTS.md created (19KB, 629 lines)
  • โœ… 13 skills documented (8 functional, 5 prompt-based)
  • โœ… 59 agents documented
  • โœ… All file references valid

๐Ÿ› Troubleshooting

Common Issues

IssueSolution
"Codex CLI not found"Install Codex CLI: which codex
"ModuleNotFoundError: yaml"Install PyYAML: pip3 install PyYAML
"CLAUDE.md not found"Let auto-init create it (default) or run /init
"stdout is not a terminal"Use codex exec not plain codex (skill does this automatically)
AGENTS.md out of syncRegenerate: python bridge.py

Get Help

# Show help
python bridge.py --help

# Check status
python bridge.py --status

# Validate environment
python bridge.py --validate

See HOW_TO_USE.md for comprehensive troubleshooting.


๐Ÿ“š Documentation


๐ŸŽฏ Use Cases

1. Cross-Tool Teams

Scenario: Team uses both Claude Code and Codex CLI

Solution:

  • Developers using Claude Code maintain CLAUDE.md
  • Developers using Codex CLI use AGENTS.md
  • Both files reference same skills, agents, documentation
  • Bridge keeps AGENTS.md in sync

2. Project Migration

Scenario: Migrating from Claude Code to Codex CLI (or vice versa)

Solution:

  • Generate AGENTS.md for existing Claude Code project
  • Codex CLI users have instant documentation
  • Skills remain usable (Python scripts execute directly)
  • Gradual migration possible

3. CI/CD Integration

Scenario: Auto-sync AGENTS.md when CLAUDE.md changes

Solution:

# .github/workflows/sync-agents-md.yml
on:
  push:
    paths: ['CLAUDE.md']
jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: python /path/to/bridge.py
      - run: git add AGENTS.md && git commit && git push

4. Skills Marketplace

Scenario: Share Claude Skills with Codex CLI users

Solution:

  • Include both CLAUDE.md and AGENTS.md in skill package
  • Claude Code users: Auto-load from CLAUDE.md
  • Codex CLI users: Follow AGENTS.md documentation
  • Universal compatibility

๐Ÿค Contributing

This skill was created as part of the Claude Code Skills Factory.

Improvements Welcome:

  • Bidirectional sync (AGENTS.md โ†’ CLAUDE.md) - planned for v2.0
  • Watch mode (auto-regenerate on file changes)
  • Additional templates
  • More execution helpers

๐Ÿ“„ License

Apache 2.0


๐ŸŒŸ Version

v1.0.0 - Initial Release (2025-10-30)

Features:

  • โœ… CLAUDE.md โ†’ AGENTS.md generation
  • โœ… Reference-based architecture (no duplication)
  • โœ… Safety mechanisms (Codex CLI + CLAUDE.md checks)
  • โœ… Skill documentation (functional vs prompt-based)
  • โœ… Codex execution helpers
  • โœ… Command reference table
  • โœ… Workflow patterns (Claude โ†’ Codex)

Future (v2.0):

  • ๐Ÿ”„ Bidirectional sync
  • ๐Ÿ”„ Watch mode
  • ๐Ÿ”„ Additional templates
  • ๐Ÿ”„ Plugin integration

๐Ÿ™ Acknowledgments

  • OpenAI - Codex CLI
  • Anthropic - Claude Code
  • Skills Factory - Comprehensive skill generation templates

๐Ÿ“ž Support

  • Issues: GitHub Issues
  • Documentation: See HOW_TO_USE.md
  • Examples: See AGENTS.md in this repository

Built with โค๏ธ for cross-tool collaboration

Claude Code โ†” Codex CLI Bridge v1.0.0