verify-before-commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill: verify-before-commit
Skill: verify-before-commit
WHAT
WHAT
Purpose và context
目的与上下文
- Purpose: gate every commit — typecheck, lint, test, smoke trước commit; sau commit promote draft lên wiki và đóng vòng đời task.
- Trigger (when to use): After any impl task, before .
git commit - Non-goals: không viết tính năng mới, không bỏ qua bước nào vì "thay đổi nhỏ", không tự đổi state-machine task ngoài lệnh đã khai.
code-logger.py
- 目的: 为每次 commit 设置门禁——在 commit 前执行 typecheck、lint、test、smoke;commit 后将 draft 发布到 wiki,并结束 task 生命周期。
- 触发时机(何时使用): 任何 impl 任务完成后、之前。
git commit - 非目标: 不编写新功能;不因“改动很小”而跳过任何步骤;除已声明的 命令外,不自行更改 task 的 state-machine。
code-logger.py
Mental model
Mental model
diff → typecheck → lint → test → qc-regression → task_lifecycle gate → smoke → commit (why) → promote draft (+ ## Origin) → log + index → task state=donediff → typecheck → lint → test → qc-regression → task_lifecycle gate → smoke → commit (why) → promote draft (+ ## Origin) → log + index → task state=doneInput và output contract
输入与输出约定
| Field | Required? | Ý nghĩa | |
|---|---|---|---|
| In | thay đổi code đã impl | có | đối tượng gate |
| In | draft khớp feature trong | không | không có (hotfix/refactor) → ghi "no draft — <reason>" vào log |
| In | | không | không có → skip step 8 (fail-open) |
| Out | commit | có | message nói why, không what |
| Out | trang wiki đã promote có | khi có draft | |
| Out | | có | cập nhật |
| 字段 | 是否必需 | 含义 | |
|---|---|---|---|
| In | 已实现的代码变更 | 是 | gate 的对象 |
| In | | 否 | 如果没有(hotfix/refactor)→ 在 log 中写入 |
| In | draft frontmatter 中的 | 否 | 如果没有 → 跳过步骤 8(fail-open) |
| Out | commit | 是 | message 说明 why,而不是 what |
| Out | 已发布且包含 | 有 draft 时 | |
| Out | | 是 | 更新 |
Rules và capabilities
规则与能力
- RULE-01 (MUST): All steps mandatory. No exceptions.
- RULE-02 (MUST): Post-commit — mandatory, never skip.
- Capabilities: chạy typecheck/lint/test/smoke của repo (tự dò theo manifest); chạy validator harness nếu có; ghi git commit + wiki + log vòng đời task.
- RULE-01 (MUST):所有步骤均为必选,无例外。
- RULE-02 (MUST):Post-commit 为必选步骤,绝不跳过。
- 能力:根据 manifest 自主检测并运行仓库的 typecheck/lint/test/smoke;如果存在 validator harness,则运行;写入 git commit、wiki 和 log,并记录 task 生命周期。
Failure boundaries
失败边界
- Typecheck/lint/test đỏ → blocked: fix rồi chạy lại, không commit.
- đỏ → blocked (bug đã fix tái phát hoặc chưa fix); chưa có test
qc-regression.py --run→ fail-open, không chặn.qc-* - chặn (task-ID sai state-machine) → blocked; không có file (install cũ) → bỏ qua.
task_lifecycle.py - Không có draft → không promote, ghi lý do vào log (succeeded hẹp). Không có id → skip step 8, không phải lỗi.
task:
- Typecheck/lint/test 失败 → blocked:修复后重跑,不得 commit。
- 失败 → blocked(已修复的 bug 再次出现,或尚未修复);尚无
qc-regression.py --runtest → fail-open,不阻断。qc-* - 阻断(task-ID 的 state-machine 错误)→ blocked;文件不存在(旧版安装)→ 跳过。
task_lifecycle.py - 没有 draft → 不执行发布,在 log 中记录原因(视为范围受限的 succeeded)。没有 id → 跳过步骤 8;这不是错误。
task:
HOW
HOW
Main workflow
主工作流
| Step | Type | Inputs | Action | Outputs/exit | Failure/next |
|---|---|---|---|---|---|
| W01 | deterministic | repo | Type-check (dò lệnh theo repo) | rc 0 | lỗi → fix, lặp |
| W02 | deterministic | repo | Lint | rc 0, ghi chú warning | lỗi → fix, lặp |
| W03 | deterministic | repo | Test + test tái hiện qc-code (3b, nếu có harness) | rc 0 | fail → fix, lặp |
| W04 | deterministic | draft/task | Trụ 3 gate | rc 0 | chặn → blocked |
| W05 | judgment | app | Smoke check golden path end-to-end | golden path chạy | hỏng → fix |
| W06 | effect | diff | Commit, message why | commit hash | — |
| W07 | effect | draft | Promote draft + | trang wiki | không draft → B01 |
| W08 | effect | | Đóng vòng đời task qua | state=done | không id → B02 |
Chi tiết từng bước (nguồn chân lý cho W01–W08; W01–W03 = bước 1–3b, W04 = 4, W05 = 5, W06 = 6 pre-commit, W07 = 6–7 post-commit, W08 = 8):
Pre-commit:
- — detect from repo:
RUN: <type-check-cmd>(package.json) /npx tsc --noEmit(go.mod). Fix all errors.go build ./... - — detect:
RUN: <lint-cmd>/npx eslint src/. Fix errors; note warnings.go vet ./... - — detect:
RUN: <test-cmd>/npm test. Fix failures. 3b. Test tái hiện qc-code (nếu có harness):go test ./...— chạy các testRUN: [ -f harness/scripts/qc-regression.py ] && python3 harness/scripts/qc-regression.py --rundoqc-*sinh (tái hiện bug đã tìm). ĐỎ = một bug đã fix nay tái phát, hoặc chưa fix. Tất định, 0-token, KHÔNG gọi LLM. Fail-open nếu chưa có test/qc-codenào (dự án chưa dùng qc-code) — không chặn.qc-* - Trụ 3 gate (nếu có harness): — chặn cứng nếu task-ID đi sai state-machine (lùi/nhảy/né gate) hoặc draft trỏ task lạ. Không có file (install cũ) → bỏ qua. Đây là bản CỨNG của step 8 best-effort bên dưới.
RUN: [ -f harness/validators/task_lifecycle.py ] && python3 harness/validators/task_lifecycle.py --root . - Smoke check: verify golden path end-to-end.
- Commit with message: why, not what.
Post-commit — mandatory, never skip:
6. Find draft in matching feature.
llmwiki/wiki/sources/draft/- Promote to or
llmwiki/wiki/concepts/(permanent).llmwiki/wiki/sources/ - Add section:
## Origin/Draft: <path>/Commit: <hash> — <msg>Date: YYYY-MM-DD - — must return file.
CHECK: grep -l "## Origin" <promoted-file>
- — then edit log properly; update
RUN: echo "promoted" >> llmwiki/wiki/log.md.llmwiki/wiki/index.md - Trụ 3 — đóng vòng đời (best-effort, fail-open): draft có frontmatter →
task: T-…. Lệnh fail-open (thiếupython3 harness/scripts/code-logger.py --task set <T-id> state=done note="<commit-hash>"/id → bỏ qua, không chặn commit). Xác nhận:--taskin lifecycle proposed→approved→dispatched→done;--task show <T-id>xác minh các transition nằm trong chuỗi bất biến.--audit
No draft (hotfix/refactor)? Note "no draft — <reason>" in log.md, skip step 6. Noid (install cũ / propose bỏ qua mint)? Skip step 8 — fail-open, không phải lỗi.task:
All steps mandatory. No exceptions.
| 步骤 | 类型 | 输入 | 操作 | 输出/退出 | 失败/下一步 |
|---|---|---|---|---|---|
| W01 | deterministic | repo | 执行类型检查(检测仓库对应的命令) | rc 0 | 出错 → 修复并重试 |
| W02 | deterministic | repo | 执行 Lint | rc 0,记录 warning | 出错 → 修复并重试 |
| W03 | deterministic | draft/task | 执行 Test,并运行可复现 qc-code 的 test(3b;如有 harness) | rc 0 | 失败 → 修复并重试 |
| W04 | deterministic | draft/task | 运行 | rc 0 | 阻断 → blocked |
| W05 | judgment | app | 对 golden path 执行端到端 smoke check | golden path 可运行 | 损坏 → 修复 |
| W06 | effect | diff | Commit,message 强调 why | commit hash | — |
| W07 | effect | draft | 发布 draft,添加 | wiki 页面 | 无 draft → B01 |
| W08 | effect | | 通过 | state=done | 无 id → B02 |
以下为每个步骤的详细信息(W01–W08 的唯一事实来源;W01–W03 = 步骤 1–3b,W04 = 4,W05 = 5,W06 = 6 pre-commit,W07 = 6–7 post-commit,W08 = 8):
提交前(Pre-commit):
- ——从 repo 中检测:
RUN: <type-check-cmd>(package.json)/npx tsc --noEmit(go.mod)。修复所有错误。go build ./... - ——检测:
RUN: <lint-cmd>/npx eslint src/。修复错误;记录 warning。go vet ./... - ——检测:
RUN: <test-cmd>/npm test。修复失败项。 3b. 可复现 qc-code 的 test(如有 harness):go test ./...——运行RUN: [ -f harness/scripts/qc-regression.py ] && python3 harness/scripts/qc-regression.py --run生成的/qc-codetest(复现已发现的 bug)。RED = 已修复的 bug 再次出现,或尚未修复。该过程是确定性的、0-token,且不调用 LLM。如果尚无qc-*test(项目尚未使用 qc-code),则 fail-open,不阻断。qc-* - 第 3 支柱(Trụ 3)gate(如有 harness): ——如果 task-ID 偏离 state-machine(倒退、跳转或绕过 gate),或 draft 指向未知 task,则硬性阻断。文件不存在(旧版安装)→ 跳过。这是下文步骤 8 best-effort 机制的硬性版本。
RUN: [ -f harness/validators/task_lifecycle.py ] && python3 harness/validators/task_lifecycle.py --root . - Smoke check:验证端到端的 golden path。
- 使用说明 why 而非 what 的 message 进行 Commit。
提交后(Post-commit)——必选,绝不跳过:
6. 在 中查找与 feature 匹配的 draft。
llmwiki/wiki/sources/draft/- 将其发布到永久目录 或
llmwiki/wiki/concepts/。llmwiki/wiki/sources/ - 添加 章节:
## Origin/Draft: <path>/Commit: <hash> — <msg>Date: YYYY-MM-DD - ——必须返回文件。
CHECK: grep -l "## Origin" <promoted-file>
- ——随后正确编辑 log;更新
RUN: echo "promoted" >> llmwiki/wiki/log.md。llmwiki/wiki/index.md - 第 3 支柱(Trụ 3)——关闭生命周期(best-effort,fail-open): draft frontmatter 包含 →
task: T-…。该命令采用 fail-open 机制(缺少python3 harness/scripts/code-logger.py --task set <T-id> state=done note="<commit-hash>"/id → 跳过,不阻断 commit)。确认:--task打印生命周期 proposed→approved→dispatched→done;--task show <T-id>验证各 transition 均位于固定链路中。--audit
没有 draft(hotfix/refactor)?在 log.md 中记录,跳过 post-commit 的步骤 6。 没有no draft — <reason>id(旧版安装 / propose 阶段跳过 mint)?跳过步骤 8——fail-open,不是错误。task:
所有步骤均为必选,无例外。
Branches
分支
| ID | Kind | Guard | Hành vi | Skip / failure | Rejoin |
|---|---|---|---|---|---|
| B01 | conditional_required | không có draft (hotfix/refactor) | ghi "no draft — <reason>" vào | — | W08 |
| B02 | conditional_required | draft không có | skip step 8 — fail-open | — | kết thúc |
| B03 | capability_optional | có | chạy 3b, 4, 8 | thiếu file → bỏ qua, fail-open | bước kế |
| ID | 类型 | 守卫条件 | 行为 | 跳过/失败 | 汇合点 |
|---|---|---|---|---|---|
| B01 | conditional_required | 没有 draft(hotfix/refactor) | 在 | — | W08 |
| B02 | conditional_required | draft 中没有 | 跳过步骤 8——fail-open | — | 结束 |
| B03 | capability_optional | 存在 | 运行 3b、4、8 | 文件缺失 → 跳过,fail-open | 下一步骤 |
Validation và stopping
验证与停止条件
Tất định: rc của typecheck/lint/test/qc-regression/task_lifecycle; phải trả file; + xác nhận lifecycle. Cần review: smoke golden path. Dừng khi mọi bước pre + post xong; đỏ ở pre-commit thì không commit.
CHECK: grep -l "## Origin" <promoted-file>--task show <T-id>--audit确定性验证:typecheck/lint/test/qc-regression/task_lifecycle 的 rc; 必须返回文件; + 确认 lifecycle。需要人工检查:smoke golden path。所有 pre + post 步骤完成后停止;若 pre-commit 阶段失败,则不得 commit。
CHECK: grep -l "## Origin" <promoted-file>--task show <T-id>--auditExamples
示例
- Positive: repo có →
package.json,npx tsc --noEmit,npx eslint src/xanh,npm testxanh → commit "why" → promote draftqc-regression.py --runvàoDDMMYY-login-otp.mdcówiki/concepts/→## Origin.code-logger.py --task set T-12 state=done note="<hash>" - Boundary/failure: fail 1 test → dừng ở W03, fix rồi chạy lại, chưa commit. Hotfix không có draft → log "no draft — hotfix typo", skip promote.
go test ./...
- 正向: repo 包含 →
package.json、npx tsc --noEmit、npx eslint src/全部通过,npm test通过 → 使用说明 why 的 message commit → 将 draftqc-regression.py --run发布到包含DDMMYY-login-otp.md的## Origin→wiki/concepts/。code-logger.py --task set T-12 state=done note="<hash>" - 边界/失败: 有 1 个 test 失败 → 停在 W03,修复后重试,暂不 commit。Hotfix 没有 draft → 记录
go test ./...,跳过发布。no draft — hotfix typo
Delivery — Output Report
交付——输出报告
After all main skill tasks complete, write a propose draft to the wiki.
完成所有主要 skill 任务后,向 wiki 写入一份状态为 proposed 的 draft。
Steps
步骤
1. Build the filename:
- Format:
DDMMYY-<ten>.md - = today (e.g.,
DDMMYYfor 2 June 2026)020626 - = 2–4 kebab-case words summarising what was done (e.g.,
<ten>,landing-page-coteccons,brand-kit-fintech)ingest-auth-spec
2. Write :
llmwiki/wiki/sources/draft/DDMMYY-<ten>.md---
type: draft
title: "DDMMYY-<ten>"
status: proposed
tags: [<skill-name>, output-report]
timestamp: YYYY-MM-DD
---1. 构建文件名:
- 格式:
DDMMYY-<ten>.md - = 今天(例如,2026 年 6 月 2 日对应
DDMMYY)020626 - = 2–4 个概括所完成内容的 kebab-case 词(例如
<ten>、landing-page-coteccons、brand-kit-fintech)ingest-auth-spec
2. 写入 :
llmwiki/wiki/sources/draft/DDMMYY-<ten>.md---
type: draft
title: "DDMMYY-<ten>"
status: proposed
tags: [<skill-name>, output-report]
timestamp: YYYY-MM-DD
---DDMMYY-<ten>
DDMMYY-<ten>
Type: draft
Status: proposed
Tags: <skill-name>, output-report
Proposed: YYYY-MM-DD
Type: draft
Status: proposed
Tags: <skill-name>, output-report
Proposed: YYYY-MM-DD
What
What
<One sentence — what this skill invocation produced or decided>
<One sentence — what this skill invocation produced or decided>
Output
Output
<Key artefacts, files created/modified, or decisions made>
<Key artefacts, files created/modified, or decisions made>
Files
Files
| File | Action |
|---|---|
| created / modified |
| File | Action |
|---|---|
| created / modified |
Notes
Notes
- Invoked via: skill
/<skill-name>
- Invoked via: skill
/<skill-name>
Origin
Origin
- Draft:
wiki/sources/draft/DDMMYY-<ten>.md - Commit: (filled by verify-before-commit)
- Date promoted: (filled by verify-before-commit)
**3. Update wiki index & log:**
- `llmwiki/wiki/index.md` — append one row: `| [DDMMYY-<ten>](sources/draft/DDMMYY-<ten>.md) | draft | YYYY-MM-DD |`
- `llmwiki/wiki/log.md` — append: `## YYYY-MM-DD — <skill-name> — <ten>`
> Skip only when the skill produces zero artefacts and zero decisions (e.g., a pure display mode like `/caveman-stats`).- Draft:
wiki/sources/draft/DDMMYY-<ten>.md - Commit: (filled by verify-before-commit)
- Date promoted: (filled by verify-before-commit)
**3. 更新 wiki index 与 log:**
- `llmwiki/wiki/index.md`——追加一行:`| [DDMMYY-<ten>](sources/draft/DDMMYY-<ten>.md) | draft | YYYY-MM-DD |`
- `llmwiki/wiki/log.md`——追加:`## YYYY-MM-DD — <skill-name> — <ten>`
> 仅当 skill 未产生任何产物和任何决策时(例如 `/caveman-stats` 这类纯展示模式)才可跳过。