codex-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCodex Review via Tmux
通过Tmux进行Codex代码审查
Overview
概述
Launch OpenAI's Codex CLI in a tmux session and run the command to get a code review of uncommitted changes. The skill handles the full lifecycle: setup, command execution, waiting for completion (up to 60 minutes), capturing output, and cleanup.
/review在tmux会话中启动OpenAI的Codex CLI,运行/review命令以获取对未提交代码变更的审查。该工具会处理完整生命周期:设置、命令执行、等待完成(最长60分钟)、捕获输出以及清理。
Prerequisites
前提条件
Before running, verify:
- is installed and available
tmux - CLI is installed and available
codex
运行前,请确认:
- 已安装并可正常使用
tmux - CLI 已安装并可正常使用
codex
The Process
操作流程
Step 1: Setup Tmux Session
步骤1:设置Tmux会话
bash
SOCKET="${TMPDIR:-/tmp}/codex-review-$$.sock"
SESSION="codex-review-$$"
tmux -S "$SOCKET" new-session -d -s "$SESSION"bash
SOCKET="${TMPDIR:-/tmp}/codex-review-$$.sock"
SESSION="codex-review-$$"
tmux -S "$SOCKET" new-session -d -s "$SESSION"Step 2: Launch Codex and Send Commands
步骤2:启动Codex并发送命令
bash
undefinedbash
undefinedLaunch codex
Launch codex
tmux -S "$SOCKET" send-keys -t "$SESSION" "codex" Enter
tmux -S "$SOCKET" send-keys -t "$SESSION" "codex" Enter
Wait for codex to initialize
Wait for codex to initialize
sleep 5
sleep 5
Type /review command
Type /review command
tmux -S "$SOCKET" send-keys -t "$SESSION" -l "/review"
tmux -S "$SOCKET" send-keys -t "$SESSION" -l "/review"
Press Enter to execute the /review command
Press Enter to execute the /review command
tmux -S "$SOCKET" send-keys -t "$SESSION" Enter
tmux -S "$SOCKET" send-keys -t "$SESSION" Enter
Wait for menu to appear
Wait for menu to appear
sleep 2
sleep 2
Select option 2: Review uncommitted changes (no Enter needed)
Select option 2: Review uncommitted changes (no Enter needed)
tmux -S "$SOCKET" send-keys -t "$SESSION" -l "2"
undefinedtmux -S "$SOCKET" send-keys -t "$SESSION" -l "2"
undefinedStep 3: Wait for Completion
步骤3:等待完成
Poll every 60 seconds for up to 60 minutes:
bash
wait_for_completion() {
local timeout=3600 interval=60 elapsed=0
while [ $elapsed -lt $timeout ]; do
output=$(tmux -S "$SOCKET" capture-pane -p -t "$SESSION" -S -100)
# Check for completion (shell prompt returned)
if echo "$output" | grep -qE '(❯|\$|>>>)\s*$'; then
return 0
fi
sleep $interval
elapsed=$((elapsed + interval))
done
return 1
}
wait_for_completion每隔60秒轮询一次,最长等待60分钟:
bash
wait_for_completion() {
local timeout=3600 interval=60 elapsed=0
while [ $elapsed -lt $timeout ]; do
output=$(tmux -S "$SOCKET" capture-pane -p -t "$SESSION" -S -100)
# Check for completion (shell prompt returned)
if echo "$output" | grep -qE '(❯|\$|>>>)\s*$'; then
return 0
fi
sleep $interval
elapsed=$((elapsed + interval))
done
return 1
}
wait_for_completionStep 4: Capture Output
步骤4:捕获输出
bash
undefinedbash
undefinedCapture full pane output (last 500 lines)
Capture full pane output (last 500 lines)
tmux -S "$SOCKET" capture-pane -p -t "$SESSION" -S -500
undefinedtmux -S "$SOCKET" capture-pane -p -t "$SESSION" -S -500
undefinedStep 5: Cleanup
步骤5:清理
bash
tmux -S "$SOCKET" kill-session -t "$SESSION"
rm -f "$SOCKET"bash
tmux -S "$SOCKET" kill-session -t "$SESSION"
rm -f "$SOCKET"To Monitor Manually
手动监控方法
If you want to watch the session while it runs:
bash
tmux -S "$SOCKET" attach -t "$SESSION"Detach with .
Ctrl+b d如果你想在运行时查看会话:
bash
tmux -S "$SOCKET" attach -t "$SESSION"使用断开连接。
Ctrl+b dSuccess Criteria
成功标准
- Codex review output is captured and displayed
- Tmux session is cleaned up
- No orphaned processes or sockets
- 已捕获并展示Codex审查输出
- Tmux会话已清理完成
- 无孤立进程或套接字残留