Skip to content

Commit 5bc0571

Browse files
author
Hackercds
committed
init: vibe coding 企业级起点 (SDD+TDD+Harness+CI+AgentOps)
- CLAUDE.md: Claude Code 入口 + 引用 AGENTS.md - AGENTS.md: 跨工具通用工程规则 - materials/01-09: 9 份 SKILL 本体(spec/测试/契约/选型/Rules/审查/CI/AgentOps/Harness) - code/backend: 成品 Spec 范例 + FastAPI 骨架 - code/frontend: 契约驱动的前端说明 - .github/: CI 12 门硬关 + PR/Issue 模板 - LICENSE: MIT
1 parent 29fc4d8 commit 5bc0571

32 files changed

Lines changed: 2899 additions & 0 deletions

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# EditorConfig · 工程基线(多 IDE 一致)
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.py]
13+
indent_size = 4
14+
max_line_length = 100
15+
16+
[*.md]
17+
trim_trailing_whitespace = false

.github/ISSUE_TEMPLATE/bug.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Bug 报告
2+
3+
## 复现步骤
4+
5+
1.
6+
2.
7+
3.
8+
9+
## 预期行为
10+
11+
12+
13+
## 实际行为
14+
15+
16+
17+
## 环境
18+
19+
- 操作系统:
20+
- 运行时版本(Python/Node/Go ……):
21+
- Agent / 模型(如果是 agent 生成的):
22+
- 关联 PR / commit:
23+
24+
## 严重程度
25+
26+
- [ ] 阻塞
27+
- [ ]
28+
- [ ]
29+
- [ ]
30+
31+
## 截图 / 日志 / Trace
32+
33+
<!-- 贴关键日志或 trace_id(见 08_AgentOps) -->
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Spec 提案(新功能 / 大改)
2+
3+
> **本仓库的所有功能/大改都必须以 Spec 提案开始**——见 [materials/01](../materials/01_spec模板.md)
4+
5+
## 关联
6+
7+
- **Spec 草案**[docs/spec/SPEC-XXX.md](../docs/spec/SPEC-XXX.md)(草案状态)
8+
- **关联 issue**
9+
10+
## 一句话目标
11+
12+
<!-- 不超过两行 -->
13+
14+
## 范围
15+
16+
### 必须有
17+
-
18+
19+
### 明确不做(防 AI 自由发挥)
20+
-
21+
22+
## 数据模型
23+
24+
| 字段 | 类型 | 约束 |
25+
|---|---|---|
26+
| | | |
27+
28+
## 端点 / 接口
29+
30+
| 动作 | 输入 | 成功返回 | 失败 |
31+
|---|---|---|---|
32+
| | | | |
33+
34+
## 边界
35+
36+
-
37+
38+
## 验收标准(DoD)
39+
40+
- [ ]
41+
42+
## 自检
43+
44+
- [ ] 每条规则能写成测试
45+
- [ ] 2 分钟内可审完
46+
- [ ] 范围划死

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!-- .github/PULL_REQUEST_TEMPLATE.md -->
2+
3+
## 关联
4+
5+
- **Spec**[docs/spec/SPEC-XXX.md](../docs/spec/SPEC-XXX.md)
6+
- **Issue**:#XXX
7+
- **ADR**(如有):[docs/adr/XXXX.md](../docs/adr/XXXX.md)
8+
9+
## 动机
10+
11+
为什么改?改了什么问题?背景是什么?
12+
13+
## 改动
14+
15+
- 改动 1
16+
- 改动 2
17+
- 改动 3
18+
19+
## 影响范围
20+
21+
- 影响的下游 / 调用方:
22+
- 是否需要数据迁移:
23+
- 是否需要客户端升级:
24+
- 是否需要发公告 / changelog:
25+
26+
## 测试
27+
28+
- 单元 / 集成:
29+
- 契约(OpenAPI):
30+
- E2E(关键旅程):
31+
- 覆盖率:__%(降覆盖需说明)
32+
- **故意改坏自检**:✅ / ❌(描述)
33+
34+
## 风险与回滚
35+
36+
- **风险等级**:低 / 中 / 高 / **不可逆**
37+
- **不可逆操作**:(无 / 列出 + 确认人)
38+
- **回滚方案**
39+
- **feature flag**
40+
41+
## 文档
42+
43+
- README / ADR / Runbook / Changelog:(已更新 / N/A)
44+
45+
## Checklist(agent-assisted PR 必勾)
46+
47+
- [ ] 本 PR 由 AI 协助完成,run_id:<run_id>
48+
- [ ] CI 12 门硬关全过(test / contract / lint / security / build)
49+
- [ ] AI 自审 prompt 已跑([06 §第一关](../materials/06_审查双关_prompt与checklist.md)
50+
- [ ] 上方所有强制项已勾选
51+
- [ ] 至少 1 位 reviewer approve(**高风险 2 位**
52+
- [ ] 已读 [AGENTS.md](../AGENTS.md)

.github/workflows/ci.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: CI · 12 门硬关
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
# 取消旧 run,避免重复跑
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
# 通用:checkout + 缓存
15+
prepare:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with: { fetch-depth: 0 } # 需要 diff
20+
- uses: actions/setup-python@v5
21+
with: { python-version: '3.10', cache: pip }
22+
- run: pip install -r requirements.txt -r requirements-dev.txt
23+
- uses: actions/cache@v4
24+
with:
25+
path: .pytest_cache
26+
key: pytest-${{ github.sha }}
27+
- uses: actions/cache@v4
28+
with:
29+
path: ~/.cache/pip
30+
key: pip-${{ hashFiles('requirements*.txt') }}
31+
32+
test:
33+
needs: prepare
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: actions/setup-python@v5
38+
with: { python-version: '3.10', cache: pip }
39+
- run: pip install -r requirements.txt -r requirements-dev.txt
40+
- name: 单元 + 集成
41+
run: pytest -q
42+
- name: 覆盖率门槛
43+
run: pytest --cov=app --cov-fail-under=80
44+
45+
contract:
46+
needs: prepare
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
with: { fetch-depth: 0 }
51+
- uses: actions/setup-python@v5
52+
with: { python-version: '3.10' }
53+
- run: pip install oasdiff spectral-cli
54+
- name: 契约 diff
55+
run: oasdiff diff origin/main HEAD --format github
56+
- name: 契约 lint
57+
run: spectral lint openapi.yaml --ruleset .spectral.yaml
58+
59+
lint:
60+
needs: prepare
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v4
64+
- uses: actions/setup-python@v5
65+
with: { python-version: '3.10' }
66+
- run: pip install ruff bandit
67+
- name: ruff
68+
run: ruff check .
69+
- name: mypy
70+
run: mypy app/
71+
72+
security:
73+
needs: prepare
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v4
77+
with: { fetch-depth: 0 }
78+
- uses: actions/setup-python@v5
79+
with: { python-version: '3.10' }
80+
- run: pip install bandit safety
81+
- name: SAST (bandit)
82+
run: bandit -r app/ -ll
83+
- name: SCA (safety)
84+
run: safety check
85+
- name: Secrets (gitleaks)
86+
uses: gitleaks/gitleaks-action@v2
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
90+
build:
91+
needs: [test, contract, lint, security]
92+
runs-on: ubuntu-latest
93+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
94+
steps:
95+
- uses: actions/checkout@v4
96+
- name: 构建镜像
97+
run: docker build -t app:${{ github.sha }} .
98+
- name: 镜像扫描
99+
uses: aquasecurity/trivy-action@master
100+
with:
101+
image-ref: app:${{ github.sha }}
102+
severity: HIGH,CRITICAL
103+
exit-code: '1'
104+
ignore-unfixed: true

.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# OS
2+
.DS_Store
3+
Thumbs.db
4+
5+
# Editors
6+
.vscode/
7+
.idea/
8+
*.swp
9+
*~
10+
11+
# Python
12+
__pycache__/
13+
*.py[cod]
14+
*.egg-info/
15+
.venv/
16+
venv/
17+
.pytest_cache/
18+
.mypy_cache/
19+
.ruff_cache/
20+
htmlcov/
21+
.coverage
22+
23+
# Node
24+
node_modules/
25+
.next/
26+
dist/
27+
build/
28+
29+
# Go
30+
vendor/
31+
32+
# Secrets(双重保险:CI 也会扫)
33+
.env
34+
.env.*
35+
!.env.example
36+
37+
# 自动生成(行级注释里可豁免)
38+
# gen/ # 团队策略:typed client 是否入仓由团队决定
39+
40+
# AI 后备(断网用,不入仓)
41+
_backup_现场产物/
42+
43+
# Claude 本地个人配置(不入仓;团队规则走 AGENTS.md / CLAUDE.md)
44+
.claude/settings.local.json

0 commit comments

Comments
 (0)