coding-agent by aaaaqwq/agi-super-skills
npx skills add https://github.com/aaaaqwq/agi-super-skills --skill coding-agent使用 bash(可选后台模式)处理所有编码代理工作。简单高效。
编码代理(Codex、Claude Code、Pi)是交互式终端应用程序,需要伪终端(PTY)才能正常工作。没有 PTY,你会得到损坏的输出、丢失颜色,或者代理可能挂起。
运行编码代理时始终使用 pty:true:
# ✅ 正确 - 使用 PTY
bash pty:true command:"codex exec '你的提示词'"
# ❌ 错误 - 没有 PTY,代理可能崩溃
bash command:"codex exec '你的提示词'"
| 参数 | 类型 | 描述 |
|---|---|---|
command | 字符串 | 要运行的 shell 命令 |
pty | 布尔值 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 用于编码代理! 为交互式 CLI 分配伪终端 |
workdir | 字符串 | 工作目录(代理只能看到此文件夹的上下文) |
background | 布尔值 | 在后台运行,返回 sessionId 用于监控 |
timeout | 数字 | 超时时间(秒),到期时终止进程 |
elevated | 布尔值 | 在主机上运行而非沙箱(如果允许) |
| 操作 | 描述 |
|---|---|
list | 列出所有运行中/最近的会话 |
poll | 检查会话是否仍在运行 |
log | 获取会话输出(可选偏移量/限制) |
write | 向 stdin 发送原始数据 |
submit | 发送数据 + 换行符(类似输入并按下 Enter) |
send-keys | 发送键令牌或十六进制字节 |
paste | 粘贴文本(可选括号模式) |
kill | 终止会话 |
对于快速提示/聊天,创建一个临时 git 仓库并运行:
# 快速聊天(Codex 需要 git 仓库!)
SCRATCH=$(mktemp -d) && cd $SCRATCH && git init && codex exec "你的提示词"
# 或者在真实项目中 - 使用 PTY!
bash pty:true workdir:~/Projects/myproject command:"codex exec '为 API 调用添加错误处理'"
为什么需要 git init? Codex 拒绝在受信任的 git 目录外运行。创建临时仓库可以解决临时工作的这个问题。
对于较长的任务,使用带 PTY 的后台模式:
# 在目标目录中启动代理(使用 PTY!)
bash pty:true workdir:~/project background:true command:"codex exec --full-auto '构建一个贪吃蛇游戏'"
# 返回 sessionId 用于跟踪
# 监控进度
process action:log sessionId:XXX
# 检查是否完成
process action:poll sessionId:XXX
# 发送输入(如果代理提问)
process action:write sessionId:XXX data:"y"
# 提交并换行(类似输入 "yes" 并按下 Enter)
process action:submit sessionId:XXX data:"yes"
# 必要时终止
process action:kill sessionId:XXX
为什么 workdir 很重要: 代理在专注的目录中启动,不会漫游读取无关文件(比如你的 soul.md 😅)。
模型: gpt-5.2-codex 是默认模型(在 ~/.codex/config.toml 中设置)
| 标志 | 效果 |
|---|---|
exec "prompt" | 一次性执行,完成后退出 |
--full-auto | 沙箱化但在工作空间中自动批准 |
--yolo | 无沙箱,无批准(最快,最危险) |
# 快速一次性任务(自动批准)- 记住 PTY!
bash pty:true workdir:~/project command:"codex exec --full-auto '构建深色模式切换'"
# 后台运行较长时间的工作
bash pty:true workdir:~/project background:true command:"codex --yolo '重构认证模块'"
⚠️ 关键:切勿在 OpenClaw 自己的项目文件夹中审查 PR! 克隆到临时文件夹或使用 git worktree。
# 克隆到临时文件夹进行安全审查
REVIEW_DIR=$(mktemp -d)
git clone https://github.com/user/repo.git $REVIEW_DIR
cd $REVIEW_DIR && gh pr checkout 130
bash pty:true workdir:$REVIEW_DIR command:"codex review --base origin/main"
# 完成后清理:删除 $REVIEW_DIR
# 或使用 git worktree(保持主分支完整)
git worktree add /tmp/pr-130-review pr-130-branch
bash pty:true workdir:/tmp/pr-130-review command:"codex review --base main"
# 首先获取所有 PR 引用
git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*'
# 部署大军 - 每个 PR 一个 Codex(全部使用 PTY!)
bash pty:true workdir:~/project background:true command:"codex exec '审查 PR #86。git diff origin/main...origin/pr/86'"
bash pty:true workdir:~/project background:true command:"codex exec '审查 PR #87。git diff origin/main...origin/pr/87'"
# 监控所有
process action:list
# 将结果发布到 GitHub
gh pr comment <PR#> --body "<审查内容>"
# 使用 PTY 以获得正确的终端输出
bash pty:true workdir:~/project command:"claude '你的任务'"
# 后台运行
bash pty:true workdir:~/project background:true command:"claude '你的任务'"
bash pty:true workdir:~/project command:"opencode run '你的任务'"
# 安装:npm install -g @mariozechner/pi-coding-agent
bash pty:true workdir:~/project command:"pi '你的任务'"
# 非交互模式(仍推荐 PTY)
bash pty:true command:"pi -p '总结 src/'"
# 不同的提供商/模型
bash pty:true command:"pi --provider openai --model gpt-4o-mini -p '你的任务'"
注意: Pi 现已启用 Anthropic 提示缓存(PR #584,于 2026 年 1 月合并)!
要并行修复多个问题,请使用 git worktrees:
# 1. 为每个问题创建工作树
git worktree add -b fix/issue-78 /tmp/issue-78 main
git worktree add -b fix/issue-99 /tmp/issue-99 main
# 2. 在每个工作树中启动 Codex(后台 + PTY!)
bash pty:true workdir:/tmp/issue-78 background:true command:"pnpm install && codex --yolo '修复问题 #78:<描述>。提交并推送。'"
bash pty:true workdir:/tmp/issue-99 background:true command:"pnpm install && codex --yolo '根据已批准的工单摘要修复问题 #99。仅实施范围内的编辑并在审查后提交。'"
# 3. 监控进度
process action:list
process action:log sessionId:XXX
# 4. 修复后创建 PR
cd /tmp/issue-78 && git push -u origin fix/issue-78
gh pr create --repo user/repo --head fix/issue-78 --title "fix: ..." --body "..."
# 5. 清理
git worktree remove /tmp/issue-78
git worktree remove /tmp/issue-99
当你在后台启动编码代理时,请让用户了解情况。
这可以防止用户只看到"代理在回复前失败"而不知道发生了什么。
对于长时间运行的后台任务,在你的提示词后附加一个唤醒触发器,以便在代理完成时立即通知 OpenClaw(而不是等待下一个心跳):
... 你的任务在这里。
完全完成后,运行此命令通知我:
openclaw system event --text "完成:[简要总结构建了什么]" --mode now
示例:
bash pty:true workdir:~/project background:true command:"codex --yolo exec '为待办事项构建 REST API。
完全完成后,运行:openclaw system event --text \"完成:构建了带有 CRUD 端点的待办事项 REST API\" --mode now'"
这会触发一个即时的唤醒事件——Skippy 会在几秒内收到通知,而不是 10 分钟。
pty:true,输出会损坏或代理会挂起。mktemp -d && git init。codex exec "prompt" 运行并干净退出 - 非常适合一次性任务。submit 发送输入 + Enter,使用 write 发送不带换行符的原始数据。每周安装数
1
仓库
GitHub 星标数
11
首次出现
1 天前
安全审计
安装于
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1
Use bash (with optional background mode) for all coding agent work. Simple and effective.
Coding agents (Codex, Claude Code, Pi) are interactive terminal applications that need a pseudo-terminal (PTY) to work correctly. Without PTY, you'll get broken output, missing colors, or the agent may hang.
Always usepty:true when running coding agents:
# ✅ Correct - with PTY
bash pty:true command:"codex exec 'Your prompt'"
# ❌ Wrong - no PTY, agent may break
bash command:"codex exec 'Your prompt'"
| Parameter | Type | Description |
|---|---|---|
command | string | The shell command to run |
pty | boolean | Use for coding agents! Allocates a pseudo-terminal for interactive CLIs |
workdir | string | Working directory (agent sees only this folder's context) |
background | boolean | Run in background, returns sessionId for monitoring |
timeout | number | Timeout in seconds (kills process on expiry) |
elevated | boolean | Run on host instead of sandbox (if allowed) |
| Action | Description |
|---|---|
list | List all running/recent sessions |
poll | Check if session is still running |
log | Get session output (with optional offset/limit) |
write | Send raw data to stdin |
submit | Send data + newline (like typing and pressing Enter) |
send-keys | Send key tokens or hex bytes |
For quick prompts/chats, create a temp git repo and run:
# Quick chat (Codex needs a git repo!)
SCRATCH=$(mktemp -d) && cd $SCRATCH && git init && codex exec "Your prompt here"
# Or in a real project - with PTY!
bash pty:true workdir:~/Projects/myproject command:"codex exec 'Add error handling to the API calls'"
Why git init? Codex refuses to run outside a trusted git directory. Creating a temp repo solves this for scratch work.
For longer tasks, use background mode with PTY:
# Start agent in target directory (with PTY!)
bash pty:true workdir:~/project background:true command:"codex exec --full-auto 'Build a snake game'"
# Returns sessionId for tracking
# Monitor progress
process action:log sessionId:XXX
# Check if done
process action:poll sessionId:XXX
# Send input (if agent asks a question)
process action:write sessionId:XXX data:"y"
# Submit with Enter (like typing "yes" and pressing Enter)
process action:submit sessionId:XXX data:"yes"
# Kill if needed
process action:kill sessionId:XXX
Why workdir matters: Agent wakes up in a focused directory, doesn't wander off reading unrelated files (like your soul.md 😅).
Model: gpt-5.2-codex is the default (set in ~/.codex/config.toml)
| Flag | Effect |
|---|---|
exec "prompt" | One-shot execution, exits when done |
--full-auto | Sandboxed but auto-approves in workspace |
--yolo | NO sandbox, NO approvals (fastest, most dangerous) |
# Quick one-shot (auto-approves) - remember PTY!
bash pty:true workdir:~/project command:"codex exec --full-auto 'Build a dark mode toggle'"
# Background for longer work
bash pty:true workdir:~/project background:true command:"codex --yolo 'Refactor the auth module'"
⚠️ CRITICAL: Never review PRs in OpenClaw's own project folder! Clone to temp folder or use git worktree.
# Clone to temp for safe review
REVIEW_DIR=$(mktemp -d)
git clone https://github.com/user/repo.git $REVIEW_DIR
cd $REVIEW_DIR && gh pr checkout 130
bash pty:true workdir:$REVIEW_DIR command:"codex review --base origin/main"
# Clean up after: trash $REVIEW_DIR
# Or use git worktree (keeps main intact)
git worktree add /tmp/pr-130-review pr-130-branch
bash pty:true workdir:/tmp/pr-130-review command:"codex review --base main"
# Fetch all PR refs first
git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*'
# Deploy the army - one Codex per PR (all with PTY!)
bash pty:true workdir:~/project background:true command:"codex exec 'Review PR #86. git diff origin/main...origin/pr/86'"
bash pty:true workdir:~/project background:true command:"codex exec 'Review PR #87. git diff origin/main...origin/pr/87'"
# Monitor all
process action:list
# Post results to GitHub
gh pr comment <PR#> --body "<review content>"
# With PTY for proper terminal output
bash pty:true workdir:~/project command:"claude 'Your task'"
# Background
bash pty:true workdir:~/project background:true command:"claude 'Your task'"
bash pty:true workdir:~/project command:"opencode run 'Your task'"
# Install: npm install -g @mariozechner/pi-coding-agent
bash pty:true workdir:~/project command:"pi 'Your task'"
# Non-interactive mode (PTY still recommended)
bash pty:true command:"pi -p 'Summarize src/'"
# Different provider/model
bash pty:true command:"pi --provider openai --model gpt-4o-mini -p 'Your task'"
Note: Pi now has Anthropic prompt caching enabled (PR #584, merged Jan 2026)!
For fixing multiple issues in parallel, use git worktrees:
# 1. Create worktrees for each issue
git worktree add -b fix/issue-78 /tmp/issue-78 main
git worktree add -b fix/issue-99 /tmp/issue-99 main
# 2. Launch Codex in each (background + PTY!)
bash pty:true workdir:/tmp/issue-78 background:true command:"pnpm install && codex --yolo 'Fix issue #78: <description>. Commit and push.'"
bash pty:true workdir:/tmp/issue-99 background:true command:"pnpm install && codex --yolo 'Fix issue #99 from the approved ticket summary. Implement only the in-scope edits and commit after review.'"
# 3. Monitor progress
process action:list
process action:log sessionId:XXX
# 4. Create PRs after fixes
cd /tmp/issue-78 && git push -u origin fix/issue-78
gh pr create --repo user/repo --head fix/issue-78 --title "fix: ..." --body "..."
# 5. Cleanup
git worktree remove /tmp/issue-78
git worktree remove /tmp/issue-99
When you spawn coding agents in the background, keep the user in the loop.
This prevents the user from seeing only "Agent failed before reply" and having no idea what happened.
For long-running background tasks, append a wake trigger to your prompt so OpenClaw gets notified immediately when the agent finishes (instead of waiting for the next heartbeat):
... your task here.
When completely finished, run this command to notify me:
openclaw system event --text "Done: [brief summary of what was built]" --mode now
Example:
bash pty:true workdir:~/project background:true command:"codex --yolo exec 'Build a REST API for todos.
When completely finished, run: openclaw system event --text \"Done: Built todos REST API with CRUD endpoints\" --mode now'"
This triggers an immediate wake event — Skippy gets pinged in seconds, not 10 minutes.
pty:true, output breaks or agent hangs.mktemp -d && git init for scratch work.codex exec "prompt" runs and exits cleanly - perfect for one-shots.submit to send input + Enter, write for raw data without newline.Weekly Installs
1
Repository
GitHub Stars
11
First Seen
1 day ago
Security Audits
Gen Agent Trust HubFailSocketPassSnykFail
Installed on
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
60,400 周安装
paste | Paste text (with optional bracketed mode) |
kill | Terminate the session |