Coding Agent (background-first)
Use bash background mode for non-interactive coding work. For interactive coding sessions, use the tmux skill (always, except very simple one-shot prompts).
The Pattern: workdir + background
CODEBLOCK0
Why workdir matters: Agent wakes up in a focused directory, doesn't wander off reading unrelated files (like your soul.md 😅).
Codex CLI
Model: gpt-5.2-codex is the default (set in ~/.codex/config.toml)
Building/Creating (use --full-auto or --yolo)
CODEBLOCK1
Reviewing PRs (vanilla, no flags)
⚠️ CRITICAL: Never review PRs in Clawdbot's own project folder!
- - Either use the project where the PR is submitted (if it's NOT ~/Projects/clawdbot)
- Or clone to a temp folder first
CODEBLOCK2
Why? Checking out branches in the running Clawdbot repo can break the live instance!
Batch PR Reviews (parallel army!)
CODEBLOCK3
Tips for PR Reviews
- - Fetch refs first: INLINECODE1
- Use git diff: Tell Codex to use INLINECODE2
- Don't checkout: Multiple parallel reviews = don't let them change branches
- Post results: Use
gh pr comment to post reviews to GitHub
Claude Code
CODEBLOCK4
OpenCode
CODEBLOCK5
Pi Coding Agent
CODEBLOCK6
Pi flags (common)
- -
--print / -p: non-interactive; runs prompt and exits. - INLINECODE6 : pick provider (default: google).
- INLINECODE7 : pick model (default: gemini-2.5-flash).
- INLINECODE8 : override API key (defaults to env vars).
Examples:
CODEBLOCK7
tmux (interactive sessions)
Use the tmux skill for interactive coding sessions (always, except very simple one-shot prompts). Prefer bash background mode for non-interactive runs.
Parallel Issue Fixing with git worktrees + tmux
For fixing multiple issues in parallel, use git worktrees (isolated branches) + tmux sessions:
CODEBLOCK8
Why worktrees? Each Codex works in isolated branch, no conflicts. Can run 5+ parallel fixes!
Why tmux over bash background? Codex is interactive — needs TTY for proper output. tmux provides persistent sessions with full history capture.
⚠️ Rules
- 1. Respect tool choice — if user asks for Codex, use Codex. NEVER offer to build it yourself!
- Be patient — don't kill sessions because they're "slow"
- Monitor with process:log — check progress without interfering
- --full-auto for building — auto-approves changes
- vanilla for reviewing — no special flags needed
- Parallel is OK — run many Codex processes at once for batch work
- NEVER start Codex in ~/clawd/ — it'll read your soul docs and get weird ideas about the org chart! Use the target project dir or /tmp for blank slate chats
- NEVER checkout branches in ~/Projects/clawdbot/ — that's the LIVE Clawdbot instance! Clone to /tmp or use git worktree for PR reviews
PR Template (The Razor Standard)
When submitting PRs to external repos, use this format for quality & maintainer-friendliness:
INLINECODE9
Key principles:
- 1. Human-written description (no AI slop)
- Feature intent for maintainers
- Timestamped prompt history
- Session logs if using Codex/agent
Example: https://github.com/steipete/bird/pull/22
技能名称: giga-coding-agent
详细描述:
编码代理(优先使用后台模式)
对于非交互式编码工作,请使用 bash 后台模式。对于交互式编码会话,请使用 tmux 技能(始终如此,除非是非常简单的一次性提示)。
模式:工作目录 + 后台
bash
为聊天/临时工作创建临时空间
SCRATCH=$(mktemp -d)
在目标目录中启动代理(小盒子——只看到相关文件)
bash workdir:$SCRATCH background:true command:<代理命令>
或者用于项目工作:
bash workdir:~/project/folder background:true command:<代理命令>
返回 sessionId 用于跟踪
监控进度
process action:log sessionId:XXX
检查是否完成
process action:poll sessionId:XXX
发送输入(如果代理提问)
process action:write sessionId:XXX data:y
如果需要则终止
process action:kill sessionId:XXX
为什么工作目录很重要: 代理在指定的目录中启动,不会乱跑读取不相关的文件(比如你的 soul.md 😅)。
Codex CLI
模型: gpt-5.2-codex 是默认模型(在 ~/.codex/config.toml 中设置)
构建/创建(使用 --full-auto 或 --yolo)
bash
--full-auto:沙盒化但在工作空间中自动批准
bash workdir:~/project background:true command:codex exec --full-auto \构建一个暗色主题的贪吃蛇游戏\
--yolo:无沙盒,无批准(最快,最危险)
bash workdir:~/project background:true command:codex --yolo \构建一个暗色主题的贪吃蛇游戏\
注意:--yolo 是 --dangerously-bypass-approvals-and-sandbox 的快捷方式
审查 PR(普通模式,无标志)
⚠️ 关键:切勿在 Clawdbot 自己的项目文件夹中审查 PR!
- - 要么使用提交 PR 的项目(如果不是 ~/Projects/clawdbot)
- 要么先克隆到临时文件夹
bash
选项 1:在实际项目中审查(如果不是 clawdbot)
bash workdir:~/Projects/some-other-repo background:true command:codex review --base main
选项 2:克隆到临时文件夹进行安全审查(clawdbot 的 PR 必须这样做!)
REVIEW_DIR=$(mktemp -d)
git clone https://github.com/clawdbot/clawdbot.git $REVIEW_DIR
cd $REVIEW_DIR && gh pr checkout 130
bash workdir:$REVIEW_DIR background:true command:codex review --base origin/main
清理:rm -rf $REVIEW_DIR
选项 3:使用 git worktree(保持主分支不变)
git worktree add /tmp/pr-130-review pr-130-branch
bash workdir:/tmp/pr-130-review background:true command:codex review --base main
为什么? 在正在运行的 Clawdbot 仓库中检出分支可能会破坏实时实例!
批量 PR 审查(并行大军!)
bash
首先获取所有 PR 引用
git fetch origin +refs/pull/
/head:refs/remotes/origin/pr/
部署大军——每个 PR 一个 Codex!
bash workdir:~/project background:true command:codex exec \审查 PR #86。git diff origin/main...origin/pr/86\
bash workdir:~/project background:true command:codex exec \审查 PR #87。git diff origin/main...origin/pr/87\
bash workdir:~/project background:true command:codex exec \审查 PR #95。git diff origin/main...origin/pr/95\
... 对所有 PR 重复
监控所有
process action:list
获取结果并发布到 GitHub
process action:log sessionId:XXX
gh pr comment
--body <审查内容>
PR 审查技巧
- - 首先获取引用: git fetch origin +refs/pull//head:refs/remotes/origin/pr/
- 使用 git diff: 告诉 Codex 使用 git diff origin/main...origin/pr/XX
- 不要检出: 多个并行审查 = 不要让它们切换分支
- 发布结果: 使用 gh pr comment 将审查发布到 GitHub
Claude Code
bash
bash workdir:~/project background:true command:claude \你的任务\
OpenCode
bash
bash workdir:~/project background:true command:opencode run \你的任务\
Pi 编码代理
bash
安装:npm install -g @mariozechner/pi-coding-agent
bash workdir:~/project background:true command:pi \你的任务\
Pi 标志(常用)
- - --print / -p:非交互式;运行提示后退出。
- --provider :选择提供商(默认:google)。
- --model :选择模型(默认:gemini-2.5-flash)。
- --api-key :覆盖 API 密钥(默认使用环境变量)。
示例:
bash
设置提供商 + 模型,非交互式
bash workdir:~/project background:true command:pi --provider openai --model gpt-4o-mini -p \总结 src/\
tmux(交互式会话)
对于交互式编码会话,请使用 tmux 技能(始终如此,除非是非常简单的一次性提示)。对于非交互式运行,优先使用 bash 后台模式。
使用 git worktrees + tmux 并行修复问题
为了并行修复多个问题,请使用 git worktrees(隔离分支)+ tmux 会话:
bash
1. 将仓库克隆到临时位置
cd /tmp && git clone git@github.com:user/repo.git repo-worktrees
cd repo-worktrees
2. 为每个问题创建工作树(隔离分支!)
git worktree add -b fix/issue-78 /tmp/issue-78 main
git worktree add -b fix/issue-99 /tmp/issue-99 main
3. 设置 tmux 会话
SOCKET=${TMPDIR:-/tmp}/codex-fixes.sock
tmux -S $SOCKET new-session -d -s fix-78
tmux -S $SOCKET new-session -d -s fix-99
4. 在每个中启动 Codex(在 pnpm install 之后!)
tmux -S $SOCKET send-keys -t fix-78 cd /tmp/issue-78 && pnpm install && codex --yolo 修复问题 #78:<描述>。提交并推送。 Enter
tmux -S $SOCKET send-keys -t fix-99 cd /tmp/issue-99 && pnpm install && codex --yolo 修复问题 #99:<描述>。提交并推送。 Enter
5. 监控进度
tmux -S $SOCKET capture-pane -p -t fix-78 -S -30
tmux -S $SOCKET capture-pane -p -t fix-99 -S -30
6. 检查是否完成(提示返回)
tmux -S $SOCKET capture-pane -p -t fix-78 -S -3 | grep -q ❯ && echo 完成!
7. 修复后创建 PR
cd /tmp/issue-78 && git push -u origin fix/issue-78
gh pr create --repo user/repo --head fix/issue-78 --title 修复:... --body ...
8. 清理
tmux -S $SOCKET kill-server
git worktree remove /tmp/issue-78
git worktree remove /tmp/issue-99
为什么使用工作树? 每个 Codex 在隔离分支中工作,没有冲突。可以同时运行 5 个以上的并行修复!
为什么使用 tmux 而不是 bash 后台? Codex 是交互式的——需要 TTY 才能正确输出。tmux 提供持久会话,具有完整的历史捕获功能。
⚠️ 规则
- 1. 尊重工具选择——如果用户要求使用 Codex,就使用 Codex。切勿主动提出自己构建!
- 保持耐心——不要因为会话“慢”就终止它们
- 使用 process:log 监控——在不干扰的情况下检查进度
- 构建时使用 --full-auto——自动批准更改
- 审查时使用普通模式——不需要特殊标志
- 并行是可以的——一次运行多个 Codex 进程