Production-ready tool for running OpenAI Codex CLI in parallel on your codebase
Codex Worker enables safe, resumable, parallel execution of OpenAI Codex CLI on multiple files. Perfect for automating repetitive coding tasks that don't require complex reasoning.
"I use Claude Code to analyze npm lint errors, group them by file and error type, then create task files for OpenAI Codex CLI to fix. Since the tasks are clear and mechanical, OpenAI Codex CLI handles them perfectly. This saves my Claude tokens for complex problems and avoids hitting rate limits!"
- Bulk Lint Fixes: Let Claude analyze errors โ Create fix tasks โ OpenAI Codex CLI executes in parallel
- Test Generation: Define test requirements โ OpenAI Codex CLI writes tests for multiple files
- Code Migrations: Specify transformation rules โ OpenAI Codex CLI applies across codebase
- Documentation: Outline what's needed โ OpenAI Codex CLI adds to multiple files
- Refactoring: Define the pattern โ OpenAI Codex CLI applies consistently
The key insight: Use expensive AI (Claude/GPT-4) for planning, use OpenAI Codex CLI for execution.
When working with AI coding agents, you often want to:
- Process multiple tasks in parallel - Run 10 agents fixing different bugs simultaneously
- Resume after interruptions - Power outage? Network issue? Just run again, completed tasks are skipped
- Track progress visually - See what's done, in-progress, or failed at a glance
- Maintain safety - Default read-only mode, explicit permissions for modifications
- Coordinate multiple workers - Run from multiple terminals without conflicts
Codex Worker uses a simple but powerful approach: file prefixes track state.
tasks/
โโโ fix-auth-bug.md # โธ๏ธ Pending task
โโโ in-progress-add-feature.md # ๐ Currently being processed
โโโ done_exec_log-update-api.md.txt # โ
Completed task (with output log)
โโโ failed_exec_log-refactor.md.txt # โ Failed task (with error log)
This prefix system enables:
- Zero-config resumability - Just run the command again
- Parallel coordination - Workers see what others are doing
- Clear visual status -
lsshows you everything - No database needed - Filesystem is the source of truth
| Option | Description | Default |
|---|---|---|
--pattern |
File pattern to match | *.md |
--model |
Model name | o4-mini |
--mode |
Safety level | read-only |
--concurrency |
Parallel workers | 1 |
--timeout |
Task timeout (seconds) | None |
--retries |
Retry attempts | 0 |
--approval |
Human approval mode | on-request |
Interrupted? No problem. Codex Worker automatically:
- Skips completed tasks (files with
done_exec_log-prefix) - Detects in-progress tasks from other workers
- Cleans up stale locks from crashed processes
- Retries failed tasks based on your configuration
# Install with pip
pip install codex-worker
# Or install from source
git clone https://github.com/yigitkonur/codex-worker
cd codex-worker
pip install -e .- Python 3.8+
- OpenAI Codex CLI:
npm install -g @openai/codex
- Typer, Rich (installed automatically with pip install)
# Create task files
echo "Fix the authentication bug in login.py" > fix-auth.md
echo "Add rate limiting to API endpoints" > add-ratelimit.md
echo "Refactor database queries for performance" > optimize-db.md
# Run OpenAI Codex CLI on all .md files (safe read-only mode by default)
codex-worker
# Output:
# โ
fix-auth.md completed
# โ
add-ratelimit.md completed
# โ
optimize-db.md completed# Run 4 AI agents in parallel
codex-worker --concurrency 4
# Each agent works on a different file simultaneously
# 4x faster than sequential execution!# Start processing 100 files
codex-worker large-tasks/ --concurrency 8
# Ctrl+C after 30 files complete
# ^C Shutting down gracefully...
# Run again - only processes remaining 70 files!
codex-worker large-tasks/ --concurrency 8
# Automatically skips the 30 completed files# Use a specific OpenAI Codex CLI model
codex-worker --model o4
# Use different models for different task complexity
codex-worker simple-tasks/ --model o4-mini
codex-worker complex-tasks/ --model o4# Dry run - see what would be executed
codex-worker --mode dry-run
# Read-only (default) - agent can only read files
codex-worker --mode read-only
# Workspace write - agent can modify files in current directory
codex-worker --mode workspace-write
# Full access (DANGEROUS) - agent can modify any file
codex-worker --mode danger-full-access --yes# Check status of all tasks
codex-worker status
# Output:
# โโโโโโโโโโโโโโณโโโโโโโโณโโโโโโโโโโโโโ
# โ Status โ Count โ Percentage โ
# โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโซ
# โ Pending โ 45 โ 45.0% โ
# โ In Progress โ 5 โ 5.0% โ
# โ Completed โ 40 โ 40.0% โ
# โ Failed โ 10 โ 10.0% โ
# โ Total โ 100 โ 100.0% โ
# โโโโโโโโโโโโโโโดโโโโโโโโดโโโโโโโโโโโโโ
# Detailed file-by-file status
codex-worker status --detailed# Clean stale in-progress markers (process died)
codex-worker clean --max-age 3600
# Reset all states to rerun tasks
codex-worker reset --force- Task Discovery: Finds all matching files (e.g.,
*.md) - State Check: Checks file prefixes to determine status
- Lock Acquisition: Atomically acquires lock with
in-progress-prefix - Execution: Runs AI agent with configured settings
- State Update: Updates prefix to
done_exec_log-orfailed_exec_log- - Parallel Coordination: Multiple workers respect each other's locks
| Prefix | Meaning | Example |
|---|---|---|
| (none) | Pending task | fix-bug.md |
in-progress- |
Currently processing | in-progress-fix-bug.md |
done_exec_log- |
Successfully completed | done_exec_log-fix-bug.md.txt |
failed_exec_log- |
Failed execution | failed_exec_log-fix-bug.md.txt |
.lock- |
Temporary lock file | .lock-fix-bug.md |
- Read-only by default - Must explicitly enable write access
- Confirmation prompts - For dangerous operations
- Atomic operations - No partial states or race conditions
- Process monitoring - Detects and cleans up dead processes
- Graceful shutdown - Ctrl+C handled properly
- Comprehensive validation - All inputs validated with Typer
# Create bug report files
for i in {1..20}; do
echo "Fix bug #$i: Check the error in module$i.py" > bug-$i.md
done
# Fix all bugs in parallel with 5 workers
codex-worker bug-*.md --concurrency 5 --mode workspace-write# Generate review tasks for each PR file
git diff main --name-only | while read file; do
echo "Review and suggest improvements for $file" > review-$(basename $file).md
done
# Run reviews in parallel
codex-worker review-*.md --concurrency 10# Create test generation tasks
find src -name "*.py" | while read file; do
echo "Generate comprehensive tests for $file" > test-$(basename $file).md
done
# Generate all tests
codex-worker test-*.md --concurrency 8 --mode workspace-write# Create doc tasks
echo "Update README with new API endpoints" > doc-api.md
echo "Add examples to authentication guide" > doc-auth.md
echo "Document the new CLI commands" > doc-cli.md
# Process documentation updates
codex-worker doc-*.md --concurrency 3export CODEX_CMD=/path/to/codex # Custom codex binary