gate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGate — Self-Healing Verification
Gate——自修复验证机制
Run checks, read errors, fix them, repeat. Prove code WORKS by executing it.
运行检查、读取错误、修复问题、重复执行。通过执行代码来证明其可用性。
Anti-Shortcut Rules
防捷径规则
- NEVER declare PASS from reading source. Execute and observe output.
- NEVER declare PASS without command output. "It should work" is not evidence.
- If a check can't execute, report BLOCKED — never fake PASS.
- 绝对不要仅通过阅读代码就判定通过。必须执行代码并观察输出。
- 绝对不要在没有命令输出的情况下判定通过。“应该能运行”不能作为依据。
- 如果无法执行检查,需报告为阻塞状态——绝对不要伪造通过结果。
Step 0: Get Commands
步骤0:获取命令
Read for build commands. If missing, init from the plugin CLI:
.claude/project.jsonbash
${CLAUDE_PLUGIN_ROOT}/scripts/cli initOr 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读取文件获取构建命令。如果文件缺失,通过插件CLI初始化:
.claude/project.jsonbash
${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:
- Execute: lint → typecheck → build → test
- All pass? → GATE PASSED — stop.
- Any fail? → Read full error, fix it, run again.
最多运行4轮迭代:
- 执行:代码检查→类型校验→构建→测试
- 全部通过?→Gate验证通过——停止流程。
- 有失败项?→读取完整错误信息,修复后重新运行。
Fix Rules
修复规则
| Error Type | Fix | Don't |
|---|---|---|
| Type errors | Fix the type, add the import | Use |
| Build errors | Fix imports, exports, modules | Skip the check |
| Lint errors | Fix the actual issue | Blanket |
| Test failures | Fix the code or the test | Delete the test |
NEVER change business logic during gate. Only fix types, imports, lint.
| 错误类型 | 修复方式 | 禁止操作 |
|---|---|---|
| 类型错误 | 修复类型问题,添加缺失的导入 | 不要使用 |
| 构建错误 | 修复导入、导出、模块问题 | 跳过检查步骤 |
| 代码检查错误 | 修复实际问题 | 全局禁用检查规则 |
| 测试失败 | 修复代码或测试用例 | 删除测试用例 |
在Gate验证期间绝对不要修改业务逻辑。仅允许修复类型、导入、代码检查相关问题。
Circuit Breaker
熔断机制
After 4 iterations without full pass:
- Report which checks still fail with last error output
- Do NOT fake a PASS
- Inform user or team lead
经过4轮迭代仍未全部通过时:
- 报告仍未通过的检查项及最后一次错误输出
- 绝对不要伪造通过结果
- 通知用户或团队负责人
CLI Reference
CLI参考
| Flag | What |
|---|---|
| Lint only |
| Typecheck only |
| Build only |
| Tests only |
| App startup (dev server + health check) |
| UI tests (Playwright/Cypress) |
| Full gate: lint + typecheck + build + test |
| Everything including app + UI |
| 参数 | 说明 |
|---|---|
| 仅执行代码检查 |
| 仅执行类型校验 |
| 仅执行构建 |
| 仅执行测试 |
| 应用启动检查(开发服务器 + 健康检查) |
| UI测试(Playwright/Cypress) |
| 完整Gate验证:代码检查 + 类型校验 + 构建 + 测试 |
| 执行所有检查,包括应用启动和UI测试 |