gatekeeper

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gatekeeper 总控路由与全局行为规则

Gatekeeper Master Control Routing and Global Behavior Rules

本文件是迭代流水线的单一规则源 + 总控路由;所有子 skill 的职责见第八节,整体规则以下各节为准。 版本编号 = 当前 Git 分支名(只读
git branch --show-current
获取;失败/空 → 提示人工切换分支,禁止用空串/猜测值)。 路径约定(全局生效)
项目根/...
一律指 Git 仓库根目录(
AGENTS.md
所在目录,如
项目根/.gatekeeper/
);
gatekeeper
skill 的
template/
指该 skill 自身资源目录,两者不可混淆。
This document is the single rule source + master control routing for the iteration pipeline; the responsibilities of all sub-skills are listed in Section 8, and the overall rules are subject to the following sections. Version number = current Git branch name (obtained by reading
git branch --show-current
only; if failed/empty → prompt manual branch switch, prohibit using empty string/guessed value). Global Path Convention:
Project Root/...
always refers to the Git repository root directory (where
AGENTS.md
is located, e.g.,
Project Root/.gatekeeper/
);
template/
of the
gatekeeper
skill refers to its own resource directory, and the two must not be confused.

When to Use

When to Use

  1. 仅人工
    /gatekeeper
    命令触发(
    agents/openai.yaml
    allow_implicit_invocation: false
    ,禁止 Agent 隐式调用);
  2. 用于推进迭代、不确定当前进度、或从中断处继续。
  1. Manual trigger only via the
    /gatekeeper
    command (set
    allow_implicit_invocation: false
    in
    agents/openai.yaml
    to prohibit implicit invocation by Agent);
  2. Used to advance iteration, confirm current progress, or resume from an interrupted point.

一、固定迭代流水线(强制卡点 + 全留痕)

1. Fixed Iteration Pipeline (Mandatory Checkpoints + Full Traceability)

人工需求确认
Agent概要设计
(小改动可跳过)→
人工评审留痕+放行
Agent编码+单元测试
Agent dev环境测试(review.md 第三部分留痕)
人工代码评审留痕+放行
人工提交合并+部署staging
人工 staging测试验证(test.md留痕)
人工辅助部署prod收尾
  • 需求确认判据:
    requirement.md
    无 HTML 占位符,且「需求确认人/日期」已填。
  • 聊天提及修改:需求/概要设计阶段 → 禁止直接改代码,要求人工补齐 requirement.md;编码阶段小改动(不涉及已评审接口/数据结构/设计)→ 可直接改码并走代码评审。
  • 小改动迭代:progress.md 阶段2 可标「跳过」,跳过概要设计与设计评审,直接进入 T03。
  • T07 问题归属:需求已有 → 回流阶段3/4 修复;需求未覆盖 → 人工补需求后重新开发,无需全流程重走。
  • 历史归档:
    项目根/.gatekeeper/history/
    保存已完结迭代,迭代中完全忽略。T08 完成或
    /gatekeeper-abort
    中止后,整体迁移至
    项目根/.gatekeeper/history/${版本编号}/
Manual Requirement Confirmation
Agent High-Level Design
(can be skipped for minor changes) →
Manual Review Traceability + Approval
Agent Coding + Unit Testing
Agent Dev Environment Testing (traceability in Part 3 of review.md)
Manual Code Review Traceability + Approval
Manual Commit Merge + Staging Deployment
Manual Staging Testing Verification (traceability in test.md)
Manual-Assisted Production Deployment Finalization
.
  • Requirement confirmation criteria:
    requirement.md
    has no HTML placeholders, and "Requirement Confirmer/Date" is filled.
  • Modifications mentioned in chat: In requirement/high-level design phase → direct code modification is prohibited, require manual completion of requirement.md; minor changes in coding phase (not involving reviewed interfaces/data structures/design) → can modify code directly and proceed with code review.
  • Minor change iteration: Mark "Skipped" in Phase 2 of progress.md, skip high-level design and design review, directly enter T03.
  • T07 issue attribution: If covered by requirements → return to Phase 3/4 for repair; if not covered by requirements → manual requirement supplement before re-development, no need to re-run the full process.
  • Historical archiving: Completed iterations are stored in
    Project Root/.gatekeeper/history/
    , and are completely ignored during iteration. After T08 is completed or
    /gatekeeper-abort
    is executed to terminate, migrate the entire iteration to
    Project Root/.gatekeeper/history/${version number}/
    .

二、评审与测试留痕强制执行规则(核心)

2. Mandatory Rules for Review and Testing Traceability (Core)

  1. 评审唯一依据
    review.md
    ;staging 测试唯一依据
    test.md
    ;dev 测试记录在
    review.md
    第三部分。忽略聊天临时评语。
  2. 评审两轮(概要设计、代码)+ 测试一轮(staging);均支持多轮整改复核,轮次记入同一表「轮次」列,不复制表头。
  3. 工作逻辑:只读【状态=待整改】行针对性整改、不新增功能;整改后主动提示人工复核,不私自判定完成;必须人工标【复核通过】才结束本轮;误报置「无需整改」附理由,由人工裁决,不得硬改或私自清空。
  4. 禁止无依据整改、超范围整改、私自清空问题记录。
  5. 修复后输出修复清单,告知人工复核。
  6. 问题全部【复核通过】+ 人工更新 progress.md 阶段 + 下发推进指令,方可进入下一阶段;AI 不主动轮询、不自行推进。
  7. 代码评审最小要素(闸门2 强制):放行前①按 design.md「变更点清单」逐条核对 diff 范围,识别超范围改动;②对外接口契约变更须同步
    crmeb/apidoc/
    并在整改结果声明;③测试覆盖说明。空表/零问题不得直接通过;「零问题」须人工在放行备注写明核对范围与抽样项,人工至少抽样核对 1-2 个变更点。
  8. dev 测试与验收标准映射(T04 强制):review.md 第三部分每条测试项须填「对应验收§」(对应 requirement.md 七、验收标准);存在未映射验收标准即视为 dev 测试不完整。
  9. staging 归属判定(test.md 强制):判「需求已有 / 需求未覆盖」前必须先 read requirement.md 原文引用条目;归属列仅允许该两枚举值,非法值主动提示人工修正;修复致接口契约变化须声明 apidoc 已同步。
  10. 跨迭代回归(强制):design.md 变更点清单须声明「关联历史迭代回归项」;触及上期功能时 dev 测试必须回测并在 review.md ③ 留痕,否则 dev 测试不完整。
  1. The only basis for review is
    review.md
    ; the only basis for staging testing is
    test.md
    ; dev testing records are in Part 3 of
    review.md
    . Ignore temporary chat comments.
  2. Two rounds of review (high-level design, code) + one round of testing (staging); multiple rounds of rectification and review are supported, and the round number is recorded in the "Round" column of the same table, no need to copy the header.
  3. Work logic: Only read and rectify rows with [Status = Pending Rectification] in a targeted manner, no new functions; actively prompt manual review after rectification, do not judge completion privately; this round can only end after manual marking [Review Passed]; mark "No Rectification Needed" with reasons for false reports, and let manual personnel decide, do not modify or clear privately.
  4. Prohibit rectification without basis, out-of-scope rectification, and private clearing of issue records.
  5. Output a repair list after fixing, inform manual personnel for review.
  6. Only after all issues are [Review Passed] + manual update of progress.md phase + issuance of advance instruction can enter the next phase; AI does not actively poll or advance on its own.
  7. Minimum Elements for Code Review (Mandatory for Gate 2): Before approval, ① check the diff scope item by item according to the "Change List" in design.md to identify out-of-scope changes; ② interface contract changes must be synchronized to
    crmeb/apidoc/
    and stated in the rectification result; ③ test coverage description. Empty table/zero issues cannot be approved directly; for "zero issues", manual personnel must specify the check scope and sampling items in the approval remarks, and manually sample and check at least 1-2 change points.
  8. Dev Testing and Acceptance Standard Mapping (Mandatory for T04): Each test item in Part 3 of review.md must fill in "Corresponding Acceptance §" (corresponding to Section 7, Acceptance Standards in requirement.md); un-mapped acceptance standards mean incomplete dev testing.
  9. Staging Attribution Judgment (Mandatory for test.md): Must read and quote the original entry in requirement.md before judging "Covered by Requirements / Not Covered by Requirements"; only these two enumerated values are allowed in the attribution column, actively prompt manual correction for illegal values; if repair leads to interface contract changes, must state that apidoc has been synchronized.
  10. Cross-Iteration Regression (Mandatory): The change list in design.md must state "Associated Historical Iteration Regression Items"; when touching previous functions, dev testing must retest and leave trace in review.md ③, otherwise dev testing is incomplete.

三、文件读写权限清单

3. File Read/Write Permission List

Agent 仅允许访问以下文件,其余一律只读:
文件可读Agent 写入说明
项目根/.gatekeeper/${版本编号}/requirement.md
❌ 禁止人工编写,Agent 不得修改
项目根/.gatekeeper/${版本编号}/progress.md
(闸门+进度)
❌ 禁止阶段总闸门,仅人工可改
项目根/.gatekeeper/${版本编号}/design.md
Agent 概要设计输出
项目根/.gatekeeper/${版本编号}/review.md
✅ 仅【状态】+【整改结果】两列状态仅允许 待整改→已整改待复核 / 无需整改
项目根/.gatekeeper/${版本编号}/test.md
✅ 仅【状态】+【整改结果】两列同上
项目根/.gatekeeper/history/
❌ 禁止已完结归档,迭代中完全忽略
AGENTS.md
opencode.json
项目根/.gatekeeper/*.md
(全局规则)
❌ 禁止全局配置,仅人工可改
Agent is only allowed to access the following files, others are read-only:
FileReadableAgent WritableDescription
Project Root/.gatekeeper/${version number}/requirement.md
❌ ProhibitedWritten manually, Agent cannot modify
Project Root/.gatekeeper/${version number}/progress.md
(Gate + Progress)
❌ ProhibitedPhase master gate, only manual modification allowed
Project Root/.gatekeeper/${version number}/design.md
Agent high-level design output
Project Root/.gatekeeper/${version number}/review.md
✅ Only [Status] + [Rectification Result] columnsStatus only allows Pending Rectification → Rectified Pending Review / No Rectification Needed
Project Root/.gatekeeper/${version number}/test.md
✅ Only [Status] + [Rectification Result] columnsSame as above
Project Root/.gatekeeper/history/
❌ ProhibitedCompleted archive, completely ignored during iteration
AGENTS.md
,
opencode.json
,
Project Root/.gatekeeper/*.md
(Global Rules)
❌ ProhibitedGlobal configuration, only manual modification allowed

四、模板与文件生成规则

4. Template and File Generation Rules

模板统一存放于本 skill(
gatekeeper
)的
template/
;实例化 = 复制到
项目根/.gatekeeper/${版本编号}/
+ 替换
${版本编号}
+ 删除「使用说明」冗余文字:
模板实例化目标生成者生成时机
_template-requirement.md
requirement.md人工初始化(
gatekeeper-init
_template-progress.md
progress.md人工初始化(
gatekeeper-init
_template-design.md
design.mdAgent阶段2(
gatekeeper-next
_template-review.md
review.mdAgent阶段5(
gatekeeper-next
_template-test.md
test.mdAgent阶段7(
gatekeeper-next
Templates are uniformly stored in
template/
of this skill (
gatekeeper
); instantiation = copy to
Project Root/.gatekeeper/${version number}/
+ replace
${version number}
+ delete redundant "Usage Instructions" text:
TemplateInstantiation TargetGeneratorGeneration Timing
_template-requirement.md
requirement.mdManualInitialization (
gatekeeper-init
)
_template-progress.md
progress.mdManualInitialization (
gatekeeper-init
)
_template-design.md
design.mdAgentPhase 2 (
gatekeeper-next
)
_template-review.md
review.mdAgentPhase 5 (
gatekeeper-next
)
_template-test.md
test.mdAgentPhase 7 (
gatekeeper-next
)

五、单轮对话范围约束

5. Single Round Dialogue Scope Constraints

  1. 一轮对话只完成 1-2 个任务,禁止一次性完结全迭代。
  2. 禁止跨阶段工作:未过概要设计评审(或未标跳过)前不得编码。
  3. 进度、阶段、评审结果全部落盘,不依赖 AI 对话记忆。
  4. Agent 回填整改结果后提示人工提交留痕文件;Git 提交由人工执行。
  1. Only complete 1-2 tasks in one round of dialogue, prohibit completing the entire iteration at once.
  2. Prohibit cross-phase work: Coding is not allowed before passing the high-level design review (or marking as skipped).
  3. Progress, phases, and review results are all recorded in files, do not rely on AI dialogue memory.
  4. After Agent fills in the rectification result, prompt manual personnel to submit traceability files; Git commits are executed manually.

六、阶段流转识别

6. Phase Transition Identification

  1. 设计评审:停止编码,待人工下发整改指令后读 review.md 问题清单。
  2. 有人工录入【待整改】:逐条修复回填,状态置「已整改待复核」;误报置「无需整改」附理由。
  3. 人工复核:通过标「复核通过」,驳回则问题进入下一轮。
  4. 全部复核通过 + 人工更新 progress.md + 下发推进指令,方可进入下一环节。
  5. 代码评审与设计评审逻辑一致。
  6. staging 测试:人工录 test.md 问题 → Agent 判归属 → 修复回填 → 人工复验复核。
  7. 进度定位:progress.md 不维护「当前阶段」指针,依据各阶段【状态】定位首个未完成阶段行;归档前校验状态与留痕结论一致。
  1. Design review: Stop coding, wait for manual rectification instruction before reading the issue list in review.md.
  2. If [Pending Rectification] is manually entered: Fix and fill in item by item, set status to "Rectified Pending Review"; mark "No Rectification Needed" with reasons for false reports.
  3. Manual review: Mark "Review Passed" if approved, and the issue enters the next round if rejected.
  4. Only after all are reviewed and passed + manual update of progress.md + issuance of advance instruction can enter the next link.
  5. Code review logic is consistent with design review.
  6. Staging testing: Manual personnel enter issues in test.md → Agent judges attribution → Fix and fill in → Manual re-test and review.
  7. Progress Location: progress.md does not maintain a "current phase" pointer, locate the first uncompleted phase row according to the [Status] of each phase; verify that the status is consistent with the traceability conclusion before archiving.

七、Token 消耗优化约束(强制)

7. Token Consumption Optimization Constraints (Mandatory)

  1. 输出规范(P0):回复只输出 变更摘要+增量,禁止全表回显留痕文件;只展示与本次动作相关的行。
  2. 模板头部精简(P0):留痕文件头部说明 1-2 行;实例化时删除「使用说明」冗余。
  3. 增量读取(P1):按【状态=待整改】/最新轮次定位范围,只读待整改行与最新轮次;同轮已读不重复读。
  4. codegraph 收敛(P2):精确符号名 + maxFiles 限制;链路查询优先 trace/callers。
  5. 单一规则源(P0):全局规则统一在本文件,避免重复注入。
  1. Output Specification (P0): Only output change summary + increment in replies, prohibit full table display of traceability files; only show rows related to the current action.
  2. Template Header Simplification (P0): 1-2 lines of header description for traceability files; delete redundant "Usage Instructions" during instantiation.
  3. Incremental Reading (P1): Locate the scope according to [Status = Pending Rectification]/latest round, only read pending rectification rows and the latest round; do not re-read rows already read in the same round.
  4. Codegraph Convergence (P2): Precise symbol names + maxFiles limit; prioritize trace/callers for link queries.
  5. Single Rule Source (P0): Global rules are unified in this document, avoid repeated injection.

八、指令与子 skill 一览

8. Instructions and Sub-skill Overview

子 skill命令职责
gatekeeper-init
/gatekeeper-init
创建
项目根/.gatekeeper/${版本编号}/
,实例化 requirement.md / progress.md 并校验占位符
gatekeeper-fix
/gatekeeper-fix
读取 review/test【待整改】问题,staging 先判归属,针对性修复回填,等人工复核
gatekeeper-next
/gatekeeper-next
确认复核通过后,执行当前阶段任务并实例化所需模板
gatekeeper-abort
/gatekeeper-abort
中止:核对留痕后标记并迁移至 history
gatekeeper-finish
/gatekeeper-finish
归档校验四项齐备后迁移至 history
Sub-skillCommandResponsibility
gatekeeper-init
/gatekeeper-init
Create
Project Root/.gatekeeper/${version number}/
, instantiate requirement.md / progress.md and verify placeholders
gatekeeper-fix
/gatekeeper-fix
Read [Pending Rectification] issues in review/test, judge attribution first for staging, fix and fill in in a targeted manner, wait for manual review
gatekeeper-next
/gatekeeper-next
After confirming review is passed, execute current phase tasks and instantiate required templates
gatekeeper-abort
/gatekeeper-abort
Terminate: After checking traceability, mark and migrate to history
gatekeeper-finish
/gatekeeper-finish
Migrate to history after verifying that four items are complete for archiving

九、总控路由分派(本 skill 核心动作)

9. Master Control Routing Dispatch (Core Action of This Skill)

1. 判断是否有流程

1. Judge Whether a Process Exists

  • 项目根/.gatekeeper/${版本编号}/
    不存在 → 尚无流程,发起
    /gatekeeper-init
    ,停止等人工填 requirement.md。
  • 存在 → 继续。
  • Project Root/.gatekeeper/${version number}/
    does not exist → No process exists, initiate
    /gatekeeper-init
    , stop and wait for manual filling of requirement.md.
  • Exists → Continue.

2. 定位当前阶段

2. Locate Current Phase

  • 只读
    progress.md
    ,定位首个未完成阶段行(见六.7);只读
    review.md
    /
    test.md
    检查【待整改】行。
  • 存在
    .init-incomplete
    标记 → 回流
    gatekeeper-init
    (补齐缺失文件)。
  • Only read
    progress.md
    , locate the first uncompleted phase row (see 6.7); only read
    review.md
    /
    test.md
    to check [Pending Rectification] rows.
  • If
    .init-incomplete
    mark exists → Return to
    gatekeeper-init
    (complete missing files).

3. 分派子 skill(留痕状态优先,命中即停)

3. Dispatch Sub-skill (Traceability Status Priority, Stop Once Hit)

优先级情形分派
1review/test 存在【待整改】
/gatekeeper-fix
2阶段1 需求确认未完成无子 skill:提示人工填 requirement.md
3阶段2 概要设计未完成
/gatekeeper-next
(产出 design.md;小改动可标跳过)
4阶段3 编码+单测未完成
/gatekeeper-next
5阶段4 dev 测试未完成
/gatekeeper-next
6阶段5 代码评审未完成
/gatekeeper-next
(实例化 review.md);待整改回流 fix
7阶段6 提交合并+部署 staging无子 skill:人工执行 git(Agent 不执行)
8阶段7 staging 测试未完成
/gatekeeper-next
(实例化 test.md);待整改回流 fix
9阶段8 收尾且归档条件满足
/gatekeeper-finish
10全部完成提示人工可归档或开新迭代
PriorityScenarioDispatch
1[Pending Rectification] exists in review/test
/gatekeeper-fix
2Phase 1 Requirement Confirmation not completedNo sub-skill: Prompt manual filling of requirement.md
3Phase 2 High-Level Design not completed
/gatekeeper-next
(output design.md; can mark as skipped for minor changes)
4Phase 3 Coding + Unit Testing not completed
/gatekeeper-next
5Phase 4 Dev Testing not completed
/gatekeeper-next
6Phase 5 Code Review not completed
/gatekeeper-next
(instantiate review.md); return to fix if pending rectification
7Phase 6 Commit Merge + Staging DeploymentNo sub-skill: Manual execution of git (Agent does not execute)
8Phase 7 Staging Testing not completed
/gatekeeper-next
(instantiate test.md); return to fix if pending rectification
9Phase 8 Finalization and archiving conditions are met
/gatekeeper-finish
10All completedPrompt manual personnel to archive or start a new iteration

4. 输出

4. Output

  • 只输出:版本编号、当前阶段、分派子 skill 及原因(一行)、后续人工动作;禁止全表回显留痕文件(见七.1)。
  • Only output: Version number, current phase, dispatched sub-skill and reason (one line), subsequent manual actions; prohibit full table display of traceability files (see 7.1).

Pitfalls

Pitfalls

  1. 本 skill 禁止 Agent 自动使用;检测到无流程目录只能发起
    /gatekeeper-init
    ,不得替人工推进需求。
  2. 只做分派,不代行子 skill 动作。
  3. requirement.md / progress.md 由人工维护,Agent 只读不写(见第三节)。
  4. 版本编号目录已存在且无
    .init-incomplete
    时,不回流 init(避免覆盖人工内容)。
  5. 一轮
    /gatekeeper
    只推进当前阶段(见第五节.1)。
  1. This skill prohibits automatic usage by Agent; if no process directory is detected, only
    /gatekeeper-init
    can be initiated, and cannot advance requirements on behalf of manual personnel.
  2. Only perform dispatch, do not act on behalf of sub-skills.
  3. requirement.md / progress.md are maintained manually, Agent is read-only (see Section 3).
  4. If the version number directory exists and there is no
    .init-incomplete
    , do not return to init (avoid overwriting manual content).
  5. One round of
    /gatekeeper
    only advances the current phase (see 5.1).