mcpField
V
verify-before-commit

verify-before-commit

github.com/rheinmirTesting & quality10266 installsUpdated 2w ago
Repository

About verify-before-commit

verify-before-commit is an agent skill that gates commits after implementation by running checks and a smoke test. After a successful commit, it can promote a matching draft into the wiki and close the associated task lifecycle.

Key features

  1. 01Runs typecheck, lint, and tests
  2. 02Runs available regression and task gates
  3. 03Checks the application's golden path
  4. 04Commits with a rationale-focused message
  5. 05Promotes drafts and updates task state

Use cases

  1. 01Validating changes before a commit
  2. 02Preventing commits when required checks fail
  3. 03Recording completed work in the wiki

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/rheinmir/setup --skill verify-before-commit

After installing, type/verify-before-commitin Claude Code to confirm it loaded.

Details

From the project README

Skill: verify-before-commit

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 code-logger.py đã khai.
Mental model

diff → typecheck → lint → test → qc-regression → task_lifecycle gate → smoke → commit (why) → promote draft (+ ## Origin) → log + index → task state=done.

Input và output contract
FieldRequired?Ý nghĩa
Inthay đổi code đã implcóđối tượng gate
Indraft khớp feature trong llmwiki/wiki/sources/draft/khôngkhông có (hotfix/refactor) → ghi "no draft — " vào log
Intask: T-… trong frontmatter draftkhôngkhông có → skip step 8 (fail-open)
Outcommitcómessage nói why, không what
Outtrang wiki đã promote có ## Originkhi có draftconcepts/ hoặc sources/
Outllmwiki/wiki/log.md + index.mdcócập nhật
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.
Failure boundaries
  • Typecheck/lint/test đỏ → blocked: fix rồi chạy lại, không commit.
  • qc-regression.py --run đỏ → blocked (bug đã fix tái phát hoặc chưa fix); chưa có test qc-* → fail-open, không chặn.
  • task_lifecycle.py chặn (task-ID sai state-machine) → blocked; không có file (install cũ) → bỏ qua.
  • Không có draft → không promote, ghi lý do vào log (succeeded hẹp). Không có task: id → skip step 8, không phải lỗi.

HOW

Main workflow
StepTypeInputsActionOutputs/exitFailure/next
W01deterministicrepoType-check (dò lệnh theo repo)rc 0lỗi → fix, lặp
W02deterministicrepoLintrc 0, ghi chú warninglỗi → fix, lặp
W03deterministicrepoTest + test tái hiện qc-code (3b, nếu có harness)rc 0fail → fix, lặp
W04deterministicdraft/taskTrụ 3 gate task_lifecycle.py (nếu có harness)rc 0chặn → blocked
W05judgmentappSmoke check golden path end-to-endgolden path chạyhỏng → fix
W06effectdiffCommit, message whycommit hash—
W07effectdraftPromote draft + ## Origin + log + indextrang wikikhông draft → B01
W08effecttask: idĐóng vòng đời task qua code-logger.py (best-effort)state=donekhô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:

  1. RUN: <type-check-cmd> — detect from repo: npx tsc --noEmit (package.json) / go build ./... (go.mod). Fix all errors.
  2. RUN: <lint-cmd> — detect: npx eslint src/ / go vet ./.... Fix errors; note warnings.
  3. RUN: <test-cmd> — detect: npm test / go test ./.... Fix failures. 3b. Test tái hiện qc-code (nếu có harness): RUN: [ -f harness/scripts/qc-regression.py ] && python3 harness/scripts/qc-regression.py --run — chạy các test qc-* do /qc-code 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-* nào (dự án chưa dùng qc-code) — không chặn.
  4. Trụ 3 gate (nếu có harness): RUN: [ -f harness/validators/task_lifecycle.py ] && python3 harness/validators/task_lifecycle.py --root . — 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.
  5. Smoke check: verify golden path end-to-end.
  6. Commit with message: why, not what.

Post-commit — mandatory, never skip: 6. Find draft in llmwiki/wiki/sources/draft/ matching feature.

  • Promote to llmwiki/wiki/concepts/ or llmwiki/wiki/sources/ (permanent).
  • Add ## Origin section: Draft: <path> / Commit: <hash> — <msg> / Date: YYYY-MM-DD
  • CHECK: grep -l "## Origin" <promoted-file> — must return file.
  1. RUN: echo "promoted" >> llmwiki/wiki/log.md — then edit log properly; update llmwiki/wiki/index.md.
  2. Trụ 3 — đóng vòng đời (best-effort, fail-open): draft có frontmatter task: T-… → python3 harness/scripts/code-logger.py --task set <T-id> state=done note="<commit-hash>". Lệnh fail-open (thiếu --task/id → bỏ qua, không chặn commit). Xác nhận: --task show <T-id> in lifecycle proposed→approved→dispatched→done; --audit xác minh các transition nằm trong chuỗi bất biến.

No draft (hotfix/refactor)? Note "no draft — " in log.md, skip step 6. No task: id (install cũ / propose bỏ qua mint)? Skip step 8 — fail-open, không phải lỗi.

All steps mandatory. No exceptions.

Branches
IDKindGuardHành viSkip / failureRejoin
B01conditional_requiredkhông có draft (hotfix/refactor)ghi "no draft — " vào log.md, skip step 6 post-commit—W08
B02conditional_requireddraft không có task: id (install cũ / propose bỏ qua mint)skip step 8 — fail-open—kết thúc
B03capability_optionalcó harness/ (qc-regression, task_lifecycle, code-logger)chạy 3b, 4, 8thiếu file → bỏ qua, fail-openbước kế
Validation và stopping

Tất định: rc của typecheck/lint/test/qc-regression/task_lifecycle; CHECK: grep -l "## Origin" <promoted-file> phải trả file; --task show <T-id> + --audit 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.

Examples
  • Positive: repo có package.json → npx tsc --noEmit, npx eslint src/, npm test xanh, qc-regression.py --run xanh → commit "why" → promote draft DDMMYY-login-otp.md vào wiki/concepts/ có ## Origin → code-logger.py --task set T-12 state=done note="<hash>".
  • Boundary/failure: go test ./... 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.
Delivery — Output Report

After all main skill tasks complete, write a propose draft to the wiki.

Steps

1. Build the filename:

  • Format: DDMMYY-<ten>.md
  • DDMMYY = today (e.g., 020626 for 2 June 2026)
  • <ten> = 2–4 kebab-case words summarising what was done (e.g., 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
---

# DDMMYY-<ten>
**Type:** draft
**Status:** proposed
**Tags:** <skill-name>, output-report
**Proposed:** YYYY-MM-DD

## What
<One sentence — what this skill invocation produced or decided>

## Output
<Key artefacts, files created/modified, or decisions made>

## Files
| File | Action |
|------|--------|
| `path/to/file` | created / modified |

## Notes
- Invoked via: `/<skill-name>` skill

## 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).

Comments

Markdown supported