第 18 节,共 25 节

与编码智能体协作

目录

SLAT 是在一个大量代码由编码智能体编写的团队中设计出来的。当布局被写下来、足够简短、并由机器检查时,智能体会可靠地遵循它。有三点起决定作用。

  1. 固定的布局就是一张免费的地图。 被要求“给转写记录加一个过滤器”的智能体会直接打开 core/transcript/ 和 app/transcript/,无需搜索。智能体花在搜索上的时间,就是它犯错的时间。
  2. 检查胜过提示词里的一句话。 提示词里的“不要从 core 发出事件”多数时候会被遵守。红色的检查每次都会被遵守。先把规则写成检查,只有在无法检查时才写成提示词中的一行。
  3. 配方就是提示词。 第 17 节有意写成编号步骤:把配方粘贴到任务中,智能体就会按预期的顺序在预期的位置生成文件。

智能体也改变了工作区的构建方式。多个智能体在多个工作副本中工作,就是同时对相同的依赖进行多次冷构建,这正是第 19.2 节说的笔记本电脑卡死。第 22.5 节说明每个工作副本如何在不与其他副本共享 target/ 文件夹的情况下热启动,第 22.4 节说明每个智能体如何只运行它的改动可能影响到的测试。

一段可以复制到你仓库贡献者指南(AGENTS.md、CLAUDE.md 或类似文件)中的内容:

## Backend layout: SLAT 1.3

The backend follows SLAT (Slice · Layer · Actor · Tier), version 1.3.
Reference: https://monoone.dev/blog/slat/

- Tiers: app → core → store/drivers → kit. Only `app` depends on tauri.
- A feature is one slice: `crates/<product>-core/src/<slice>/` and `src-tauri/src/<slice>/`.
- Files in a slice: mod.rs, model.rs, logic.rs, store.rs, service.rs, actor/ (only if needed).
- A Tauri command has at most 10 lines and calls one function of its slice.
- Background state belongs to an actor: Msg → update (pure) → Effect.
- Operating-system code only in `drivers/src/platform/`.
- If the product has plugins: a base slice never imports a plugin slice
  (SLAT section 23).
- Before adding code, find its place with the decision tree (SLAT section 17.8,
  https://monoone.dev/blog/slat/recipes/).
- Checks in `checks/slat-*.sh` enforce this. Do not edit a check to make it pass;
  report it instead.
- Before pushing, run the tests the change affects (SLAT section 22.4), then the checks.
- Every working copy has its own `target/`. Never point two copies at one
  folder (SLAT section 22.5).