← 返回
开发者工具 中文

Coding Sessions

Run long-lived AI coding agents (Codex CLI, Claude Code, Ralph loops) in persistent tmux sessions with completion hooks and automatic monitoring. Use when la...
在持久化的tmux会话中运行长时间AI编程代理(Codex CLI、Claude Code、Ralph循环),配备完成钩子和自动监控功能。适用于...
luke-deltadesk
开发者工具 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 734
下载
💾 11
安装
1
版本
#latest

概述

Coding Sessions

Orchestrate long-running AI coding agents in persistent tmux sessions with completion notifications and health monitoring.

Why tmux?

Background exec processes die on gateway restart. Any coding agent expected to run >5 minutes MUST run inside tmux. This is non-negotiable.

Always use the stable socket (~/.tmux/sock) — the default /tmp socket gets reaped by macOS.

Quick Start

Single Codex Task

tmux -S ~/.tmux/sock new -d -s <name> "cd <project-dir> && \
  PATH=/opt/homebrew/bin:\$PATH codex exec --full-auto '<task description>'; \
  EXIT_CODE=\$?; echo 'EXITED:' \$EXIT_CODE; \
  openclaw system event --text '<name> finished (exit \$EXIT_CODE) in <project-dir>' --mode now; \
  sleep 999999"

Ralph Loop (preferred for multi-step work)

tmux -S ~/.tmux/sock new -d -s <name> "cd <project-dir> && \
  PATH=/opt/homebrew/bin:\$PATH ralphy --codex --prd PRD.md; \
  EXIT_CODE=\$?; echo 'EXITED:' \$EXIT_CODE; \
  openclaw system event --text 'Ralph loop <name> finished (exit \$EXIT_CODE) in <project-dir>' --mode now; \
  sleep 999999"

Parallel Ralph Loops

tmux -S ~/.tmux/sock new -d -s <name> "cd <project-dir> && \
  PATH=/opt/homebrew/bin:\$PATH ralphy --codex --parallel --prd PRD.md; \
  EXIT_CODE=\$?; echo 'EXITED:' \$EXIT_CODE; \
  openclaw system event --text 'Ralph parallel <name> finished (exit \$EXIT_CODE)' --mode now; \
  sleep 999999"

Command Anatomy

Every tmux coding session follows this pattern:

  1. Stable socket: -S ~/.tmux/sock (survives macOS /tmp cleanup)
  2. Named session: -s (human-readable, used for monitoring)
  3. PATH fix: PATH=/opt/homebrew/bin:$PATH (Ralph/Codex need Homebrew binaries)
  4. The agent command: codex exec --full-auto or ralphy --codex
  5. Completion hook: Captures exit code, fires openclaw system event for instant notification
  6. Sleep tail: sleep 999999 keeps the shell alive so output remains readable

Monitoring

# List all sessions
tmux -S ~/.tmux/sock list-sessions

# Check recent output
tmux -S ~/.tmux/sock capture-pane -t <name> -p | tail -20

# Check if session exists
tmux -S ~/.tmux/sock has-session -t <name> 2>/dev/null && echo "alive" || echo "dead"

# Kill a completed session
tmux -S ~/.tmux/sock kill-session -t <name>

When to Use Ralph vs Raw Codex

ScenarioTool
----------------
Multi-step feature with PRD/checklistralphy --codex --prd PRD.md
Task that has stalled or failed beforeralphy --codex (auto-retry with fresh context)
Parallel independent tasksralphy --codex --parallel --prd PRD.md
Tiny focused fix, one-file changecodex exec --full-auto
Exploratory work, investigationcodex exec --full-auto

PRD Format

Ralph tracks completion via markdown checklists:

## Tasks
- [ ] Create the API endpoint
- [ ] Add input validation
- [ ] Write tests
- [x] Already done (skipped by Ralph)

Ralph restarts the agent with fresh context each iteration. The agent picks up where it left off via files + git history. Include test-first instructions in task prompts for deterministic validation.

Post-Completion Verification

Before declaring success or failure, always check:

  1. git log --oneline -3 — did the agent commit?
  2. git diff --stat — uncommitted changes?
  3. Read the tmux pane output — what actually happened?

Ralph can mark PRD tasks as done even when codex fails silently. Verify via git, not PRD checkboxes.

Logging

After starting any long-running session, log it in daily notes (memory/YYYY-MM-DD.md) under "Active Long-Running Processes" with the session name and original command. This ensures context survives compaction and heartbeat monitoring can track/restart sessions.

Troubleshooting

  • "Failed to refresh token" in ~/.codex/log/codex-tui.log → run codex auth login
  • Agent reads files and exits → wrap in Ralph loop (auto-retry solves this)
  • API rate limits (429s) with parallel agents → reduce parallelism or stagger starts
  • Session died → restart with same command from daily notes

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 11:13 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 66 📥 179,953
developer-tools

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 921 📥 185,757
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 668 📥 323,916