| name | codex-implement |
| description | Delegate complex implementation tasks to Codex. Use when user says codex implement, delegate implementation, or has a complex coding task. |
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
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.
1. Gather Requirements
From user, collect:
- What needs implementing
- Target file paths
- Constraints and patterns to follow
- Dependencies and interfaces
2. 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]
3. Update Status
Write pending to $AGENT_COLLAB_DIR/status
4. Trigger Codex
tmux send-keys -t 1 '$read-task' && sleep 0.5 && tmux send-keys -t 1 Enter Enter
5. Notify User
Tell user briefly that implementation was delegated to Codex.
6. 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.
7. 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/statustoidle