tinyorbit-ai/skills/tree/main/mods/forge-gate
forge-gate
强制执行 forge 阶段门禁:只针对你现有的文件,显示当前阶段的 Verifiable gate 是否为绿色;如果不是,就把声称 gate 为 green 的 forge 阶段结果退回。运行 /gate。
关于这个 mod
forge-gate
在 Claude Code 内强制执行 forge 阶段门禁。
Phase 3 繚 Billing API ??gate green 4m ago + written checks [ Run gate ]
Phase 3 繚 Billing API ??changed since the last run [ Run gate ]
Phase 3 繚 Billing API ??gate red: bun run gate:phase-03 [ Run gate ]
Phase 5 繚 App icon ??written checks, not checked [ Checked ]
- 哪个阶段: 当前 git 分支会与 wiki/plan.md 中的 Branch: 行匹配。离开阶段分支后,mod 不会执行。/gate 3 会固定阶段,/gate auto 取消固定。
- 哪些命令: 门禁中用反引号标出的片段,只要第一个词是真实可执行文件,就会被识别。部署、发布、安装、发送和 rm 风格的命令不会运行,含有 <placeholders> 的片段也不会运行。
- 绿色: 每条门禁命令都在你当前拥有的文件上通过。它会比较文件内容(在命令运行前取得的 git tree id),所以提交不会使通过结果过期,但任何编辑都会使它过期。wiki/ 会被排除,因为 forge 会在门禁运行后写入构建日志和学习记录。通过结果会跨工作阶段保存。
- 证据:
- Claude Bash 运行只有在门禁命令是整段命令的一部分、从储存库根目录运行并以前台方式完成时才算数。前面只能是 && 或 ;,后面只能是 &&。因此 true || bun test、echo bun test、cd sub && bun test、bun test | tail,以及移到背景执行的运行都不算。
- 像 bun run gate && tsc --noEmit 这样的链会计算其中每条门禁命令。链失败时,只有最后一条命令会标记为失败。
- 子 agent 的运行只有在前面明确写出 cd <repo root> && 时才算数,因为它的 shell 目录未知。
- 运行结果按储存库和命令保存,不论当前在哪个分支。因此,git switch -c phase/3-?圳 后立刻进行的运行也会被保留。
- /gate(或 Run gate)也算数。它会列出命令,并在运行前询问。
- forge stage 的守卫: 每个 forge 阶段都会以结果行结尾:FORGE_RESULT {"skill":"...","phase":3,"gate":"green",...}。当该行写着 gate 为 green 时,会根据当前文件上实际运行的内容检查。如果不成立,阶段会被退回一次,列出缺少的内容,并要求运行门禁,或把 gate 改为 red 或 deferred。阶段编号取自结果行,所以 forge-ship 合并到 main 后仍会按阶段检查。主工作阶段和子 agent 都适用。诚实的 red、deferred 或 blocked 行总能通过。
- 其他地方的守卫: 没有结果行时,它会观察短语。Claude 表示阶段完成、可以审查或发布,或表示门禁通过,而实际并未变绿时,系统会退回一次。停下来提问的回合不会被退回。
- 已写检查: 命令无法证明的文字检查会随每份报告显示。完全没有命令的门禁会等待你按下 Checked。
- Run gate: 色带按钮或 /gate 会立即在当前文件上运行阶段门禁命令,并在色带中显示结果。这是你不必询问 Claude 也能检查的方式,例如在相信“完成”之前检查。大多数时候你不需要按它,Claude 的运行会自行更新色带。
命令:/gate 运行门禁(会先询问),/gate status 只报告不运行,/gate <n> 在离开阶段分支时固定阶段 n,/gate auto 取消固定。
它如何融入 forge 循环
- forge-plan 为每个阶段写入 Verifiable gate:。mod 只读取它。
- forge-build 在交接前必须运行一次门禁。它的结果行和“交给审查”的声明都会被检查。
- forge-review 会在运行时验证和修复循环中重新运行门禁,每次运行都会更新色带。
- forge-ship 会先 rebase,这会改变文件,使旧的通过结果过期。ship 会按自身规则重新运行门禁,然后再落地。合并后,结果行仍会按阶段编号检查。
- crack-on 和 Arnold workers 无人值守运行。守卫会检查其中每个 green。
在正常循环中,这个 mod 主要是确认 skills 已经执行的内容。它的价值在于显示状态、捕捉跳过或过期的运行,以及跨工作阶段记住通过结果。
限制:
- 只检查退出码,不检查门禁引用的预期输出。
- 只有手动检查的门禁无法验证。
- 如果门禁在 .gitignore 外写入文件,运行后的 tree 会改变,因此永远不会读到 green;请忽略这些输出。
- 子 agent 如果在自己的 worktree 中运行,除非 cd 到这个储存库的根目录,否则不会被追踪。
- 色带跟随分支。离开阶段分支时,可以用 /gate <n> 固定阶段。
关闭 guardDoneClaims 设置即可停用两种守卫(结果行和短语)。色带和 /gate 仍会继续工作。
安装方式见 ../README.md。
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add tinyorbit-ai/skills claude plugin install forge-gate
原文 / README
forge-gate
The forge phase gate, enforced inside Claude Code.
Phase 3 · Billing API ✓ gate green 4m ago + written checks [ Run gate ]
Phase 3 · Billing API ◐ changed since the last run [ Run gate ]
Phase 3 · Billing API ✗ gate red: bun run gate:phase-03 [ Run gate ]
Phase 5 · App icon ◐ written checks, not checked [ Checked ]
- Which phase: your current git branch, matched against the
**Branch:**lines inwiki/plan.md. Off a phase branch the mod does nothing./gate 3pins a phase and/gate autounpins it. - Which commands: the gate's backticked spans whose first word is a real
executable. Deploy, release, install, send and rm-style commands are never run, and
nor are spans with
<placeholders>. - Green: every gate command passed on exactly the files you have now. It
compares file contents (a git tree id, taken before the command ran), so committing
doesn't make a pass stale, but any edit does.
wiki/is left out, because forge writes its build log and learnings after the gate runs. A pass is remembered across sessions. - Evidence:
- A Claude Bash run counts when the gate command is a whole piece of the command,
run in the repo root, finished in the foreground. Only
&∨may come before it, and only&&after it. Sotrue || bun test,echo bun test,cd sub && bun test,bun test | tailand a run moved to the background don't count. - A chain like
bun run gate && tsc --noEmitcounts every gate command in it. If the chain fails, only its last command is marked failed. - A subagent's run counts only with an explicit
cd <repo root> &&in front, since its shell directory isn't known. - Runs are kept per repo and command, whichever branch is out. So a run made right
after
git switch -c phase/3-…counts. /gate(or Run gate) also counts. It lists the commands and asks before it runs anything.
- A Claude Bash run counts when the gate command is a whole piece of the command,
run in the repo root, finished in the foreground. Only
- The guard, for forge stages: every forge stage ends with a result line,
FORGE_RESULT {"skill":…,"phase":3,"gate":"green",…}. When that line says"gate":"green", it's checked against what actually ran on the current files. If it isn't true, the stage is sent back once with what's missing, told to run the gate or to change"gate"to"red"or"deferred". The phase is the one the line names, so forge-ship's line is still checked after it lands on main. It works in the main session and in subagents. An honestred,deferredorblockedline always passes. - The guard, everywhere else: with no result line, it watches for phrases. When Claude says the phase is done, ready for review or ship, or that the gate passes, while it isn't green, it's sent back once. A turn that stops to ask a question is never sent back.
- Written checks: prose the commands can't prove is shown with every report. A gate with no commands at all waits for you to press Checked.
- Run gate (the band's button, or
/gate) runs the phase's gate commands now, on the files as they are, and shows the result in the band. It's your own way to check without asking Claude, e.g. before trusting a "done". Most of the time you never press it: Claude's runs update the band by themselves.
Commands: /gate runs the gate (it asks first), /gate status reports without
running, /gate <n> pins phase n when you're off its branch, /gate auto unpins.
How it fits the forge loop
- forge-plan writes each phase's
**Verifiable gate:**. The mod only reads it. - forge-build must run the gate once before handing off. Its result line and its "handing to review" claim are checked.
- forge-review reruns the gate during runtime verification and its fix loop. Each run updates the band.
- forge-ship rebases first, which changes the files, so the old pass goes stale. Ship reruns the gate as its own rules require, then lands. Its result line is checked by phase number after the merge.
- crack-on and Arnold workers run unattended. The guard is what checks each "green" there.
Inside the normal loop the mod mostly confirms what the skills already do. Its value is the visible state, catching a skipped or stale run, and remembering a pass across sessions.
Limits:
- Exit codes only, so a gate's quoted expected output isn't checked.
- Gates with only manual checks can't be verified.
- A gate that writes files outside
.gitignorechanges the tree it ran on, so it never reads green. Ignore its outputs. - A subagent in its own worktree isn't tracked unless it
cds to this repo's root. - The band follows the branch. Off a phase branch,
/gate <n>pins a phase.
Turn the guardDoneClaims setting off to disable both guards (result lines and
phrases). The band and /gate keep working.
Install: see ../README.md.
