网淘吧来吧,欢迎您!

Kilo CLI Coding Agent

2026-03-31 新闻来源:网淘吧 围观:19
电脑广告
手机广告

重要提示:您需要安装并配置Kilo CLI,以确保OpenClaw能够顺利使用它。

npm install -g @kilocode/cli

如果您想自动化向Github提交拉取请求,那么您还需要在项目中验证Github CLI:https://github.com/cli/cli#installation

Kilo CLI Coding Agent

编码代理(后台优先)

使用bash 后台模式进行非交互式编码工作。对于交互式编码会话,请使用tmux技能(始终如此,除非是非常简单的一次性提示)。

模式:工作目录 + 后台

# Create temp space for chats/scratch work
SCRATCH=$(mktemp -d)

# Start agent in target directory ("little box" - only sees relevant files)
bash workdir:$SCRATCH background:true command:"<agent command>"
# Or for project work:
bash workdir:~/project/folder background:true command:"<agent command>"
# 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"

# Kill if needed
process action:kill sessionId:XXX

为什么工作目录很重要:代理在一个专注的目录中启动,不会偏离去读取无关文件(比如你的soul.md 😅)。


Kilo CLI

构建/创建(使用自主模式)

bash workdir:~/project background:true command:"kilo run --auto \"Build a snake game with dark theme\""

审查PR(普通模式,无标志)

⚠️ 关键提示:切勿在OpenClaw自己的项目文件夹中审查PR!

  • 要么使用提交PR的项目(如果不是 ~/Projects/openclaw)
  • 要么先克隆到一个临时文件夹
# Option 1: Review in the actual project (if NOT OpenClaw)
bash workdir:~/Projects/some-other-repo background:true command:"kilo run \"Review current branch against main branch\""

# Option 2: Clone to temp folder for safe review (REQUIRED for OpenClaw PRs!)
REVIEW_DIR=$(mktemp -d)
git clone https://github.com/openclaw/openclaw.git $REVIEW_DIR
cd $REVIEW_DIR && gh pr checkout 130
bash workdir:$REVIEW_DIR background:true command:"kilo run \"Review current branch against main branch\""
# Clean up after: rm -rf $REVIEW_DIR

# Option 3: Use git worktree (keeps main intact)
git worktree add /tmp/pr-130-review pr-130-branch
bash workdir:/tmp/pr-130-review background:true command:"kilo run \"Review current branch against main branch\""

为什么?在运行的OpenClaw仓库中检出分支可能会破坏线上实例!

批量PR审查(并行大军!)

# Fetch all PR refs first
git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*'

# Deploy the army - one Kilo CLI per PR!
bash workdir:~/project background:true command:"kilo run \"Review PR #86. git diff origin/main...origin/pr/86\""
bash workdir:~/project background:true command:"kilo run \"Review PR #87. git diff origin/main...origin/pr/87\""
bash workdir:~/project background:true command:"kilo run \"Review PR #95. git diff origin/main...origin/pr/95\""
# ... repeat for all PRs

# Monitor all
process action:list

# Get results and post to GitHub
process action:log sessionId:XXX
gh pr comment <PR#> --body "<review content>"

PR审查技巧

  • 首先获取引用: git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*'
  • 使用 git diff:告诉 Kilo CLI 使用git diff origin/main...origin/pr/XX
  • 不要检出:多个并行审查 = 不要让它们切换分支
  • 发布结果:使用gh pr comment将审查结果发布到GitHub

tmux(交互式会话)

使用tmux技能进行交互式编码会话(除了非常简单的单次提示外,始终使用)。对于非交互式运行,优先使用bash后台模式。


使用git worktrees + tmux进行并行问题修复

为了并行修复多个问题,请使用git worktrees(隔离分支)+ tmux会话:

# 1. Clone repo to temp location
cd /tmp && git clone git@github.com:user/repo.git repo-worktrees
cd repo-worktrees

# 2. Create worktrees for each issue (isolated branches!)
git worktree add -b fix/issue-78 /tmp/issue-78 main
git worktree add -b fix/issue-99 /tmp/issue-99 main

# 3. Set up tmux sessions
SOCKET="${TMPDIR:-/tmp}/kilo-fixes.sock"
tmux -S "$SOCKET" new-session -d -s fix-78
tmux -S "$SOCKET" new-session -d -s fix-99

# 4. Launch Kilo CLI in each (after npm install!)
tmux -S "$SOCKET" send-keys -t fix-78 "cd /tmp/issue-78 && npm install && kilo run 'Fix issue #78: <description>. Commit and push.'" Enter
tmux -S "$SOCKET" send-keys -t fix-99 "cd /tmp/issue-99 && npm install && kilo run 'Fix issue #99: <description>. Commit and push.'" Enter

# 5. Monitor progress
tmux -S "$SOCKET" capture-pane -p -t fix-78 -S -30
tmux -S "$SOCKET" capture-pane -p -t fix-99 -S -30

# 6. Check if done (prompt returned)
tmux -S "$SOCKET" capture-pane -p -t fix-78 -S -3 | grep -q "❯" && echo "Done!"

# 7. 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 "..."

# 8. Cleanup
tmux -S "$SOCKET" kill-server
git worktree remove /tmp/issue-78
git worktree remove /tmp/issue-99

为什么使用worktrees?每个Kilo CLI都在独立的分支中运行,互不冲突。可以并行执行5个以上的修复任务!

为什么选择tmux而不是bash后台运行?Kilo CLI是交互式工具——需要TTY来正常输出。tmux提供持久化会话并完整记录历史输出。


⚠️ 规则说明

  1. 尊重工具选择——如果用户要求使用Kilo CLI,请务必使用Kilo CLI。绝对不要尝试自行构建!
  2. 保持耐心——不要因为运行“缓慢”就终止会话
  3. 使用process:log监控进度——无需干扰即可查看进度
  4. 构建时使用--full-auto参数——自动批准变更
  5. 审查时使用vanilla模式——无需特殊参数
  6. 支持并行操作——批量处理时可同时运行多个Kilo CLI进程
  7. 绝对不要在~/openclaw/目录下启动Kilo CLI——它会读取你的核心文档并对组织架构产生奇怪想法!请使用目标项目目录或/tmp目录进行空白会话
  8. 绝对不要在~/Projects/openclaw/目录下检出分支——这是LIVE OpenClaw实例!克隆到/tmp目录或使用git worktree进行PR审查

PR模板(Razor标准)

向外部代码库提交PR时,请使用此格式以确保质量并方便维护者处理:

## Original Prompt
[Exact request/problem statement]

## What this does
[High-level description]

**Features:**
- [Key feature 1]
- [Key feature 2]

**Example usage:**
```bash
# Example
command example
```

## Feature intent (maintainer-friendly)
[Why useful, how it fits, workflows it enables]

## Prompt history (timestamped)
- YYYY-MM-DD HH:MM UTC: [Step 1]
- YYYY-MM-DD HH:MM UTC: [Step 2]

## How I tested
**Manual verification:**
1. [Test step] - Output: `[result]`
2. [Test step] - Result: [result]

**Files tested:**
- [Detail]
- [Edge cases]

## Session logs (implementation)
- [What was researched]
- [What was discovered]
- [Time spent]

## Implementation details
**New files:**
- `path/file.ts` - [description]

**Modified files:**
- `path/file.ts` - [change]

**Technical notes:**
- [Detail 1]
- [Detail 2]

---

核心原则:

  1. 人工编写的描述(杜绝AI生成的低质量内容)
  2. 面向维护者的功能意图说明
  3. 带时间戳的提示历史记录
  4. 使用Kilo CLI代理时的会话日志

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏

文章底部电脑广告
手机广告位-内容正文底部
上一篇:spots 下一篇:Timesheet - Time Tracking

相关文章

您是本站第388030名访客 今日有1篇新文章/评论