When to use
Run traceability check when you need to:- Verify the full chain: REQ → UC → WF → API → BDD → INV → ADR → TASK → COMMIT → CODE → TEST
- Find artifacts that are defined but never referenced (orphans)
- Find references to artifacts that don’t exist (broken links)
- Verify that completed tasks have git commits with proper trailers
- Check that code and test references are still valid (when code intelligence available)
Invocation
This is a read-only skill. It reports issues but never modifies files.
How it works
Step 1: Collect all defined IDs
Scans the following files for artifact definitions:| ID Type | Source Files | Pattern |
|---|---|---|
| REQ | requirements/REQUIREMENTS.md | REQ-\d{3} |
| UC | spec/use-cases.md | UC-\d{3} |
| WF | spec/workflows.md | WF-\d{3} |
| API | spec/contracts.md | API-\d{3} |
| BDD | spec/use-cases.md, test/ | BDD-\d{3} |
| INV | spec/domain-model.md, spec/invariants.md | INV-\d{3} |
| ADR | spec/adr/ADR-*.md | ADR-\d{3} |
| NFR | spec/nfr.md | NFR-\d{3} |
| RN | spec/release-notes.md | RN-\d{3} |
Step 2: Collect all referenced IDs
Scans ALL files inrequirements/, spec/, test/, plan/, and task/ for references to any ID pattern. Builds a set of referenced IDs per type.
Step 3: Cross-reference analysis
For each ID type, computes:- Orphaned definitions: IDs that are defined but never referenced by any other artifact
- Broken references: IDs that are referenced but never defined
- Forward references: IDs referenced in upstream artifacts pointing to downstream artifacts (acceptable but noted)
Step 4: Traceability matrix
Builds a condensed matrix showing which REQs trace through to which downstream artifacts:Step 5: Commit chain verification
Verifies the TASK → COMMIT link:- Check git availability: Gracefully skips if not inside a git repository
- Extract commits with
Refs:andTask:trailers from git log (limit 500 for performance) - Build TASK → commits mapping: A task may have multiple commits
- Identify gaps:
- Tasks without commits: TASKs marked
[x]but no matching commit in git log - Commits without refs: Commits with
Task:trailer but noRefs:trailer (missing upstream traceability) - Commits with broken refs: Commits whose
Refs:trailer references artifact IDs not defined in any spec
- Tasks without commits: TASKs marked
- Compute commit coverage: Tasks with at least one commit / total completed tasks
Commit verification runs only when inside a git repository. Otherwise, this step is skipped.
Step 5.5: Code & test chain verification (optional)
Extends the chain to verify CODE and TEST links structurally. Runs only whendashboard/traceability-graph.json exists AND contains a codeIntelligence block (generated by /sdd:code-index).
-
Verify codeRef validity:
- Check that referenced files exist on disk
- Check that symbols still exist at registered locations
- Mark as
valid,stale(file exists but symbol moved), orbroken(file missing)
-
Verify testRef validity:
- Check that test files exist on disk
- Check that named test blocks exist
- Mark as
valid,stale, orbroken
-
Detect orphaned code annotations:
- Scan
src/forRefs:comments that reference artifact IDs not defined in any SDD artifact - These indicate stale annotations left after spec changes
- Scan
-
Detect uncovered paths:
- Using the call graph from
codeIntelligence.callGraph[] - Find exported/public symbols reachable from entry points (route handlers, main exports)
- Identify those with NO
Refs:annotation and no inferred refs - These are execution paths with no SDD traceability
- Using the call graph from
-
Compute code-test chain coverage:
- codeRefs: valid / stale / broken counts
- testRefs: valid / stale / broken counts
- Orphaned annotations: count
- Uncovered paths: count
- Code chain coverage: valid codeRefs / total codeRefs
Step 6: Generate report
Outputs a comprehensive text report:Constraints
- Read-only: Never modifies any files
- Precise line numbers: Reports include exact file locations
- Graceful degradation: If a directory doesn’t exist, skips it and notes “not yet generated”
- Tolerates partial pipelines: Not all stages need to be complete
- Git optional: Commit verification gracefully skips if git not available
- Code intelligence optional: Step 5.5 runs only when code index exists
Example use cases
After requirements change
Before auditing
After implementation
Related skills
Dashboard
Visual traceability matrix (same underlying data)
Code Index
Enable Step 5.5 code/test chain verification
Spec Auditor
Audit content quality after fixing traceability