Analyze drift between specs and implementation. Compares requirements against code to find divergence.
Analyze drift between specifications and implementation. This command compares your spec requirements (FR-, SC-, acceptance scenarios) against the actual codebase to identify where they've diverged.
$ARGUMENTS
Read the project structure to understand the codebase:
specs/*/spec.md filesFind all spec files in the project:
find specs -name "spec.md" -type f 2>/dev/null | sort
For each spec, extract:
For each spec, determine:
Use these heuristics:
Find code that doesn't match any spec:
Output a structured report in this format:
# Spec Drift Report
Generated: [timestamp]
Project: [project name]
## Summary
| Category | Count |
|----------|-------|
| Specs Analyzed | X |
| Requirements Checked | X |
| ✓ Aligned | X (Y%) |
| ⚠️ Drifted | X (Y%) |
| ✗ Not Implemented | X (Y%) |
| 🆕 Unspecced Code | X |
## Detailed Findings
### Spec: [spec-id] - [title]
#### Aligned ✓
- FR-001: [description] → [implementation location]
#### Drifted ⚠️
- FR-002: Spec says "[spec text]" but code does "[actual behavior]"
- Location: [file:line]
- Severity: [minor|moderate|major]
#### Not Implemented ✗
- FR-003: [description]
### Unspecced Code 🆕
| Feature | Location | Lines | Suggested Spec |
|---------|----------|-------|----------------|
| [feature] | [path] | [count] | [spec-XXX] |
## Inter-Spec Conflicts
[List any contradictions between specs]
## Recommendations
1. [First recommendation]
2. [Second recommendation]
Save the report to:
.specify/sync/drift-report.md (human-readable).specify/sync/drift-report.json (machine-readable)The JSON report should follow this schema:
{
"generated": "ISO-8601 timestamp",
"project": "project name",
"summary": {
"specs_analyzed": 0,
"requirements_checked": 0,
"aligned": 0,
"drifted": 0,
"not_implemented": 0,
"unspecced_features": 0
},
"specs": [
{
"id": "spec-id",
"title": "Spec Title",
"aligned": ["FR-001", "FR-002"],
"drifted": [
{
"requirement": "FR-003",
"spec_text": "what spec says",
"actual": "what code does",
"location": "path/to/file.cs:123",
"severity": "moderate"
}
],
"not_implemented": ["FR-004"]
}
],
"unspecced": [
{
"feature": "FeatureName",
"location": "path/to/file",
"lines": 150,
"suggested_spec": "spec-013"
}
],
"conflicts": []
}
/speckit.sync.analyze
/speckit.sync.analyze --spec 011-register-write
/speckit.sync.analyze --json
--spec <id> to analyze a single spec--json for machine-readable output only44:["$","$L4c",null,{"content":"$4d","frontMatter":{"name":"speckit-sync-analyze","description":"Analyze drift between specs and implementation. Compares requirements against code to find divergence.","compatibility":"Requires spec-kit project structure with .specify/ directory","metadata":{"author":"github-spec-kit","source":"sync:commands/analyze.md"},"user-invocable":true,"disable-model-invocation":true}}]