gate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gate — Self-Healing Verification

Gate——自修复验证机制

Run checks, read errors, fix them, repeat. Prove code WORKS by executing it.
运行检查、读取错误、修复问题、重复执行。通过执行代码来证明其可用性。

Anti-Shortcut Rules

防捷径规则

  1. NEVER declare PASS from reading source. Execute and observe output.
  2. NEVER declare PASS without command output. "It should work" is not evidence.
  3. If a check can't execute, report BLOCKED — never fake PASS.
  1. 绝对不要仅通过阅读代码就判定通过。必须执行代码并观察输出。
  2. 绝对不要在没有命令输出的情况下判定通过。“应该能运行”不能作为依据。
  3. 如果无法执行检查,需报告为阻塞状态——绝对不要伪造通过结果。

Step 0: Get Commands

步骤0:获取命令

Read
.claude/project.json
for build commands. If missing, init from the plugin CLI:
bash
${CLAUDE_PLUGIN_ROOT}/scripts/cli init
Or run checks directly via the plugin CLI:
bash
${CLAUDE_PLUGIN_ROOT}/scripts/cli gate        # lint + typecheck + build + test
${CLAUDE_PLUGIN_ROOT}/scripts/cli gatekeep -g  # same, with PASS/FAIL report
${CLAUDE_PLUGIN_ROOT}/scripts/cli gatekeep -l  # lint only
${CLAUDE_PLUGIN_ROOT}/scripts/cli gatekeep -t  # test only
读取
.claude/project.json
文件获取构建命令。如果文件缺失,通过插件CLI初始化:
bash
${CLAUDE_PLUGIN_ROOT}/scripts/cli init
或者直接通过插件CLI运行检查:
bash
${CLAUDE_PLUGIN_ROOT}/scripts/cli gate        # 代码检查 + 类型校验 + 构建 + 测试
${CLAUDE_PLUGIN_ROOT}/scripts/cli gatekeep -g  # 同上,附带通过/失败报告
${CLAUDE_PLUGIN_ROOT}/scripts/cli gatekeep -l  # 仅执行代码检查
${CLAUDE_PLUGIN_ROOT}/scripts/cli gatekeep -t  # 仅执行测试

The Loop

循环流程

Run up to 4 iterations:
  1. Execute: lint → typecheck → build → test
  2. All pass? → GATE PASSED — stop.
  3. Any fail? → Read full error, fix it, run again.
最多运行4轮迭代:
  1. 执行:代码检查→类型校验→构建→测试
  2. 全部通过?→Gate验证通过——停止流程。
  3. 有失败项?→读取完整错误信息,修复后重新运行。

Fix Rules

修复规则

Error TypeFixDon't
Type errorsFix the type, add the importUse
@ts-ignore
Build errorsFix imports, exports, modulesSkip the check
Lint errorsFix the actual issueBlanket
disable
Test failuresFix the code or the testDelete the test
NEVER change business logic during gate. Only fix types, imports, lint.
错误类型修复方式禁止操作
类型错误修复类型问题,添加缺失的导入不要使用
@ts-ignore
构建错误修复导入、导出、模块问题跳过检查步骤
代码检查错误修复实际问题全局禁用检查规则
测试失败修复代码或测试用例删除测试用例
在Gate验证期间绝对不要修改业务逻辑。仅允许修复类型、导入、代码检查相关问题。

Circuit Breaker

熔断机制

After 4 iterations without full pass:
  1. Report which checks still fail with last error output
  2. Do NOT fake a PASS
  3. Inform user or team lead
经过4轮迭代仍未全部通过时:
  1. 报告仍未通过的检查项及最后一次错误输出
  2. 绝对不要伪造通过结果
  3. 通知用户或团队负责人

CLI Reference

CLI参考

FlagWhat
-l
Lint only
-c
Typecheck only
-b
Build only
-t
Tests only
-a
App startup (dev server + health check)
-u
UI tests (Playwright/Cypress)
-g
Full gate: lint + typecheck + build + test
--all
Everything including app + UI
参数说明
-l
仅执行代码检查
-c
仅执行类型校验
-b
仅执行构建
-t
仅执行测试
-a
应用启动检查(开发服务器 + 健康检查)
-u
UI测试(Playwright/Cypress)
-g
完整Gate验证:代码检查 + 类型校验 + 构建 + 测试
--all
执行所有检查,包括应用启动和UI测试