ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 tinyorbit-ai

forge-gate

強制執行 forge 階段閘門:只針對你現有的檔案,顯示目前階段的 Verifiable gate 是否為綠色;如果不是,就退回聲稱 gate 為 green 的 forge 階段結果。執行 /gate。

tinyorbit-ai@tinyorbit-ai

tinyorbit-ai/skills/tree/main/mods/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: 列比對。離開階段分支後,外掛不會執行。/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:,外掛只讀取它。
  • forge-build 在交接前必須執行一次閘門;它的結果列和“交給審查”的聲明都會檢查。
  • forge-review 會在執行階段驗證和修復迴圈中重新執行閘門,每次都更新色帶。
  • forge-ship 會先 rebase,改變檔案,使舊的通過結果過期;ship 會依自己的規則重新執行閘門,再落地。合併後結果列仍依階段編號檢查。
  • crack-on 和 Arnold workers 無人值守執行,守衛會檢查其中每個 green。

在正常迴圈中,這個外掛主要確認 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 in wiki/plan.md. Off a phase branch the mod does nothing. /gate 3 pins a phase and /gate auto unpins 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 && or ; may come before it, and only && after it. So true || bun test, echo bun test, cd sub && bun test, bun test | tail and a run moved to the background don't count.
    • A chain like bun run gate && tsc --noEmit counts 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.
  • 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 honest red, deferred or blocked line 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 .gitignore changes 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.

更多類似作品