将项目级的 Ratchet/约定检测方法论融入 req-test-gate 技能, 通过 /req 流程三个节点自动触发(dev 环境检测、cr 约定建议、test Gate 0B), 无需手动记忆执行。 新增文档:harness-engineering.md、ratchet-pattern.md、convention-flow.md、 project-bootstrap.md 及 4 个模板(ratchet/convention 脚本、GATES.md、pre-commit)。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
103 lines
3.0 KiB
Markdown
103 lines
3.0 KiB
Markdown
# GATES.md Template
|
||
|
||
项目质量门禁文档模板。放置于 `docs/quality/GATES.md`。
|
||
|
||
## 使用方法
|
||
|
||
1. 复制下方模板到项目的 `docs/quality/GATES.md`
|
||
2. 替换 `{PLACEHOLDER}` 为项目特定值
|
||
3. 根据项目实际情况增删 Gate
|
||
|
||
## 模板
|
||
|
||
```markdown
|
||
# Quality Gates
|
||
|
||
Quality gates are automated checks that code must pass before it can be merged or deployed.
|
||
|
||
## Gate Overview
|
||
|
||
| Gate | Name | Where | What it catches |
|
||
|------|------|-------|-----------------|
|
||
| 0 | Pre-commit | Local (husky) | Formatting, lint errors |
|
||
| 1 | CI Lint | {CI_SYSTEM} | {LINT_TOOLS} |
|
||
| 2 | Convention & Architecture | {CI_SYSTEM} | New violations of established rules |
|
||
| 3 | Unit Tests | CI / local | Logic bugs, regressions |
|
||
| 4 | Security Scan | CI | Dependency vulnerabilities |
|
||
| 5 | Build | CI | Compilation errors |
|
||
|
||
## Gate 0: Pre-commit (Local)
|
||
|
||
Runs automatically on every `git commit` via husky + lint-staged.
|
||
|
||
{FRONTEND_SECTION — include if applicable}
|
||
**Frontend** (`{FRONTEND_GLOBS}`):
|
||
- {LINT_TOOL} with {LINT_FLAGS}
|
||
- {FORMATTER}
|
||
|
||
{BACKEND_SECTION — include if applicable}
|
||
**Backend** (`{BACKEND_GLOBS}`):
|
||
- {FORMAT_TOOL} (auto-format)
|
||
- {ANALYSIS_TOOL} (static analysis)
|
||
|
||
**Bypass** (emergency only): `git commit --no-verify`
|
||
|
||
## Gate 1: CI Lint
|
||
|
||
Runs on pull requests via {CI_SYSTEM}.
|
||
|
||
- **Backend**: {BACKEND_LINT_COMMANDS}
|
||
- **Frontend**: {FRONTEND_LINT_COMMANDS}
|
||
|
||
## Gate 2: Convention & Architecture Checks
|
||
|
||
Runs on pull requests via {CI_SYSTEM}.
|
||
|
||
{LIST_EACH_CHECK_SCRIPT}
|
||
- `./scripts/check-{name}.sh check` — {description}
|
||
|
||
See project CLAUDE.md and docs/architecture/ for rule details.
|
||
|
||
## Gates 3-5: Testing, Security, Build
|
||
|
||
These gates are enforced via the `/req test` workflow:
|
||
|
||
1. **Gate 3**: Unit test generation and execution
|
||
2. **Gate 4**: Security regression scan
|
||
3. **Gate 5**: E2E smoke test + final report
|
||
|
||
See the dev-test skill documentation for details.
|
||
|
||
## Local Commands
|
||
|
||
\`\`\`bash
|
||
# Gate 0: Format & Lint
|
||
{LOCAL_LINT_COMMANDS}
|
||
|
||
# Gate 2: Convention checks
|
||
{LOCAL_CHECK_COMMANDS}
|
||
|
||
# Gate 3: Unit tests
|
||
{LOCAL_TEST_COMMANDS}
|
||
\`\`\`
|
||
```
|
||
|
||
## Placeholder 说明
|
||
|
||
| Placeholder | 含义 | 示例 |
|
||
|-------------|------|------|
|
||
| `{CI_SYSTEM}` | CI 系统名称 | `Gitea Actions`, `GitHub Actions` |
|
||
| `{LINT_TOOLS}` | lint 工具列表 | `golangci-lint, ESLint, TypeScript errors` |
|
||
| `{FRONTEND_GLOBS}` | 前端文件 glob | `*.ts, *.tsx`, `*.vue` |
|
||
| `{BACKEND_GLOBS}` | 后端文件 glob | `*.go` |
|
||
| `{LINT_TOOL}` | lint 工具 | `ESLint` |
|
||
| `{LINT_FLAGS}` | lint 参数 | `--fix --max-warnings 0` |
|
||
| `{FORMATTER}` | 格式化工具 | `Prettier`, `gofmt` |
|
||
|
||
## 注意事项
|
||
|
||
- **此文档的 Gate 编号是项目级的**(描述项目基础设施层级),与 req-test-gate 技能的 Gate 0-5(需求级测试门禁)是两套独立体系
|
||
- Gate 0-2 由 harness engineering 方法论管理(pre-commit → CI lint → ratchet/约定检测)
|
||
- Gate 3-5 由 `/req test` 流程管理(单元测试 → 安全扫描 → 构建验证)
|
||
- 两者互补,不要混淆编号
|