[TMUX MODE] Send plan to Codex via tmux file-based IPC. Only use when user explicitly runs /codex-plan-review command...
Send an implementation plan to Codex for critical analysis and validation.
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: 'review this plan with codex' and I'll use the MCP tool which works without tmux."
Do not proceed with the remaining steps if not in tmux.
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.
Ensure plan includes:
If no plan exists, help user create one first. If you just produced a plan, reuse it directly without re-asking. If plan mode is declined or you are not in plan mode, write a concise plan summary (5-10 bullets) before running this review. If you are in plan mode, do not finalize or present the plan yet. Delegate to Codex first, then integrate the feedback into the final plan and only then ask the user to proceed.
If the user explicitly says to skip plan review, do not run this skill.
Write to $AGENT_COLLAB_DIR/requests/task.md:
# Task Request for Codex
## Task Type: PLAN_REVIEW
## Timestamp
[Current timestamp]
## Plan Title
[Brief title]
## The Plan
[Full plan content]
## Review Questions
- Is this approach sound?
- Are there edge cases not considered?
- Is the architecture appropriate?
- Are there simpler alternatives?
- What are the risks?
## Specific Concerns
[Areas of uncertainty]
## Constraints
[Constraints to respect]
## Files to Read for Context
[List FULL ABSOLUTE paths of any files Codex should read to understand the codebase]
**NOTE: Codex runs in the same working directory and CAN read files directly.
Reference files by path rather than copying content.**
Write pending to $AGENT_COLLAB_DIR/status
tmux send-keys -t 1 '$read-task' && sleep 0.5 && tmux send-keys -t 1 Enter Enter
Tell user briefly that plan was sent to Codex for review and that you'll return with feedback before implementation. Do not ask the user to proceed yet.
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 3; done; echo "CODEX_COMPLETE"
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.
When poll completes, automatically:
$AGENT_COLLAB_DIR/responses/response.md$AGENT_COLLAB_DIR/status to idle