This directory provides Codex CLI integration for the Amplifier project, establishing dual-backend support alongside the existing Claude Code integration in .claude/.
Codex CLI is Anthropic's command-line interface for AI-powered development. Unlike Claude Code's VS Code-specific integration, Codex provides a standalone CLI experience with different architectural patterns:
- Hooks vs MCP Servers: Claude Code uses native hooks; Codex uses MCP (Model Context Protocol) servers
- Session Storage: Codex stores sessions in
~/.codex/; Claude Code uses internal VS Code storage - Configuration: Codex uses TOML format; Claude Code uses JSON
- Agent Execution: Codex uses
codex exec; Claude Code uses the Task tool
The wrapper script (amplify-codex.sh) provides a seamless experience similar to Claude Code's automatic hooks, handling session initialization and cleanup automatically. For advanced users, the session management tools can be invoked manually for fine-grained control.
.codex/
├── config.toml # Main Codex configuration file
├── README.md # This documentation
├── mcp_servers/ # MCP server implementations (replaces Claude Code hooks)
├── agents/ # Codex-compatible agent definitions
├── commands/ # Command implementations for Codex
└── tools/ # Helper scripts and utilities
Contains fully implemented Python-based MCP servers using FastMCP:
- session_manager/ - Replaces
SessionStart.pyandSessionStop.pyhooks - quality_checker/ - Replaces
PostToolUse.pyhook - transcript_saver/ - Replaces
PreCompact.pyhook - task_tracker/ - Provides task management capabilities (TodoWrite equivalent)
- web_research/ - Enables web search and content fetching (WebFetch equivalent)
Each MCP server is a self-contained module with its own directory and server script. Server logs are written to .codex/logs/.
Stores Codex-compatible agent definitions converted from .claude/agents/. Since Codex doesn't have Claude Code's Task tool, agents are executed via codex exec with appropriate context and instructions.
Houses command implementations for Codex. Since Codex doesn't have native slash commands like Claude Code (/architect, /review, etc.), this directory contains command scripts that can be invoked via MCP tools or wrapper scripts.
Contains Codex-specific automation tools and helper scripts including:
- Session initialization scripts
- Cleanup utilities
- Integration helpers for the existing
tools/codex_transcripts_builder.py
Amplifier provides bash shortcuts for common Codex workflows:
# Enable shortcuts (add to ~/.bashrc)
source .codex/tools/codex_shortcuts.sh
# Common commands
codex-init "Working on authentication" # Quick session initialization
codex-check src/auth.py # Run quality checks
codex-save # Save current transcript
codex-task-add "Implement login flow" # Create new task
codex-task-list # List current tasks
codex-search "authentication patterns" # Web search
codex-agent architect "Design API" # Spawn agent
codex-status # Show session statusThese shortcuts wrap MCP tool invocations for faster development workflows.
Codex uses MCP servers to provide functionality equivalent to Claude Code's hooks:
| Claude Code Hook | Codex MCP Server | Purpose |
|---|---|---|
SessionStart.py |
amplifier_session |
Initialize session context, set up workspace |
SessionStop.py |
amplifier_session |
Handle session cleanup |
PostToolUse.py |
amplifier_quality |
Run code quality checks after tool usage |
PreCompact.py |
amplifier_transcripts |
Save and manage session transcripts |
Claude Code: Uses the Task tool to spawn agents with context
<task>
Use the architect agent to analyze this codebase
</task>
Codex: Uses codex exec command with agent files
codex exec .codex/agents/architect.md --context="Analyze this codebase"Claude Code (.claude/settings.json):
{
"claude": {
"model": "claude-3-5-sonnet-20241022",
"maxTokens": 8192
},
"hooks": {
"enabled": true
}
}Codex (.codex/config.toml):
model = "claude-3-5-sonnet-20241022"
approval_policy = "on-request"
[mcp_servers.amplifier_session]
command = "uv"
args = ["run", "python", ".codex/mcp_servers/session_manager/server.py"]initialize_session - Load relevant memories (replaces SessionStart hook)
- Input:
{"prompt": str, "context": Optional[str]} - Output:
{"memories": [...], "metadata": {"memoriesLoaded": int, "source": "amplifier_memory"}} - Usage: Call at session start to provide context from previous work
finalize_session - Extract and store memories (replaces Stop/SubagentStop hooks)
- Input:
{"messages": List[dict], "context": Optional[str]} - Output:
{"metadata": {"memoriesExtracted": int, "source": "amplifier_extraction"}} - Usage: Call at session end to capture learnings
health_check - Verify server and memory system status
- Input:
{} - Output:
{"status": "healthy", "memory_enabled": bool, "modules_available": [...]} - Usage: Verify setup before using other tools
check_code_quality - Run make check (replaces PostToolUse hook)
- Input:
{"file_paths": List[str], "tool_name": Optional[str], "cwd": Optional[str]} - Output:
{"passed": bool, "output": str, "issues": [...], "metadata": {...}} - Usage: Call after editing files to validate changes
run_specific_checks - Run individual tools (ruff, pyright, pytest)
- Input:
{"check_type": str, "file_paths": Optional[List[str]], "args": Optional[List[str]]} - Output:
{"passed": bool, "output": str, "tool": str, "issues": [...]} - Usage: Run targeted checks (e.g., just linting or just tests)
validate_environment - Check development environment setup
- Input:
{} - Output:
{"valid": bool, "issues": [...], "environment": {...}} - Usage: Diagnose setup issues before running checks
save_current_transcript - Export current session (replaces PreCompact hook)
- Input:
{"session_id": Optional[str], "format": str = "both", "output_dir": Optional[str]} - Output:
{"exported_path": str, "metadata": {"file_size": int, "event_count": int}} - Usage: Save session before ending work
save_project_transcripts - Batch export project sessions
- Input:
{"project_dir": str, "format": str = "standard", "incremental": bool = True} - Output:
{"exported_sessions": [...], "skipped": [...], "metadata": {...}} - Usage: Bulk export for project documentation
list_available_sessions - Discover exportable sessions
- Input:
{"project_only": bool = False, "limit": int = 10} - Output:
{"sessions": [...], "total_count": int, "project_sessions": int} - Usage: Find sessions to export or analyze
convert_transcript_format - Convert between formats
- Input:
{"session_id": str, "from_format": str, "to_format": str, "output_path": Optional[str]} - Output:
{"converted_path": str, "metadata": {"original_format": str, "target_format": str}} - Usage: Standardize transcript formats for analysis
-
Install Codex CLI (follow Anthropic's installation guide)
-
MCP Server Status: All five MCP servers are implemented and ready to use. Profiles are configured with appropriate server combinations.
-
Profile Usage:
# Start Codex with development profile (all servers enabled) codex --profile development # Start with CI profile (quality checks only) codex --profile ci # Start with review profile (quality + transcripts) codex --profile review
- Use the
developmentprofile for full-featured development sessions - Enable
task_trackerfor project management workflows - Configure
web_researchcache settings for performance - Set appropriate timeouts for long-running operations
MCP servers are now fully implemented and integrated into Codex profiles. Each server provides specific functionality that replaces Claude Code hooks:
- Purpose: Memory system integration at session boundaries
- Tools:
initialize_session,finalize_session,health_check - Usage: Automatically loads context at session start and saves memories at end
- Purpose: Code quality validation after changes
- Tools:
check_code_quality,run_specific_checks,validate_environment - Usage: Run quality checks after editing files
- Purpose: Session transcript management and export
- Tools:
save_current_transcript,save_project_transcripts,list_available_sessions,convert_transcript_format - Usage: Export and manage session transcripts
Tools are invoked using natural language or direct tool calls:
# Load session context
codex> initialize_session with prompt "Working on user authentication"
# Check code quality
codex> check_code_quality with file_paths ["src/auth.py"]
# Save current transcript
codex> save_current_transcript with format "both"Servers are enabled per profile in config.toml:
- Development: All servers (
amplifier_session,amplifier_quality,amplifier_transcripts) - CI: Quality checks only (
amplifier_quality) - Review: Quality + transcripts (
amplifier_quality,amplifier_transcripts)
The configuration exposes essential environment variables:
PATH: System path for tool accessHOME: User home directoryAMPLIFIER_ROOT: Project root directoryVIRTUAL_ENV: Python virtual environmentCONDA_DEFAULT_ENV: Conda environment
Codex integration leverages the existing tools/codex_transcripts_builder.py for transcript handling:
- Global Transcripts: Stored in
~/.codex/transcripts/ - Project Transcripts: Optional local storage in
.codex/transcripts/ - Format Compatibility: Maintains compatibility with Claude Code transcript formats
- Builder Integration: Automatic integration with existing transcript builder
Future MCP server implementations will provide access to:
- Knowledge synthesis workflows (
amplifier/knowledge_synthesis/) - Memory systems (
amplifier/memory/) - Content loading and extraction (
amplifier/content_loader/,amplifier/extraction/)
Note: Knowledge system integration will be added in a later development phase.
The wrapper script automatically runs code quality checks after Codex exits, detecting modified files and validating changes before cleanup.
Background process saves transcripts every 10 minutes during long sessions, preventing data loss and enabling incremental backups.
Seamlessly pass conversation context to agents, enabling in-context agent spawning with full session awareness.
Automatically detects git branch, recent commits, and TODO comments to provide relevant context for new sessions.
Understanding the differences between Claude Code and Codex transcript formats is crucial for working with both backends effectively.
| Backend | Location | Format | Description |
|---|---|---|---|
| Claude Code | .data/transcripts/compact_YYYYMMDD_HHMMSS_<session-id>.txt |
Single text file | Project-local storage with compact format |
| Codex Global | ~/.codex/transcripts/YYYY-MM-DD-HH-MM-PM__<cwd>__<short-id>/ |
Directory per session | Global storage, all Codex sessions |
| Codex Local | .codex/transcripts/ |
Directory per session | Optional project-local storage |
Why the difference? Codex uses directories because each session generates multiple files (history, standard transcript, extended transcript, metadata), while Claude Code compacts everything into a single file.
.data/transcripts/
├── compact_20240101_100000_a1b2c3d4-e5f6-7890-abcd-ef1234567890.txt
├── compact_20240101_110000_f1e2d3c4-b5a6-9870-dcba-fe0987654321.txt
└── ...
~/.codex/transcripts/
├── 2024-01-01-10-00-AM__home-user-project__a1b2c3d4/
│ ├── history.jsonl # Raw history entries
│ ├── transcript.md # Conversation-focused markdown
│ ├── transcript_extended.md # Detailed markdown with all events
│ └── meta.json # Session metadata
├── 2024-01-01-11-00-AM__home-user-other__f1e2d3c4/
│ └── ...
Claude Code Format:
[USER]: Hello, can you help me analyze this code?
[ASSISTANT]: I'd be happy to help you analyze your code. Could you please share the code you'd like me to review?
[THINKING]: The user is asking for code analysis. I should ask them to provide the code first before I can help.
[TOOL USE: file_reader]
{
"path": "src/main.py"
}
[TOOL RESULT]
def main():
print("Hello, world!")
[ASSISTANT]: I can see your code is a simple "Hello, world!" program. Here's my analysis...
Codex Format (transcript.md):
- **User** · 2024-01-01 10:00:00
Hello, can you help me analyze this code?
- **Assistant** · 2024-01-01 10:00:01
I'd be happy to help you analyze your code. Could you please share the code you'd like me to review?
- **Assistant [thinking]** · 2024-01-01 10:00:02
The user is asking for code analysis. I should ask them to provide the code first before I can help.
- **Tool Call (file_reader)** · 2024-01-01 10:00:03
```json
{
"path": "src/main.py"
}-
Tool Result · 2024-01-01 10:00:04
def main(): print("Hello, world!")
-
Assistant · 2024-01-01 10:00:05 I can see your code is a simple "Hello, world!" program. Here's my analysis...
### Metadata Differences
#### Claude Code Header
```text
# Amplifier Claude Code Transcript Export
# Exported: 2024-01-01 12:00:00 PST
# Session ID: a1b2c3d4-e5f6-7890-abcd-ef1234567890
# Compact trigger: Auto-compact after 50 interactions
# Custom instructions: You are a helpful AI assistant for code analysis.
================================================================================
# Codex Session Transcript
**Session ID:** a1b2c3d4-e5f6-7890-abcd-ef1234567890
**Started:** 2024-01-01T10:00:00-08:00
**Working Directory:** /home/user/project
**Event Count:** 127
**Message Count:** 45
**Tool Usage Count:** 12
**Exported:** 2024-01-01T12:00:00-08:00
---| Backend | Session ID Format | Example | Location |
|---|---|---|---|
| Claude Code | Full UUID in filename | compact_20240101_100000_a1b2c3d4-e5f6-7890-abcd-ef1234567890.txt |
Filename |
| Codex | Short ID in directory, full in metadata | Directory: .../__a1b2c3d4/, Metadata: full UUID |
Directory name + metadata |
Implications:
- Claude Code: Direct lookup by full session ID in filename
- Codex: Requires directory scanning or metadata parsing for full session ID
- Export Timestamp: Single timestamp when transcript was exported
- Message Timestamps: Embedded in content as relative times or not at all
- Format: Local timezone, human-readable
- Per-Event Timestamps: Each event has precise timestamp
- Timezone Support: ISO 8601 format with timezone information
- Configurable Display: Can show in local time or UTC
Example Timestamp Formats:
# Claude Code
Exported: 2024-01-01 12:00:00 PST
# Codex
Started: 2024-01-01T10:00:00-08:00
Event: 2024-01-01T10:05:23.456789-08:00
[TOOL USE: file_reader]
{
"path": "test.py",
"lines": [1, 50]
}
[TOOL RESULT]
def function():
return "result"
# Content may be truncated...
- **Tool Call (file_reader)** · 2024-01-01 10:00:02
```json
{
"path": "test.py",
"lines": [1, 50],
"call_id": "call_abc123"
}- Tool Result · 2024-01-01 10:00:03
Call ID: call_abc123
def function(): return "result"
**Key Differences:**
- **Call Matching**: Codex uses `call_id` to match tool calls with results
- **Formatting**: Codex uses markdown code blocks with syntax highlighting
- **Metadata**: Codex includes additional metadata like call IDs and precise timestamps
### Duplicate Detection Mechanisms
#### Claude Code (hook_precompact.py)
- Detects embedded transcripts via session ID patterns in content
- Scans for file references and session IDs in export headers
- Marks sections as "previously loaded" to avoid re-processing
#### Codex
- Deduplicates user messages by normalized text + timestamp
- Uses session directory existence to skip already-processed sessions
- Tracks embedded transcript sections via metadata markers
**Example Detection Patterns:**
```text
# Claude Code looks for:
"Session ID: a1b2c3d4-e5f6-7890-abcd-ef1234567890"
"compact_20240101_100000_*.txt"
# Codex looks for:
"# Embedded Transcript: a1b2c3d4"
Directory: "2024-01-01-10-00-AM__*__a1b2c3d4/"
The enhanced tools/transcript_manager.py provides a unified interface for working with both transcript formats.
# List all transcripts from both backends
python tools/transcript_manager.py list
# List only Claude Code transcripts
python tools/transcript_manager.py list --backend claude
# List only Codex transcripts
python tools/transcript_manager.py list --backend codex
# Get JSON output with metadata
python tools/transcript_manager.py list --json# Load by session ID (works with both full and short IDs)
python tools/transcript_manager.py load a1b2c3d4
# Load by filename (Claude Code)
python tools/transcript_manager.py load compact_20240101_100000_session.txt
# Load Codex transcript with format preference
python tools/transcript_manager.py load a1b2c3d4 --format extended# Search in both backends
python tools/transcript_manager.py search "error handling"
# Search only in Codex transcripts
python tools/transcript_manager.py search "tool usage" --backend codex
# Search with context
python tools/transcript_manager.py search "function definition" --context 3# Convert Claude Code transcript to Codex format
python tools/transcript_manager.py convert claude-session-123 --from claude --to codex
# Convert Codex to Claude Code format
python tools/transcript_manager.py convert codex-session-456 --from codex --to claudeThe enhanced tools/codex_transcripts_builder.py now supports project filtering and robust error handling:
# Process all sessions (original behavior)
python tools/codex_transcripts_builder.py
# Process only sessions from current project
python tools/codex_transcripts_builder.py --project-dir .
# Process specific session
python tools/codex_transcripts_builder.py --session-id a1b2c3d4
# Incremental processing (skip already processed)
python tools/codex_transcripts_builder.py --incremental
# Skip errors and continue processing
python tools/codex_transcripts_builder.py --skip-errors --verbose
# Generate compact format
python tools/codex_transcripts_builder.py --output-format compactThe new .codex/tools/transcript_exporter.py provides Claude Code hook-like functionality:
# Export current session
python .codex/tools/transcript_exporter.py --current
# Export specific session
python .codex/tools/transcript_exporter.py --session-id a1b2c3d4
# Export all project sessions
python .codex/tools/transcript_exporter.py --project-only
# Export with different formats
python .codex/tools/transcript_exporter.py --current --format both
python .codex/tools/transcript_exporter.py --current --format compact
# Custom output directory
python .codex/tools/transcript_exporter.py --current --output-dir ./exportsUse tools/transcript_manager.py as a single interface for both backends:
# Restore complete conversation lineage from both backends
python tools/transcript_manager.py restore
# Restore only from specific backend
python tools/transcript_manager.py restore --backend codex
# Export current session (detects backend automatically)
python tools/transcript_manager.py export --current
# List with backend indicators
python tools/transcript_manager.py list --show-backend# 1. Start work - check recent sessions
python tools/transcript_manager.py list --last 5
# 2. Load context from recent session
python tools/transcript_manager.py load recent-session-id
# 3. During work - export current session periodically
python .codex/tools/transcript_exporter.py --current --output-dir .codex/transcripts
# 4. End of day - restore full lineage for review
python tools/transcript_manager.py restore > daily_summary.md# 1. Get all project-related sessions
python tools/codex_transcripts_builder.py --project-dir . --verbose
# 2. Search for specific topics across all transcripts
python tools/transcript_manager.py search "architecture decision"
python tools/transcript_manager.py search "bug fix" --context 2
# 3. Convert key insights to preferred format
python tools/transcript_manager.py convert key-session --to claude --output insights.txt# 1. List transcripts from old backend
python tools/transcript_manager.py list --backend claude --json > claude_inventory.json
# 2. Convert important sessions to new format
for session in important_sessions.txt; do
python tools/transcript_manager.py convert $session --from claude --to codex
done
# 3. Verify conversion
python tools/transcript_manager.py list --backend codexProblem: Can't find expected transcripts Solutions:
# Check both global and local locations
ls ~/.codex/transcripts/
ls .codex/transcripts/
ls .data/transcripts/
# Use transcript manager to scan all locations
python tools/transcript_manager.py list --backend auto --verbose
# Check if sessions exist but transcripts weren't generated
ls ~/.codex/sessions/
python tools/codex_transcripts_builder.py --session-id <id> --verboseProblem: Session ID doesn't match between systems Solutions:
# Use fuzzy matching (prefix search)
python tools/transcript_manager.py load a1b2c3 # Matches a1b2c3d4-e5f6-...
# List with session ID details
python tools/transcript_manager.py list --show-ids
# Check both short and full ID formats
grep -r "a1b2c3" ~/.codex/transcripts/
grep -r "a1b2c3d4-e5f6" .data/transcripts/Problem: Timestamps don't match expected times Solutions:
# Check timezone settings in Codex
python tools/codex_transcripts_builder.py --timezone "America/New_York"
# Convert existing transcripts to local timezone
python tools/transcript_manager.py convert session-id --timezone-convert local
# Check system timezone
date
echo $TZProblem: Transcripts are too large to process Solutions:
# Use compact format for large sessions
python tools/codex_transcripts_builder.py --output-format compact
# Split large transcripts by time
python tools/transcript_manager.py split large-session --by-date
# Search instead of loading full content
python tools/transcript_manager.py search "specific topic" --session large-session# Amplifier Claude Code Transcript Export
# Exported: 2024-01-01 12:00:00 PST
# Session ID: a1b2c3d4-e5f6-7890-abcd-ef1234567890
================================================================================
[USER]: I need help refactoring this Python function to be more efficient.
[ASSISTANT]: I'd be happy to help you refactor your Python function for better efficiency. Could you please share the function you'd like me to review?
[TOOL USE: file_reader]
{
"path": "src/utils.py",
"lines": [10, 25]
}
[TOOL RESULT]
def process_data(items):
result = []
for item in items:
if item.status == 'active':
processed = item.value * 2
result.append(processed)
return result
[ASSISTANT]: I can see your function processes a list of items. Here are some efficiency improvements...
# Codex Session Transcript
**Session ID:** a1b2c3d4-e5f6-7890-abcd-ef1234567890
**Started:** 2024-01-01T10:00:00-08:00
**Working Directory:** /home/user/amplifier-project
**Exported:** 2024-01-01T12:00:00-08:00
---
## Conversation
- **User** · 2024-01-01 10:00:00
I need help refactoring this Python function to be more efficient.
- **Assistant** · 2024-01-01 10:00:01
I'd be happy to help you refactor your Python function for better efficiency. Could you please share the function you'd like me to review?
- **Tool Call (file_reader)** · 2024-01-01 10:00:02
```json
{
"path": "src/utils.py",
"lines": [10, 25],
"call_id": "call_abc123"
}-
Tool Result · 2024-01-01 10:00:03 Call ID: call_abc123
def process_data(items): result = [] for item in items: if item.status == 'active': processed = item.value * 2 result.append(processed) return result
-
Assistant · 2024-01-01 10:00:04 I can see your function processes a list of items. Here are some efficiency improvements...
### Codex transcript_extended.md Excerpt
```markdown
# Codex Session Transcript (Extended)
**Session ID:** a1b2c3d4-e5f6-7890-abcd-ef1234567890
**Started:** 2024-01-01T10:00:00-08:00
**Event Count:** 127
**Message Count:** 45
**Tool Usage Count:** 12
---
## Raw Events
### Event 1 · 2024-01-01T10:00:00.123456-08:00
**Type:** user_message
**Source:** history
```json
{
"timestamp": "2024-01-01T10:00:00.123456-08:00",
"type": "user_message",
"content": {
"text": "I need help refactoring this Python function to be more efficient."
},
"metadata": {
"input_tokens": 156,
"context_window": 8192
}
}
Type: assistant_message Source: history
{
"timestamp": "2024-01-01T10:00:01.234567-08:00",
"type": "assistant_message",
"content": {
"text": "I'd be happy to help you refactor your Python function for better efficiency. Could you please share the function you'd like me to review?"
},
"metadata": {
"output_tokens": 234,
"reasoning_time_ms": 1250
}
}- Total Events: 127
- User Messages: 23
- Assistant Messages: 22
- Tool Calls: 12
- Tool Results: 12
- Thinking Blocks: 8
- Session Duration: 45 minutes
- Total Tokens: 12,543 (input: 8,231, output: 4,312)
These examples highlight the key visual and structural differences between the formats, helping users understand what to expect when working with each backend.
## Key Differences from Claude Code
**Current Parity**: 95% feature parity with Claude Code ([detailed comparison](../docs/tutorials/FEATURE_PARITY_MATRIX.md))
**What's New in Codex Integration**:
- ✅ Task tracking (TodoWrite equivalent)
- ✅ Web research capabilities (WebFetch equivalent)
- ✅ Enhanced automation (auto-checks, periodic saves)
- ✅ Agent context bridge for seamless agent spawning
- ✅ Command shortcuts for faster workflows
| Aspect | Claude Code | Codex |
|--------|-------------|-------|
| **Hooks** | Native Python hooks | MCP servers |
| **Commands** | Slash commands (`/architect`) | Natural language or MCP tools |
| **Sessions** | VS Code internal storage | `~/.codex/sessions/` |
| **Config** | JSON in `.claude/settings.json` | TOML in `.codex/config.toml` |
| **Agent Spawning** | Task tool | `codex exec` command |
| **Integration** | VS Code extension | Standalone CLI |
## Getting Started
### Prerequisites
- Codex CLI installed and configured
- Project dependencies installed (`make install`)
- Virtual environment activated
### Quick Start with Wrapper Script
> **New to Codex?** Check out our [5-minute quick start tutorial](../docs/tutorials/QUICK_START_CODEX.md) for a guided introduction.
The easiest way to get started with Codex and Amplifier is:
1. **Make the wrapper executable**:
```bash
chmod +x ../amplify-codex.sh
-
Start your first session:
../amplify-codex.sh
-
Use MCP tools during development:
initialize_session- Load relevant memoriescheck_code_quality- Run code quality checkssave_current_transcript- Export session transcripts
For detailed tutorials, see the tutorial index.
If you prefer to manage sessions manually:
# 1. Initialize session
uv run python .codex/tools/session_init.py --prompt "Working on feature X"
# 2. Start Codex
codex --profile development
# 3. Use MCP tools during session
# - initialize_session (if not run manually)
# - check_code_quality after changes
# - save_current_transcript before ending
# - finalize_session to save memories
# 4. Clean up after session
uv run python .codex/tools/session_cleanup.pyAmplifier provides standalone tools for session initialization and cleanup:
Loads relevant memories before starting a Codex session.
Usage:
# Basic usage (uses default context)
uv run python .codex/tools/session_init.py
# With specific context
uv run python .codex/tools/session_init.py --prompt "Refactoring authentication module"
# Custom output location
uv run python .codex/tools/session_init.py --output ./my_context.md
# Verbose logging
uv run python .codex/tools/session_init.py --verboseOutput:
.codex/session_context.md- Formatted memories for reference.codex/session_init_metadata.json- Metadata for programmatic access.codex/logs/session_init.log- Detailed logs
Environment Variables:
MEMORY_SYSTEM_ENABLED- Enable/disable memory loading (default: true)CODEX_SESSION_CONTEXT- Default context if no --prompt provided
Extracts memories and exports transcript after a Codex session.
Usage:
# Basic usage (auto-detects latest session)
uv run python .codex/tools/session_cleanup.py
# Specific session
uv run python .codex/tools/session_cleanup.py --session-id a1b2c3d4
# Skip memory extraction
uv run python .codex/tools/session_cleanup.py --no-memory
# Custom transcript format
uv run python .codex/tools/session_cleanup.py --format extended
# Verbose logging
uv run python .codex/tools/session_cleanup.py --verboseOutput:
.codex/transcripts/<session-dir>/- Exported transcript files.codex/session_cleanup_metadata.json- Cleanup metadata.codex/logs/session_cleanup.log- Detailed logs- Updated memory store in
.data/memories/
Environment Variables:
MEMORY_SYSTEM_ENABLED- Enable/disable memory extraction (default: true)CODEX_SESSION_ID- Session to process if not provided via --session-id
Orchestrates session initialization, Codex execution, and cleanup.
Usage:
# Basic usage
./amplify-codex.sh
# With specific profile
./amplify-codex.sh --profile ci
# Skip initialization
./amplify-codex.sh --no-init
# Skip cleanup
./amplify-codex.sh --no-cleanup
# Show help
./amplify-codex.sh --helpFeatures:
- Validates prerequisites (Codex CLI, uv, virtual environment)
- Runs session_init.py before starting Codex
- Displays user guidance with available MCP tools
- Runs session_cleanup.py after Codex exits
- Handles errors gracefully with clear messages
- Logs all operations for debugging
Environment Variables:
AMPLIFIER_BACKEND- Set to "codex" (automatically set by wrapper)CODEX_PROFILE- Profile to use (default: development)MEMORY_SYSTEM_ENABLED- Enable/disable memory system (default: true)
MCP Server Connection Issues:
- Verify Python environment:
uv run python --version - Check server script paths in
config.toml - Review server logs in
.codex/logs/ - Ensure amplifier modules are importable
Server-Specific Issues:
- Session Manager: Check
MEMORY_SYSTEM_ENABLEDenvironment variable - Quality Checker: Verify
Makefileexists and haschecktarget - Transcript Saver: Ensure transcript export tools are available
Environment Variable Problems:
- Ensure
AMPLIFIER_ROOTis set correctly - Verify virtual environment activation
- Check
env_allowsection inconfig.toml
Agent Execution Failures:
- Confirm agent files exist in
.codex/agents/ - Verify execution timeout settings
- Check working directory configuration
Viewing Server Logs:
# View all server logs
tail -f .codex/logs/*.log
# View specific server log
tail -f .codex/logs/session_manager.logsession_init.py fails:
- Check memory system is enabled:
echo $MEMORY_SYSTEM_ENABLED - Verify memory data exists:
ls .data/memories/ - Check logs:
cat .codex/logs/session_init.log - Run with --verbose for detailed output
session_cleanup.py can't find session:
- Check Codex session directory:
ls ~/.codex/sessions/ - Provide explicit session ID:
--session-id <id> - Verify session has history.jsonl file
- Check logs:
cat .codex/logs/session_cleanup.log
Wrapper script issues:
- Ensure script is executable:
chmod +x amplify-codex.sh - Check Codex is installed:
codex --version - Verify uv is available:
uv --version - Check virtual environment:
ls .venv/ - Review wrapper output for specific error messages
Memory extraction timeout:
- Large sessions may timeout (60 second limit)
- Run cleanup manually with --no-memory to skip extraction
- Process session in smaller chunks if possible
- Check for memory system performance issues
Phase 3 (MCP servers) is now complete. Subsequent phases will implement:
- Wrapper scripts for enhanced CLI integration
- Backend abstraction layer for unified API
- Agent migration from Claude Code to Codex
- Advanced cross-backend features
- Server Startup: Typically <1 second with FastMCP
- Tool Invocation: Minimal overhead for MCP protocol
- Memory System: Performance depends on dataset size
- Quality Checks: Run only when needed to avoid delays
- Start Codex with review profile
- Invoke
check_code_qualityafter changes - Invoke
save_current_transcriptfor documentation - Review combined quality report and transcript
- Start new session with
initialize_session - Work on tasks
- End session with
finalize_sessionto save context - Next session loads relevant memories automatically
- Use
list_available_sessionsto find project sessions - Invoke
save_project_transcriptsfor bulk export - Use
convert_transcript_formatfor standardization
# Start session with wrapper
./amplify-codex.sh --profile development
# Wrapper automatically:
# 1. Loads 5 relevant memories
# 2. Starts Codex with all MCP servers
# 3. Displays tool guidance
# During session, use MCP tools:
codex> check_code_quality with file_paths ["src/auth.py"]
codex> save_current_transcript with format "both"
# Exit Codex (Ctrl+D or exit command)
# Wrapper automatically:
# 1. Extracts memories from session
# 2. Exports transcript to .codex/transcripts/
# 3. Displays summaryFollowing the project's core philosophy from AGENTS.md:
- Minimal Intrusion: All Codex integration stays within
.codex/directory - Cross-platform Compatibility: Works on Windows, macOS, and Linux
- Fail Gracefully: Degrades gracefully when MCP servers are unavailable
- User Control: Extensive configuration options and profile support
- Interoperability: Maintains compatibility with existing Claude Code workflows
New User: Quick Start (5 min) → Beginner Guide (30 min) → Troubleshooting
Migrating from Claude Code: Feature Parity Matrix → Workflow Diagrams
Advanced User: Workflow Diagrams → Backend Comparison
- Quick Start Tutorial
- Complete Beginner Guide
- Visual Workflow Diagrams
- Feature Parity Matrix
- Troubleshooting Decision Tree
- Tutorial Index
AGENTS.md- AI Assistant guidance and sub-agent optimizationtools/codex_transcripts_builder.py- Existing Codex transcript integration.claude/README.md- Claude Code integration documentationdocs/- Additional project documentation
For questions or issues with Codex integration, refer to the project's main documentation or create an issue in the repository.