Help us improve
Share bugs, ideas, or general feedback.
Analyzes Acceptance Criteria (AC) to test traceability and generates coverage reports from SPEC files and test annotations (@AC, @SPEC). Useful for requirement-level coverage validation.
npx claudepluginhub asiaostrich/universal-dev-standards --plugin universal-dev-standardsHow this skill is triggered — by the user, by Claude, or both
Slash command
/universal-dev-standards:ac-coverage [spec file path | 規格檔案路徑][spec file path | 規格檔案路徑]This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Analyze Acceptance Criteria (AC) to test traceability and generate coverage reports.
Reviews test sufficiency and identifies coverage gaps using Codex MCP. Supports file, directory, description, or git-diff input. Includes AC traceability mode for mapping acceptance criteria to test evidence.
Verifies bidirectional traceability from requirements to code to tests. Scans .aiwg/requirements/, code files, tests, and commit messages for ID references like UC-*, REQ-*. Builds matrix, identifies coverage gaps, orphans, and untested code.
Validates test coverage against requirements by mapping requirements to tests, classifying gaps, and writing new tests. Never modifies implementation code.
Share bugs, ideas, or general feedback.
Analyze Acceptance Criteria (AC) to test traceability and generate coverage reports.
分析驗收條件(AC)與測試之間的追蹤關係,並產生覆蓋率報告。
/coverage | 與 /coverage 的區別| Aspect | /coverage | /ac-coverage |
|---|---|---|
| Scope | Code-level (line/branch/function) | Requirement-level (AC-to-test) |
| Input | Source code + test runner | SPEC file + test annotations |
| Question | "How much code is tested?" | "Which AC have tests?" |
| Output | Coverage percentages | Traceability matrix + gap report |
@AC and @SPEC annotations using standard linking conventionsCoverage % = (covered + partial × 0.5) / total × 100Tests MUST reference their source AC using standard annotations:
// TypeScript/JavaScript
describe('AC-1: User login with valid credentials', () => {
// @AC AC-1
// @SPEC SPEC-001
it('should redirect to dashboard on successful login', () => { ... });
});
# Python
class TestAC1_UserLogin:
"""AC-1: User login with valid credentials
@AC AC-1
@SPEC SPEC-001
"""
def test_redirect_to_dashboard(self): ...
# BDD Feature
@SPEC-001 @AC-1
Scenario: User login with valid credentials
| Threshold | Default Value | Enforcement |
|---|---|---|
| Check-in | 80% | Required for feature branch merge |
| Release | 100% | Required for production release |
| Warning | 60% | Triggers coverage warning |
Thresholds are configurable via --threshold parameter or project configuration.
--full 模式)Use --full flag to extend from 2-layer (AC→Test) to 4-layer traceability.
使用 --full 標記將追溯從 2 層(AC→Test)擴展為 4 層。
Layer 0: Requirement / User Story (REQ)
↓ (defines)
Layer 1: Acceptance Criteria (AC)
↓ (@AC annotations)
Layer 2: Test Cases
↓ (covers)
Layer 3: Source Code (@implements)
// Layer 3→1: Code referencing AC
// @implements AC-1, AC-2
function authenticate(user: string, pass: string) { ... }
<!-- Layer 0→1: Requirement in SPEC -->
## Requirements
### REQ-1: User Authentication
- AC-1: Given valid credentials, when login, then authenticated
- AC-2: Given invalid credentials, when login, then rejected
## Four-Layer Traceability Matrix
| Requirement | AC | Test | Code | Status |
|-------------|-----|------|------|--------|
| REQ-1 | AC-1 | auth.test.ts:15 | auth.ts:42 | ✅ Full |
| REQ-1 | AC-2 | auth.test.ts:30 | auth.ts:58 | ✅ Full |
| REQ-2 | AC-3 | — | dashboard.ts:10 | ⚠️ No test |
| REQ-3 | AC-4 | export.test.ts:5 | — | ⚠️ No code |
### Gap Summary
- Layer 0→1: 2 requirements without AC
- Layer 1→2: 1 AC without tests
- Layer 2→3: 0 tests without code mapping
- Layer 3→1: 3 code files without AC mapping
Use --trace-code <path> to trace from code back to requirements.
使用 --trace-code <path> 從程式碼反向追溯到需求。
/ac-coverage --trace-code src/auth.ts
# Output:
# src/auth.ts:42 → @implements AC-1 → REQ-1 (SPEC-AUTH-001)
# src/auth.ts:58 → @implements AC-2 → REQ-1 (SPEC-AUTH-001)
The generated report follows the standard format from core/acceptance-criteria-traceability.md:
# AC Coverage Report
**Specification**: SPEC-001 — Feature Name
**Generated**: 2026-03-18
**Coverage**: 75% (6/8 AC)
## Summary
| Status | Count | Percentage |
|--------|-------|------------|
| ✅ Covered | 5 | 62.5% |
| ⚠️ Partial | 2 | 25.0% |
| ❌ Uncovered | 1 | 12.5% |
## Traceability Matrix
| AC-ID | Description | Status | Test Reference |
|-------|-------------|--------|----------------|
| AC-1 | Login with valid credentials | ✅ | auth.test.ts:15 |
| AC-2 | Reject invalid credentials | ✅ | auth.test.ts:32 |
| ... | ... | ... | ... |
## Gaps
- **AC-8**: Social login — Blocked by OAuth sandbox
## Action Items
1. [ ] AC-8: Set up OAuth sandbox (ETA: TBD)
After /ac-coverage completes, the AI assistant should suggest:
AC 覆蓋率分析完成。建議下一步 / AC coverage analysis complete. Suggested next steps:
- 覆蓋率達標 → 執行
/checkin品質關卡 — Coverage meets threshold → Run/checkinquality gates- 有未覆蓋 AC → 執行
/derive-tdd補齊測試 ⭐ Recommended / 推薦 — Uncovered AC found → Run/derive-tddto add tests- 有部分覆蓋 AC → 檢查缺少的邊界情況 — Partial AC → Review missing edge cases
- 需要完整追溯 → 執行
/ac-coverage --full— Need full traceability → Run with--full- 反向追溯 → 執行
/ac-coverage --trace-code <path>— Reverse trace → Use--trace-code
完整的 AI 行為定義請參閱對應的命令文件:
/ac-coverageFor complete AI agent behavior definition, see the corresponding command file:
/ac-coverage