跳到主要内容

一份 policy.yaml 渲染成 Grok Bot 技能和 Auto-review 规则(也供 Cursor/Grok Build):bot 只写自己名下的路径、密钥永不落盘、每回合一行 JSON 日志,make check 防 drift

GitHubGitHubrsnobles2026-11-17

上手教程踩坑与局限全文核对建议先读
GitHubGitHubrsnobles2026-11-17

打开原文

概要

同时用 Grok Bots、Cursor 和 Grok Build 的人,把「每个 agent 该守什么规矩」写进一份 policy.yaml,一键渲染成各环境认的格式,避免每个 bot 各抄一份规则后越改越散。

核心流程

  1. 起因:同一套规矩要在多个 agent 环境各写一遍。 README 的做法:"Rules are written once in policy.yaml and plain Markdown in shared/. make render turns them into each environment's format, and make check fails if the committed output drifts from the source."(规则只写一次;make render 渲染成各环境的格式,make check 在提交产物与源漂移时报错。)
  2. 自己做:在 Grok Bot 里装渲染产物。 安装方式:"Add dist/grok-bot/workspace-conventions/ to the shared skill library and a load line to each bot"(把渲染出的 workspace-conventions 加入共享技能库,并给每个 bot 加一行加载指令);产物是一份技能加 Auto-review 起步规则。
  3. 交给 bot:每个回合先过工作区规矩。 技能的触发描述是 "Load at the start of every turn that reads or writes /workspace, creates files, logs a run, hands work to another bot, or touches secrets."(在读写 /workspace、建文件、记运行日志、向别的 bot 交活或碰密钥的每个回合开头加载。);核心规则 OWN-1:"A bot writes only under paths it owns per the layout and etc/registry.json. Everything else is read-only to it."(bot 只写按布局和注册表属于它的路径,其余一律只读。)
  4. 交给 bot:密钥、日志和交接有硬规矩。 SEC-1:"Never write secrets, tokens or environment values to /workspace, logs, memory or any repo."(绝不把密钥、令牌或环境值写进 /workspace、日志、记忆或任何仓库。);LOG-1 要求每回合往 var/log/<bot>/turns.jsonl 追加一行 JSON(时长、工具、消息数、错误),且 "Log counts and metadata, never message content."(只记计数和元数据,不记消息内容。);交接用 ATOM-1:"Write to a temp file in the same directory, then rename() it into place."(同目录写临时文件再改名顶上,读者永远看不到半个文件。)
  5. 怎么检查: 作者的检查在构建侧:make check 重新渲染到临时目录并与提交的 dist/ 逐项 diff;SKILL.md 顶部注明 "Generated by agent-policies 0.2.0 from policy.yaml. Do not edit; run make render."(产物是生成的,别手改,改了跑 make render。)

核心观点和结果

  • 「最小权限」靠约定,不靠内核。 证据:原则一节写明 "All agents run as the same user, so the kernel cannot keep them apart."(所有 agent 以同一用户运行,内核分不开它们),于是每个 agent 按自己拥有的路径自律;README 也声明钩子是 "guardrails, not a security boundary"(护栏,不是安全边界)。
  • 政策与机制分离,改一处重新渲染。 证据:policy.yaml 定「必须发生什么」,技能、规则、钩子只是载体;产物带版本号并禁止手改。
  • 跨 bot 交活走文件队列。 证据:把工作交给另一个 bot 的方式是往 var/spool/<queue>/ 写临时文件再改名顶上;每回合结束原子地重写 run/<bot>/status.json 当「进程表」。
  • 规矩分「强制」和「指南」两档。 证据:每条规则标注 enforced by(convention / auto-review / hook),而用量类的 tokens_per_bot_per_day 只是 "watched via daily usage routine into var/metrics"(用每日用量例程写进指标目录)的指南。

来源

平台
GitHub
原作者
rsnobles
原文日期
分类
上手教程、踩坑与局限

这条证据标签是什么意思

全文核对

来源已经读过(帖子、文章或字幕)。这只说明原文被读过,不代表本站复现了作者的结果。

阅读编辑与证据规范

同场景的其他案例

非官方社区项目,与 xAI 没有隶属关系,也未获 xAI 认可或背书。没有注册。做法和数字属于原作者。