loki-mode

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Loki Mode - OpenClaw Skill

Loki Mode - OpenClaw Skill

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

前置条件

  • loki
    CLI installed on the host (via
    npm install -g loki-mode
    or Homebrew)
  • One of: Claude Code, Codex CLI, or Gemini CLI installed
  • Corresponding API key set (ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_API_KEY)
  • 主机上已安装
    loki
    CLI(通过
    npm install -g loki-mode
    或Homebrew安装)
  • 已安装以下工具之一: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:
  • --bg
    : Background mode (session outlives the tool call)
  • --yes
    : Skip confirmation prompts
  • --no-dashboard
    : Avoid port conflicts in sandboxed environments
  • --provider <claude|codex|gemini>
    : Select AI provider (default: claude)
  • --budget <amount>
    : Set cost limit in USD (auto-pause when exceeded)
使用bash工具的后台模式:
bash(command: "loki start <prd-path> --bg --yes --no-dashboard", pty: true, background: true, workdir: "<project-dir>")
关键参数:
  • --bg
    :后台模式(会话独立于工具调用持续运行)
  • --yes
    :跳过确认提示
  • --no-dashboard
    :避免在沙箱环境中出现端口冲突
  • --provider <claude|codex|gemini>
    :选择AI提供商(默认:claude)
  • --budget <amount>
    :设置美元计价的成本上限(超出后自动暂停)

Monitor progress

监控进度

Poll status every 30 seconds:
bash(command: "loki status --json", workdir: "<project-dir>")
The JSON output contains:
  • version
    : Loki Mode version string
  • status
    : inactive, running, paused, stopped, completed, unknown
  • phase
    : Current SDLC phase (e.g., BOOTSTRAP, DISCOVERY, ARCHITECTURE, DEVELOPMENT, QA, DEPLOYMENT)
  • iteration
    : Current iteration number
  • provider
    : Which AI provider is active (claude, codex, gemini)
  • pid
    : Process ID of the running session (null if not running)
  • elapsed_time
    : Seconds since session start
  • dashboard_url
    : URL of the web dashboard (null if disabled)
  • task_counts
    : Object with
    total
    ,
    completed
    ,
    failed
    ,
    pending
    counts
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_limit
,
budget_used
每30秒轮询一次状态:
bash(command: "loki status --json", workdir: "<project-dir>")
JSON输出包含以下字段:
  • version
    :Loki Mode版本字符串
  • status
    :状态(inactive、running、paused、stopped、completed、unknown)
  • phase
    :当前SDLC阶段(例如BOOTSTRAP、DISCOVERY、ARCHITECTURE、DEVELOPMENT、QA、DEPLOYMENT)
  • iteration
    :当前迭代次数
  • provider
    :当前使用的AI提供商(claude、codex、gemini)
  • pid
    :运行会话的进程ID(未运行时为null)
  • elapsed_time
    :会话启动后的耗时(秒)
  • dashboard_url
    :Web仪表盘的URL(禁用时为null)
  • task_counts
    :任务统计对象,包含
    total
    completed
    failed
    pending
    计数
对于预算跟踪(不在JSON输出中),直接读取预算文件:
bash(command: "cat .loki/metrics/budget.json 2>/dev/null || echo '{}'", workdir: "<project-dir>")
预算JSON字段:
budget_limit
budget_used

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"
每次轮询后,总结变更内容:
  • 阶段转换(例如「从ARCHITECTURE阶段进入DEVELOPMENT阶段」)
  • 任务完成计数(例如「20项任务已完成12项,0项失败」)
  • 耗时(例如「已运行45分钟」)
  • 需要关注的错误状态(失败任务数>0、状态为unknown)
如果启用了预算跟踪,更新内容中需包含成本信息:
  • 「预估成本:$4.50 / 预算上限$50.00」

Control 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>")
  • 暂停:
    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>")

Session complete

会话完成

When status becomes "stopped" or "completed":
  1. Run
    loki status --json
    for final summary
  2. Run
    git log --oneline -20
    to show commits made
  3. Report final task counts, elapsed time, and duration
  4. If council verdict exists, include it:
    cat .loki/council/report.md
当状态变为「stopped」或「completed」时:
  1. 运行
    loki status --json
    获取最终总结
  2. 运行
    git log --oneline -20
    查看提交记录
  3. 汇报最终任务计数、耗时和总时长
  4. 如果存在评审结论,包含该内容:
    cat .loki/council/report.md

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
    loki logs
    before restarting
  • 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
  • 务必使用--bg参数(会话必须独立于工具调用持续运行)
  • 务必使用--yes参数(在非交互式渠道中跳过确认提示)
  • 绝对不要在OpenClaw工作区目录本身中运行loki
  • 通过轮询状态而非监控stdout来跟踪进度(后台模式会分离进程)
  • 如果会话崩溃,先检查
    loki logs
    再重启
  • 遵守预算限制——启用跟踪时,每次进度更新都要包含成本信息
  • 建议使用--no-dashboard参数,避免在沙箱环境中出现端口冲突