/verify-feature-code — Code vs Doc Verification
Mục đích
Mỗi khi BA cần biết doc có khớp code không, chạy skill này. Nó:
- Đọc toàn bộ doc của 1 feature folder
- Đọc code trong 1 hoặc nhiều repo đã index qua GitNexus
- Sinh gap report (md) phân loại Critical/High/Medium/Low
- Lưu report vào
<feature>/verifications/YYYY-MM-DD-code-vs-doc-verification.md
- Không tự update doc — BA đọc report rồi quyết định
Khi nào dùng
- Trước release / review feature để đảm bảo spec đã phản ánh code thật
- Sau khi dev MR xong, doc cần update theo code
- Audit định kỳ (quý/tháng)
Khi nào KHÔNG dùng
- Nếu feature chưa có code (brand new spec) → dùng
/project:review-feature thay
- Nếu chỉ cần gen
api-design.md từ doc → dùng /project:write-api-design
- Nếu cần explore code (no doc yet) → dùng
/codebase-doc
Inputs
| Param |
Bắt buộc |
Mô tả |
<feature-folder> |
✅ |
Path đến feature folder (vd docs/requirements/compute/cloud-advisor) |
--repos <list> |
✅ |
Comma-separated repo names đã index (vd portal-ui-user,portal-api-dev) |
--exclude <area> |
⬜ |
Skip một phần (vd admin, billing-callback) |
--focus <area> |
⬜ |
Chỉ kiểm tra 1 phần cụ thể |
--format md|docx |
⬜ |
Default md. docx gọi skill issue-discovery-report để gen BDR file |
Ví dụ:
/verify-feature-code docs/requirements/compute/cloud-advisor --repos portal-ui-user,portal-api-dev --exclude admin
Workflow (Claude MUST follow)
Step 0 — Precheck
- Gọi
list_repos (GitNexus) → confirm repos đã index.
- Đọc
<feature-folder>/ để biết file nào tồn tại.
- Đọc
<feature-folder>/verifications/ (nếu có) để biết các lần verify trước — tránh duplicate findings, chỉ report mới/khác.
Step 1 — Read docs
Đọc theo thứ tự:
OVERVIEW.md hoặc SRS.md (functional requirements)
DATA_DICTIONARY.md (field specs, defaults, enums)
DOMAIN_MODEL.puml hoặc data-design.md (entities + relationships)
api-design.md nếu có
workflow-design.md nếu có
architecture.md / test-case.md nếu có
Trích xuất:
- Entity names, enum values, defaults
- API endpoints (method + path)
- Business rules, state machines
- RBAC roles / permissions
- External system dependencies
Step 2 — Query code (GitNexus first, Grep fallback)
Ưu tiên theo thứ tự:
- Resource
gitnexus://repo/{name}/context — check staleness, get stats
- Resource
gitnexus://repo/{name}/clusters — find cluster matching feature name
- Tool
query — với concept keywords từ doc
- Tool
cypher — direct graph query nếu cần specific symbol
- Fallback
Grep + Read khi GitNexus không có kết quả
Với mỗi entity/endpoint/rule trong doc, tìm:
- File thực tế chứa implementation
- Enum values / default values thực tế
- Route registrations (blueprints, route tables)
- Migrations (initial seed data)
Step 3 — Cross-reference
Lập bảng 3 cột Doc | Code | Status:
| Aspect |
Doc says |
Code shows |
Match? |
| Entity names |
... |
... |
✅ / ❌ |
| Enum values |
... |
... |
✅ / ❌ |
| API endpoints |
... |
... |
✅ / ❌ |
| Defaults |
... |
... |
✅ / ❌ |
| RBAC |
... |
... |
✅ / ❌ |
| State machine |
... |
... |
✅ / ❌ |
Step 4 — Classify issues
| Severity |
Criterion |
| Critical |
Code hoặc doc gây lỗi runtime / data loss / bypass security / bug đã ship |
| High |
Endpoint/entity đã ship nhưng không có doc, hoặc enum/default không khớp gây confusion |
| Medium |
State machine / RBAC / lifecycle thiếu doc, naming không nhất quán |
| Low |
Cosmetic, glossary, minor clarification |
Step 5 — Write report
File: <feature-folder>/verifications/YYYY-MM-DD-code-vs-doc-verification.md
Template:
# <Feature> — Code vs Doc Verification Report
| Field | Value |
|-------|-------|
| **Date** | YYYY-MM-DD |
| **Feature** | `<path>` |
| **Verifier** | Claude (BA assist) |
| **Scope** | <what was covered; what excluded> |
| **Codebases** | <repo@commit or @index-date> |
| **Tools** | GitNexus <status> / Grep fallback |
## Docs Reviewed
- ...
## Code Reviewed
- ...
## Summary
| Severity | Count | Description |
|----------|-------|-------------|
| Critical | N | ... |
| High | N | ... |
| Medium | N | ... |
| Low | N | ... |
**Overall:** <1-line verdict — DOC = CODE / DOC ⊃ CODE / DOC ⊂ CODE / DIVERGED>
---
## Section A — Critical Issues
### C1. <title>
**Where:** `path/to/file.py:LINE`
<what doc says> vs <what code does>
**Recommended:** <action>
---
## Section B — High Issues
## Section C — Medium Issues
## Section D — Low Issues
## Action Plan
| # | Action | File | Owner |
|---|--------|------|-------|
| 1 | ... | ... | BA/Dev |
## Excluded
- <areas deferred, why, who follows up>
<!-- verification-meta:
generated_by: verify-feature-code
schema_version: 1
codebases_indexed:
- <repo>@<date>
-->
Step 6 — DO NOT update feature docs
Skill chỉ báo cáo, không tự sửa. BA review rồi chạy /project:write-overview, /project:write-api-design, hoặc sửa manual.
Report Conventions
File naming
<feature-folder>/verifications/YYYY-MM-DD-code-vs-doc-verification.md
Nếu nhiều lần 1 ngày: thêm suffix -v2, -v3.
Issue ID format
C1, C2, C3... — Critical
H1, H2, H3... — High
M1, M2, M3... — Medium
L1, L2, L3... — Low
Mỗi issue có:
- Where: file path (tuyệt đối hoặc từ repo root) + line number nếu có
- Doc says vs Code reality — phải trích câu/entity/enum cụ thể
- Recommended — hành động, ai làm
Anti-patterns
- ❌ Generic claim "doc doesn't match code" — phải chỉ rõ file/line
- ❌ Recommend sửa code — skill này audit doc, không chỉ đạo engineering
- ❌ Tự update OVERVIEW.md / PUML — chỉ sinh report
- ❌ Đoán entity thuộc repo nào khi chưa index
- ❌ Skip Critical issues "để báo sau" — phải list hết
Output Checklist
□ File verifications/YYYY-MM-DD-code-vs-doc-verification.md đã tạo
□ Header đầy đủ: Date, Feature, Scope, Codebases, Tools
□ Summary table có số issue mỗi severity
□ Mỗi issue: Where (file:line), Doc says vs Code reality, Recommended
□ Action Plan có owner rõ ràng (BA / Dev / Ops)
□ Excluded section ghi rõ scope bị skip
□ HTML comment metadata ở cuối (generated_by, indexed repos)
□ KHÔNG sửa file doc nào khác ngoài file report
Integration with other skills
| Cần làm tiếp |
Skill |
| Gen .docx BDR từ report |
issue-discovery-report |
| Update OVERVIEW.md từ gaps |
/project:write-overview |
| Gen api-design.md từ endpoints chưa doc |
/project:write-api-design |
| Explore code của endpoint cụ thể |
gitnexus-exploring |
| Trace bug trong code |
gitnexus-debugging |
| Lập kế hoạch refactor để khớp doc |
gitnexus-refactoring |
Example: Cloud Advisor (2026-04-18, 2026-04-19)
Run 1 (non-admin):
/verify-feature-code docs/requirements/compute/cloud-advisor --repos portal-ui-user,portal-api-dev --exclude admin
Kết quả:
- File:
docs/requirements/compute/cloud-advisor/verifications/2026-04-18-code-vs-doc-verification.md
- 3 Critical, 3 High, 4 Medium, 3 Low
- Verdict: DOC ⊃ CODE (doc describes 5 categories / 17 rules; code ships 3 / 10)
Run 2 (admin follow-up):
/verify-feature-code docs/requirements/compute/cloud-advisor --repos portal-ui-admin,portal-api-dev --focus admin
Kết quả:
- File:
docs/requirements/compute/cloud-advisor/verifications/2026-04-19-admin-code-vs-doc-verification.md
- 0 Critical, 3 High, 1 Medium, 0 Low
- Verdict: DOC ⊃ CODE (admin side) — UFR-680/681/682 chưa implement; ResourceTypeKey & RBAC actions đã định nghĩa nhưng chưa wire
Pattern: mỗi focus/scope = 1 report file riêng, không overwrite file cũ.
1---2name: verify-feature-code3description: Verify a BA feature folder against actual code in one or more indexed repos; produce a gap report and persist it as a dated markdown file in the feature's verifications/ subfolder.4---56# /verify-feature-code — Code vs Doc Verification78## Mục đích910Mỗi khi BA cần biết **doc có khớp code không**, chạy skill này. Nó:11121. Đọc toàn bộ doc của 1 feature folder132. Đọc code trong 1 hoặc nhiều repo đã index qua GitNexus143. Sinh **gap report** (md) phân loại Critical/High/Medium/Low154. **Lưu report** vào `<feature>/verifications/YYYY-MM-DD-code-vs-doc-verification.md`165. Không tự update doc — BA đọc report rồi quyết định1718## Khi nào dùng1920- Trước release / review feature để đảm bảo spec đã phản ánh code thật21- Sau khi dev MR xong, doc cần update theo code22- Audit định kỳ (quý/tháng)2324## Khi nào KHÔNG dùng2526- Nếu feature chưa có code (brand new spec) → dùng `/project:review-feature` thay27- Nếu chỉ cần gen `api-design.md` từ doc → dùng `/project:write-api-design`28- Nếu cần explore code (no doc yet) → dùng `/codebase-doc`2930---3132## Inputs3334| Param | Bắt buộc | Mô tả |35|-------|----------|-------|36| `<feature-folder>` | ✅ | Path đến feature folder (vd `docs/requirements/compute/cloud-advisor`) |37| `--repos <list>` | ✅ | Comma-separated repo names đã index (vd `portal-ui-user,portal-api-dev`) |38| `--exclude <area>` | ⬜ | Skip một phần (vd `admin`, `billing-callback`) |39| `--focus <area>` | ⬜ | Chỉ kiểm tra 1 phần cụ thể |40| `--format md\|docx` | ⬜ | Default `md`. `docx` gọi skill `issue-discovery-report` để gen BDR file |4142Ví dụ:43```44/verify-feature-code docs/requirements/compute/cloud-advisor --repos portal-ui-user,portal-api-dev --exclude admin45```4647---4849## Workflow (Claude MUST follow)5051### Step 0 — Precheck52531. Gọi `list_repos` (GitNexus) → confirm repos đã index.54 - Check `~/.gitnexus/registry.json`: `indexedAt` phải mới hơn last commit của repo.55 - Nếu repo chưa có trong registry: **ưu tiên** chạy binary trực tiếp thay vì `npx`:56 ```bash57 node ~/.npm/_npx/*/node_modules/gitnexus/dist/cli/index.js analyze < /dev/null 2>&158 ```59 Chạy từ thư mục repo, `run_in_background=true`, timeout 10 phút.60 - **Tại sao không dùng `npx gitnexus analyze`:** `npx` re-verify package mỗi lần gọi → thường treo không output, exit 0 mà không làm gì. Chạy binary node trực tiếp bypass được.61 - Nếu `~/.npm/_npx/*/node_modules/gitnexus/` chưa có: `npx --yes gitnexus status` 1 lần để cache package, sau đó dùng node trực tiếp.62 - **Progress indicator:** analyze KHÔNG stream log qua pipe; xem process bằng `ps aux | grep gitnexus` và folder `<repo>/.gitnexus/` (có `lbug`, `lbug.wal` = đang ghi DB). Thời gian: ~5–10 phút cho repo vừa (5k files), dài hơn cho repo lớn.63 - **Fallback:** Nếu GitNexus index chưa xong sau 10 phút, vẫn có thể tiếp tục verify bằng Grep/Read trực tiếp — ghi chú trong report "GitNexus index in progress, findings from direct grep".642. Đọc `<feature-folder>/` để biết file nào tồn tại.653. Đọc `<feature-folder>/verifications/` (nếu có) để biết các lần verify trước — tránh duplicate findings, chỉ report mới/khác.6667### Step 1 — Read docs6869Đọc theo thứ tự:70711. `OVERVIEW.md` hoặc `SRS.md` (functional requirements)722. `DATA_DICTIONARY.md` (field specs, defaults, enums)733. `DOMAIN_MODEL.puml` hoặc `data-design.md` (entities + relationships)744. `api-design.md` nếu có755. `workflow-design.md` nếu có766. `architecture.md` / `test-case.md` nếu có7778Trích xuất:79- Entity names, enum values, defaults80- API endpoints (method + path)81- Business rules, state machines82- RBAC roles / permissions83- External system dependencies8485### Step 2 — Query code (GitNexus first, Grep fallback)8687Ưu tiên theo thứ tự:88891. **Resource** `gitnexus://repo/{name}/context` — check staleness, get stats902. **Resource** `gitnexus://repo/{name}/clusters` — find cluster matching feature name913. **Tool** `query` — với concept keywords từ doc924. **Tool** `cypher` — direct graph query nếu cần specific symbol935. **Fallback** `Grep` + `Read` khi GitNexus không có kết quả9495Với mỗi entity/endpoint/rule trong doc, tìm:96- File thực tế chứa implementation97- Enum values / default values thực tế98- Route registrations (blueprints, route tables)99- Migrations (initial seed data)100101### Step 3 — Cross-reference102103Lập bảng 3 cột **Doc | Code | Status**:104105| Aspect | Doc says | Code shows | Match? |106|--------|----------|-----------|--------|107| Entity names | ... | ... | ✅ / ❌ |108| Enum values | ... | ... | ✅ / ❌ |109| API endpoints | ... | ... | ✅ / ❌ |110| Defaults | ... | ... | ✅ / ❌ |111| RBAC | ... | ... | ✅ / ❌ |112| State machine | ... | ... | ✅ / ❌ |113114### Step 4 — Classify issues115116| Severity | Criterion |117|----------|-----------|118| **Critical** | Code hoặc doc gây lỗi runtime / data loss / bypass security / bug đã ship |119| **High** | Endpoint/entity đã ship nhưng không có doc, hoặc enum/default không khớp gây confusion |120| **Medium** | State machine / RBAC / lifecycle thiếu doc, naming không nhất quán |121| **Low** | Cosmetic, glossary, minor clarification |122123### Step 5 — Write report124125File: `<feature-folder>/verifications/YYYY-MM-DD-code-vs-doc-verification.md`126127Template:128129````markdown130# <Feature> — Code vs Doc Verification Report131132| Field | Value |133|-------|-------|134| **Date** | YYYY-MM-DD |135| **Feature** | `<path>` |136| **Verifier** | Claude (BA assist) |137| **Scope** | <what was covered; what excluded> |138| **Codebases** | <repo@commit or @index-date> |139| **Tools** | GitNexus <status> / Grep fallback |140141## Docs Reviewed142- ...143144## Code Reviewed145- ...146147## Summary148149| Severity | Count | Description |150|----------|-------|-------------|151| Critical | N | ... |152| High | N | ... |153| Medium | N | ... |154| Low | N | ... |155156**Overall:** <1-line verdict — DOC = CODE / DOC ⊃ CODE / DOC ⊂ CODE / DIVERGED>157158---159160## Section A — Critical Issues161162### C1. <title>163**Where:** `path/to/file.py:LINE`164165<what doc says> vs <what code does>166167**Recommended:** <action>168169---170171## Section B — High Issues172## Section C — Medium Issues173## Section D — Low Issues174175## Action Plan176177| # | Action | File | Owner |178|---|--------|------|-------|179| 1 | ... | ... | BA/Dev |180181## Excluded182- <areas deferred, why, who follows up>183184<!-- verification-meta:185 generated_by: verify-feature-code186 schema_version: 1187 codebases_indexed:188 - <repo>@<date>189-->190````191192### Step 6 — DO NOT update feature docs193194Skill chỉ **báo cáo**, không tự sửa. BA review rồi chạy `/project:write-overview`, `/project:write-api-design`, hoặc sửa manual.195196---197198## Report Conventions199200### File naming201```202<feature-folder>/verifications/YYYY-MM-DD-code-vs-doc-verification.md203```204205Nếu nhiều lần 1 ngày: thêm suffix `-v2`, `-v3`.206207### Issue ID format208- `C1, C2, C3...` — Critical209- `H1, H2, H3...` — High210- `M1, M2, M3...` — Medium211- `L1, L2, L3...` — Low212213Mỗi issue có:214- **Where:** file path (tuyệt đối hoặc từ repo root) + line number nếu có215- **Doc says** vs **Code reality** — phải trích câu/entity/enum cụ thể216- **Recommended** — hành động, ai làm217218### Anti-patterns219220- ❌ Generic claim "doc doesn't match code" — phải chỉ rõ file/line221- ❌ Recommend sửa code — skill này audit doc, không chỉ đạo engineering222- ❌ Tự update OVERVIEW.md / PUML — chỉ sinh report223- ❌ Đoán entity thuộc repo nào khi chưa index224- ❌ Skip Critical issues "để báo sau" — phải list hết225226---227228## Output Checklist229230```231□ File verifications/YYYY-MM-DD-code-vs-doc-verification.md đã tạo232□ Header đầy đủ: Date, Feature, Scope, Codebases, Tools233□ Summary table có số issue mỗi severity234□ Mỗi issue: Where (file:line), Doc says vs Code reality, Recommended235□ Action Plan có owner rõ ràng (BA / Dev / Ops)236□ Excluded section ghi rõ scope bị skip237□ HTML comment metadata ở cuối (generated_by, indexed repos)238□ KHÔNG sửa file doc nào khác ngoài file report239```240241---242243## Integration with other skills244245| Cần làm tiếp | Skill |246|--------------|-------|247| Gen .docx BDR từ report | `issue-discovery-report` |248| Update OVERVIEW.md từ gaps | `/project:write-overview` |249| Gen api-design.md từ endpoints chưa doc | `/project:write-api-design` |250| Explore code của endpoint cụ thể | `gitnexus-exploring` |251| Trace bug trong code | `gitnexus-debugging` |252| Lập kế hoạch refactor để khớp doc | `gitnexus-refactoring` |253254---255256## Example: Cloud Advisor (2026-04-18, 2026-04-19)257258**Run 1 (non-admin):**259```260/verify-feature-code docs/requirements/compute/cloud-advisor --repos portal-ui-user,portal-api-dev --exclude admin261```262263Kết quả:264- File: `docs/requirements/compute/cloud-advisor/verifications/2026-04-18-code-vs-doc-verification.md`265- 3 Critical, 3 High, 4 Medium, 3 Low266- Verdict: DOC ⊃ CODE (doc describes 5 categories / 17 rules; code ships 3 / 10)267268**Run 2 (admin follow-up):**269```270/verify-feature-code docs/requirements/compute/cloud-advisor --repos portal-ui-admin,portal-api-dev --focus admin271```272273Kết quả:274- File: `docs/requirements/compute/cloud-advisor/verifications/2026-04-19-admin-code-vs-doc-verification.md`275- 0 Critical, 3 High, 1 Medium, 0 Low276- Verdict: DOC ⊃ CODE (admin side) — UFR-680/681/682 chưa implement; ResourceTypeKey & RBAC actions đã định nghĩa nhưng chưa wire277278Pattern: **mỗi focus/scope = 1 report file riêng**, không overwrite file cũ.