Lattice
Lattice is a file-based operating system for AI agent teams. It replaces volatile chat windows with persistent files, enabling agents to work stably through long, iterative development cycles via an 8-phase execution pipeline.
Why Lattice?
- - Stable long-running execution — File-driven state machine ensures agents stay on track across sessions. No context window overflow, no drift. Tasks complete reliably over hours or days through structured iteration.
- Three-tier failure handling — When an agent gets stuck: (1) Model Escalation retries with stronger models, (2) Peer Consult gathers parallel opinions from multiple models, (3) Auto-Triage makes a judgment call (relax constraints / defer / block for human). Most blockers resolve automatically.
- Per-phase model configuration — Thinking-heavy phases (planning, review, architecture) need strong reasoning models; token-heavy phases (implementation, testing) can use cost-efficient coding models. This dramatically reduces overall token cost without sacrificing quality where it matters.
Example model assignment (from a production setup):
| Phase | Model tier | Example |
|---|
| Constitute (architecture) | Strong reasoning | Claude Opus |
| Research |
Strong reasoning | Gemini Pro |
| Specify (design) | Strong reasoning | Claude Opus |
| Plan + Tasks | Strong reasoning | Claude Opus |
| Implement | Cost-efficient coding | GPT Codex |
| Test | Cost-efficient coding | GPT Codex |
| Review | Strong reasoning | Claude Opus |
| Gap Analysis | Strong reasoning | Gemini Pro |
The key insight: implementation and testing consume the most tokens (writing/running code), but don't require the most expensive models. Planning and review consume fewer tokens but need deeper reasoning. Match model strength to cognitive demand, not token volume.
- - Multi-project parallel execution — Run multiple projects simultaneously, each with its own cron-scheduled orchestrator. Combined with OpenClaw's cron system, projects advance autonomously on independent cadences.
Templates are bundled at templates/ORG/ relative to this skill directory.
Quick Reference
- - Full design doc: INLINECODE1
- Pipeline guide (all agents): INLINECODE2
- Sub-agent guide: INLINECODE3
- Orchestrator prompt template: INLINECODE4
- Phase prompt templates: INLINECODE5
- State machine template: INLINECODE6
Task: Initialize a New Organization (lattice init)
1. Gather Information
Ask the user for:
- - Organization name (e.g. "Acme Labs")
- Target directory — where to create the
ORG/ folder (default: current workspace root) - Departments — list of department names (e.g. Research, Engineering, Reliability)
- First project (optional) — name + one-line description
Keep it conversational. Don't dump all questions at once.
2. Scaffold the ORG Directory
Copy the entire templates/ORG/ directory to <target>/ORG/.
Then customize:
- 1. ORG_README.md — Replace the example org structure in §5 with the user's actual departments
- TASKBOARD.md — Leave the template structure intact (user fills in priorities later)
- Departments — For each department the user listed:
- Copy
DEPARTMENTS/example-dept/ →
DEPARTMENTS/<dept-name>/
- In each copied department, replace
<Department Name> placeholders in CHARTER.md, RUNBOOK.md, HANDOFF.md with the actual department name
- Reset STATE.json to
{"lastRun": null, "cursor": null, "notes": "Initial state"}
- 4. Remove
DEPARTMENTS/example-dept/ after creating real departments (unless user wants to keep it as reference)
3. Create the First Project (if requested)
- - Copy
PROJECTS/example-project/ → INLINECODE17 - Update STATUS.md with the project name
- Update DECISIONS.md header
- Configure PIPELINE_STATE.json (see "Configure Pipeline State" below)
- Remove
PROJECTS/example-project/ after creating the real project
4. Configure Pipeline State
Read templates/ORG/PROJECTS/pipeline-framework/templates/PIPELINE_STATE.template.json as the reference.
Ask the user:
- - Which agents will run each phase? (agentId per role — or a single agent for all)
- Which models for each phase? (or a default model)
- Escalation chain — list of models from cheapest to strongest (e.g.
["gflash", "gpro", "sonnet"]) - Peer consult models — which models to consult in parallel when stuck
- Synthesizer/triage model — typically the strongest available model
- Notification channel (optional) — where to send pipeline status updates
Fill in the project's PIPELINE_STATE.json with these values, replacing all <placeholder> tokens.
5. Set Up the Orchestrator Cron Job
Read templates/ORG/PROJECTS/pipeline-framework/templates/ORCHESTRATOR_PROMPT.template.md.
Create a cron job using the cron tool:
- - Schedule:
every 30 minutes (adjustable) - Session target: INLINECODE26
- Payload kind: INLINECODE27
- Model: the user's chosen orchestrator model
- Message: the orchestrator prompt template, with all
<placeholder> tokens filled in:
-
<project> → project name
-
<org-root> → absolute path to the ORG directory
-
<project-root> → absolute path to the project directory
-
<repo-root> → absolute path to the code repository (ask user)
- Phase prompt paths → absolute paths to the skill's bundled phase prompt templates
Tell the user the cron job ID so they can manage it later.
6. Summary
Print a brief summary:
- - ORG directory location
- Departments created
- Project(s) created
- Cron job ID and schedule
- Remind them to fill in TASKBOARD.md with initial priorities
Task: Add a New Project (lattice new-project)
- 1. Ask for: project name, one-line description, code repo path
- Copy
templates/ORG/PROJECTS/example-project/ → INLINECODE35 - Customize STATUS.md, DECISIONS.md, PIPELINE_STATE.json (same as step 3-4 above)
- Optionally create a new orchestrator cron job for this project
Task: Add a New Department (lattice new-dept)
- 1. Ask for: department name, mission (one sentence)
- Copy
templates/ORG/DEPARTMENTS/example-dept/ → INLINECODE38 - Fill in CHARTER.md with the department name and mission
- Update ORG_README.md §5 to include the new department
Task: Check Organization Status (lattice status)
- 1. Read
ORG/TASKBOARD.md — summarize active priorities - For each project in
ORG/PROJECTS/:
- Read
STATUS.md — current phase and progress
- Read
PIPELINE_STATE.json — phase statuses, blockers, run number
- 3. For each department in
ORG/DEPARTMENTS/:
- Read
HANDOFF.md — current state and blockers
- 4. Present a concise status report
Pipeline Architecture (for reference)
8 Phases
CODEBLOCK0
3-Layer Assistance (when a phase gets stuck)
- 1. Model Escalation — retry with progressively stronger models
- Peer Consult — parallel multi-model consultation + synthesis
- Auto-Triage — automated judge decides: RELAX (loosen constraints) / DEFER (next iteration) / BLOCK (wait for human)
Key Files per Project
CODEBLOCK1
Lattice
Lattice 是一个基于文件的 AI 智能体团队操作系统。它用持久化文件取代了易变的聊天窗口,通过一个 8 阶段执行流水线,使智能体能够在漫长、迭代的开发周期中稳定工作。
为什么选择 Lattice?
- - 稳定的长时间运行执行 — 文件驱动的状态机确保智能体在多次会话中保持正轨。无上下文窗口溢出,无漂移。通过结构化迭代,任务可在数小时或数天内可靠完成。
- 三层故障处理 — 当智能体卡住时:(1) 模型升级 — 使用更强模型重试,(2) 同行咨询 — 从多个模型收集并行意见,(3) 自动分诊 — 做出判断(放宽约束 / 推迟 / 阻塞等待人工处理)。大多数阻塞问题会自动解决。
- 按阶段配置模型 — 高思考强度的阶段(规划、审查、架构)需要强推理模型;高 Token 消耗的阶段(实现、测试)可使用高性价比的编码模型。这能大幅降低总体 Token 成本,同时不牺牲关键环节的质量。
示例模型分配(来自生产环境配置):
| 阶段 | 模型层级 | 示例 |
|---|
| 构建(架构) | 强推理 | Claude Opus |
| 研究 |
强推理 | Gemini Pro |
| 规格(设计) | 强推理 | Claude Opus |
| 规划 + 任务 | 强推理 | Claude Opus |
| 实现 | 高性价比编码 | GPT Codex |
| 测试 | 高性价比编码 | GPT Codex |
| 审查 | 强推理 | Claude Opus |
| 差距分析 | 强推理 | Gemini Pro |
关键洞察:实现和测试消耗的 Token 最多(编写/运行代码),但不需要最昂贵的模型。规划和审查消耗的 Token 较少,但需要更深入的推理。将模型强度与认知需求匹配,而非 Token 数量。
- - 多项目并行执行 — 同时运行多个项目,每个项目拥有独立的定时调度协调器。结合 OpenClaw 的定时系统,项目可按各自独立节奏自主推进。
模板位于此技能目录下的 templates/ORG/ 目录中。
快速参考
- - 完整设计文档:templates/ORG/PROJECTS/pipeline-framework/DESIGN.md
- 流水线指南(所有智能体):templates/ORG/PIPELINEGUIDE.md
- 子智能体指南:templates/ORG/PROJECTS/pipeline-framework/templates/PIPELINEGUIDEFORSUBAGENTS.md
- 协调器提示词模板:templates/ORG/PROJECTS/pipeline-framework/templates/ORCHESTRATORPROMPT.template.md
- 阶段提示词模板:templates/ORG/PROJECTS/pipeline-framework/templates/PHASEPROMPTS/
- 状态机模板:templates/ORG/PROJECTS/pipeline-framework/templates/PIPELINE_STATE.template.json
任务:初始化新组织(lattice init)
1. 收集信息
向用户询问:
- - 组织名称(例如 Acme Labs)
- 目标目录 — 用于创建 ORG/ 文件夹的位置(默认:当前工作区根目录)
- 部门 — 部门名称列表(例如 研究部、工程部、可靠性部)
- 首个项目(可选)— 名称 + 一行描述
保持对话风格。不要一次性抛出所有问题。
2. 搭建 ORG 目录结构
将整个 templates/ORG/ 目录复制到 /ORG/。
然后进行自定义:
- 1. ORG_README.md — 将 §5 中的示例组织结构替换为用户的实际部门
- TASKBOARD.md — 保持模板结构不变(用户稍后填写优先级)
- 部门 — 针对用户列出的每个部门:
- 复制 DEPARTMENTS/example-dept/ → DEPARTMENTS/
/
- 在每个复制的部门中,将 CHARTER.md、RUNBOOK.md、HANDOFF.md 中的 占位符替换为实际部门名称
- 将 STATE.json 重置为 {lastRun: null, cursor: null, notes: Initial state}
- 4. 创建真实部门后移除 DEPARTMENTS/example-dept/(除非用户希望保留作为参考)
3. 创建首个项目(如果用户要求)
- - 复制 PROJECTS/example-project/ → PROJECTS//
- 更新 STATUS.md 中的项目名称
- 更新 DECISIONS.md 的标题
- 配置 PIPELINE_STATE.json(参见下方的配置流水线状态)
- 创建真实项目后移除 PROJECTS/example-project/
4. 配置流水线状态
将 templates/ORG/PROJECTS/pipeline-framework/templates/PIPELINE_STATE.template.json 作为参考。
向用户询问:
- - 哪些智能体将运行每个阶段?(每个角色的 agentId — 或一个智能体负责所有)
- 每个阶段使用哪些模型?(或一个默认模型)
- 升级链 — 从最便宜到最强的模型列表(例如 [gflash, gpro, sonnet])
- 同行咨询模型 — 卡住时并行咨询的模型
- 合成器/分诊模型 — 通常是最强的可用模型
- 通知渠道(可选)— 发送流水线状态更新的位置
使用这些值填充项目的 PIPELINE_STATE.json,替换所有 标记。
5. 设置协调器定时任务
读取 templates/ORG/PROJECTS/pipeline-framework/templates/ORCHESTRATOR_PROMPT.template.md。
使用 cron 工具创建一个定时任务:
- - 调度:每 30 分钟(可调整)
- 会话目标:isolated
- 负载类型:agentTurn
- 模型:用户选择的协调器模型
- 消息:协调器提示词模板,其中所有 标记已填充:
- → 项目名称
- → ORG 目录的绝对路径
- → 项目目录的绝对路径
- → 代码仓库的绝对路径(询问用户)
- 阶段提示词路径 → 技能捆绑的阶段提示词模板的绝对路径
告知用户定时任务 ID,以便他们稍后管理。
6. 总结
打印简要总结:
- - ORG 目录位置
- 已创建的部门
- 已创建的项目
- 定时任务 ID 和调度
- 提醒用户填写 TASKBOARD.md 中的初始优先级
任务:添加新项目(lattice new-project)
- 1. 询问:项目名称、一行描述、代码仓库路径
- 复制 templates/ORG/PROJECTS/example-project/ → ORG/PROJECTS//
- 自定义 STATUS.md、DECISIONS.md、PIPELINE_STATE.json(与上述步骤 3-4 相同)
- 可选:为此项目创建一个新的协调器定时任务
任务:添加新部门(lattice new-dept)
- 1. 询问:部门名称、使命(一句话)
- 复制 templates/ORG/DEPARTMENTS/example-dept/ → ORG/DEPARTMENTS//
- 在 CHARTER.md 中填写部门名称和使命
- 更新 ORG_README.md §5 以包含新部门
任务:检查组织状态(lattice status)
- 1. 读取 ORG/TASKBOARD.md — 总结当前活跃的优先级
- 对于 ORG/PROJECTS/ 中的每个项目:
- 读取 STATUS.md — 当前阶段和进度
- 读取 PIPELINE_STATE.json — 阶段状态、阻塞项、运行编号
- 3. 对于 ORG/DEPARTMENTS/ 中的每个部门:
- 读取 HANDOFF.md — 当前状态和阻塞项
- 4. 呈现简洁的状态报告
流水线架构(供参考)
8 个阶段
构建 → 研究 → 规格 → 规划+任务 → 实现 → 测试 → 审查 → 差距分析
3 层辅助(当阶段卡住时)
- 1. 模型升级 — 使用逐渐更强的模型重试
- 同行咨询 — 并行多模型咨询 + 合成
- 自动分诊 — 自动判断决定:放宽(放松约束)/ 推迟(下一轮迭代)/ 阻塞(等待人工处理)
每个项目的关键文件
ORG/PROJECTS//
├── STATUS