loki-mode
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLoki Mode - OpenClaw Skill
Loki Mode - OpenClaw 技能
When to use
适用场景
- User asks to "build", "implement", or "develop" a feature from a PRD
- User provides a requirements document and wants autonomous execution
- User says "loki mode" or references autonomous development
- User wants to run a full SDLC cycle on a codebase
- 用户要求基于PRD「搭建」、「实现」或「开发」某个功能
- 用户提供需求文档,需要自主执行
- 用户提及「loki mode」或者提到自主开发
- 用户需要在代码库上运行完整的SDLC周期
Prerequisites
前置要求
- CLI installed on the host (via
lokior Homebrew)npm install -g loki-mode - One of: Claude Code, Codex CLI, or Gemini CLI installed
- Corresponding API key set (ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_API_KEY)
- 主机上已安装CLI(可通过
loki或Homebrew安装)npm install -g loki-mode - 已安装以下工具之一:Claude Code、Codex CLI或Gemini CLI
- 已配置对应的API密钥(ANTHROPIC_API_KEY、OPENAI_API_KEY或GOOGLE_API_KEY)
How to invoke
调用方式
Start a session
启动会话
Use the bash tool with background mode:
bash(command: "loki start <prd-path> --bg --yes --no-dashboard", pty: true, background: true, workdir: "<project-dir>")Key flags:
- : Background mode (session outlives the tool call)
--bg - : Skip confirmation prompts
--yes - : Avoid port conflicts in sandboxed environments
--no-dashboard - : Select AI provider (default: claude)
--provider <claude|codex|gemini> - : Set cost limit in USD (auto-pause when exceeded)
--budget <amount>
使用bash工具的后台模式:
bash(command: "loki start <prd-path> --bg --yes --no-dashboard", pty: true, background: true, workdir: "<project-dir>")Monitor progress
关键参数:
Poll status every 30 seconds:
bash(command: "loki status --json", workdir: "<project-dir>")The JSON output contains:
- : Loki Mode version string
version - : inactive, running, paused, stopped, completed, unknown
status - : Current SDLC phase (e.g., BOOTSTRAP, DISCOVERY, ARCHITECTURE, DEVELOPMENT, QA, DEPLOYMENT)
phase - : Current iteration number
iteration - : Which AI provider is active (claude, codex, gemini)
provider - : Process ID of the running session (null if not running)
pid - : Seconds since session start
elapsed_time - : URL of the web dashboard (null if disabled)
dashboard_url - : Object with
task_counts,total,completed,failedcountspending
For budget tracking (not in JSON output), read the budget file directly:
bash(command: "cat .loki/metrics/budget.json 2>/dev/null || echo '{}'", workdir: "<project-dir>")Budget JSON fields: ,
budget_limitbudget_used- :后台模式(会话不受工具调用生命周期限制)
--bg - :跳过确认提示
--yes - :避免沙箱环境中的端口冲突
--no-dashboard - :选择AI提供商(默认:claude)
--provider <claude|codex|gemini> - :设置成本上限(单位:美元,超出后自动暂停)
--budget <amount>
Report progress to channel
进度监控
After each poll, summarize changes:
- Phase transitions ("Moved from ARCHITECTURE to DEVELOPMENT")
- Task completion counts ("12/20 tasks complete, 0 failed")
- Elapsed time ("Running for 45 minutes")
- Error states that need attention (failed tasks > 0, status is unknown)
If budget tracking is active, include cost in updates:
- "Estimated cost: $4.50 / $50.00 budget"
每30秒轮询一次状态:
bash(command: "loki status --json", workdir: "<project-dir>")JSON输出包含以下字段:
- :Loki Mode版本字符串
version - :状态,可选值:inactive(未激活)、running(运行中)、paused(已暂停)、stopped(已停止)、completed(已完成)、unknown(未知)
status - :当前SDLC阶段(例如BOOTSTRAP、DISCOVERY、ARCHITECTURE、DEVELOPMENT、QA、DEPLOYMENT)
phase - :当前迭代编号
iteration - :当前使用的AI提供商(claude、codex、gemini)
provider - :运行中会话的进程ID(未运行时为null)
pid - :会话启动后经过的秒数
elapsed_time - :网页仪表盘URL(未启用时为null)
dashboard_url - :包含
task_counts(总任务数)、total(已完成)、completed(失败)、failed(待处理)计数的对象pending
若要追踪预算(不在JSON输出中),可直接读取预算文件:
bash(command: "cat .loki/metrics/budget.json 2>/dev/null || echo '{}'", workdir: "<project-dir>")预算JSON字段:(预算上限)、(已使用预算)
budget_limitbudget_usedControl commands
向频道上报进度
- Pause:
bash(command: "loki pause", workdir: "<project-dir>") - Resume:
bash(command: "loki resume", workdir: "<project-dir>") - Stop:
bash(command: "loki stop", workdir: "<project-dir>") - Status:
bash(command: "loki status", workdir: "<project-dir>") - Logs:
bash(command: "loki logs --tail 50", workdir: "<project-dir>")
每次轮询后,总结变化:
- 阶段切换(例如「Moved from ARCHITECTURE to DEVELOPMENT」)
- 任务完成数(例如「12/20 tasks complete, 0 failed」)
- 运行时长(例如「Running for 45 minutes」)
- 需要关注的错误状态(失败任务数>0,状态为unknown)
如果启用了预算追踪,更新内容中要包含成本信息:
- 「Estimated cost: $4.50 / $50.00 budget」
Session complete
控制命令
When status becomes "stopped" or "completed":
- Run for final summary
loki status --json - Run to show commits made
git log --oneline -20 - Report final task counts, elapsed time, and duration
- If council verdict exists, include it:
cat .loki/council/report.md
- 暂停:
bash(command: "loki pause", workdir: "<project-dir>") - 恢复:
bash(command: "loki resume", workdir: "<project-dir>") - 停止:
bash(command: "loki stop", workdir: "<project-dir>") - 状态查询:
bash(command: "loki status", workdir: "<project-dir>") - 日志查询:
bash(command: "loki logs --tail 50", workdir: "<project-dir>")
Critical rules
会话结束
- ALWAYS use --bg flag (session must outlive the tool call)
- ALWAYS use --yes flag (no confirmation prompts in non-interactive channels)
- NEVER run loki in the OpenClaw workspace directory itself
- Poll status rather than watching stdout (background mode detaches)
- If session crashes, check before restarting
loki logs - Respect budget limits -- include cost in every progress update when tracking is active
- The --no-dashboard flag is recommended to avoid port conflicts in sandboxed environments
当状态变为「stopped」或「completed」时:
- 执行获取最终总结
loki status --json - 执行展示生成的提交记录
git log --oneline -20 - 上报最终任务计数、运行时长
- 如果存在评审结论,包含该内容:
cat .loki/council/report.md
—
重要规则
—
- 始终使用--bg参数(会话必须不受工具调用生命周期限制)
- 始终使用--yes参数(非交互频道中无需确认提示)
- 切勿在OpenClaw工作区目录本身运行loki
- 采用轮询方式查询状态,而非监听标准输出(后台模式会脱离进程)
- 如果会话崩溃,重启前先查看
loki logs - 遵守预算限制——启用追踪时,每次进度更新都要包含成本信息
- 推荐使用--no-dashboard参数,避免沙箱环境中的端口冲突