| name | codex-implement |
| description | [TMUX MODE] Delegate implementation to Codex via tmux file-based IPC. Only use when user explicitly runs /codex-implement command. For natural language requests, use the delegate_codex_implement MCP tool instead. |
Codex Implement Skill
Delegate complex implementation tasks to the Codex agent for high-quality code.
When to Use
- Complex multi-file implementations
- Algorithms requiring careful design
- User explicitly wants Codex to implement
Steps
0. Check for Tmux
First, verify we're running in tmux. Run this check:
[ -n "$TMUX" ] && echo "TMUX_OK" || echo "NOT_IN_TMUX"
If NOT_IN_TMUX: Stop immediately and tell the user:
"This skill requires tmux dual-pane mode. You're not in tmux.
Instead, just ask me naturally: 'implement this with codex' and I'll use the MCP tool which works without tmux."
Do not proceed with the remaining steps if not in tmux.
1. Resolve .agent-collab Directory
Before any file operations, resolve the .agent-collab directory so commands work outside the project root:
AGENT_COLLAB_DIR="${AGENT_COLLAB_DIR:-}"
if [ -n "$AGENT_COLLAB_DIR" ]; then
if [ -d "$AGENT_COLLAB_DIR/.agent-collab" ]; then
AGENT_COLLAB_DIR="$AGENT_COLLAB_DIR/.agent-collab"
elif [ ! -d "$AGENT_COLLAB_DIR" ]; then
AGENT_COLLAB_DIR=""
fi
fi
if [ -z "$AGENT_COLLAB_DIR" ]; then
AGENT_COLLAB_DIR="$(pwd)"
while [ "$AGENT_COLLAB_DIR" != "/" ] && [ ! -d "$AGENT_COLLAB_DIR/.agent-collab" ]; do
AGENT_COLLAB_DIR="$(dirname "$AGENT_COLLAB_DIR")"
done
AGENT_COLLAB_DIR="$AGENT_COLLAB_DIR/.agent-collab"
fi
If $AGENT_COLLAB_DIR does not exist, stop and ask for the project root.
2. Gather Requirements
From user, collect:
- What needs implementing
- Target file paths
- Constraints and patterns to follow
- Dependencies and interfaces
3. Create Implementation Spec
Write to $AGENT_COLLAB_DIR/requests/task.md:
# Task Request for Codex
## Task Type: IMPLEMENT
## Timestamp
[Current timestamp]
## Implementation Request
[Detailed description]
## Target Files
- Primary: [FULL ABSOLUTE path, e.g. /Users/antor/project/src/feature.cpp]
- Secondary: [supporting file paths]
## Requirements
1. [Requirement 1]
2. [Requirement 2]
...
## Interfaces & Contracts
[Interfaces the code must satisfy]
## Context Files to Read
[List FULL ABSOLUTE paths of existing files Codex should read for context]
**NOTE: Codex runs in the same working directory and CAN read files directly.
Do NOT copy file contents here. Just list paths and Codex will read them.**
## Patterns to Follow
[Reference existing patterns by file path]
## Constraints
- [List constraints]
4. Update Status
Write pending to $AGENT_COLLAB_DIR/status
5. Trigger Codex
tmux send-keys -t 1 '$read-task' && sleep 0.5 && tmux send-keys -t 1 Enter Enter
6. Notify User
Tell user briefly that implementation was delegated to Codex.
7. Wait for Codex (Background Polling)
Start a background polling loop to wait for Codex to complete. Run this EXACT bash command (with $AGENT_COLLAB_DIR/status) using the Bash tool with run_in_background: true:
while [ "$(cat "$AGENT_COLLAB_DIR/status")" != "done" ]; do sleep 5; done; echo "CODEX_COMPLETE"
Note: Use 5 second intervals since implementations take longer.
CRITICAL: Use the resolved $AGENT_COLLAB_DIR/status path so polling works outside the project root. Use background execution so you can continue helping the user while waiting.
8. Auto-Read Response
When poll completes, automatically:
- Read
$AGENT_COLLAB_DIR/responses/response.md
- Present the implementation to user
- Ask if user wants to integrate the code
- Reset
$AGENT_COLLAB_DIR/status to idle