Does what was built actually match what was specced?
spec-architect is a CLI + GUI tool that audits the alignment between your spec documents, source code, and tests. It answers the question developers and PMs dread: "Is this thing actually done?"
For each feature, spec-architect:
- Parses your markdown spec files and extracts requirements (by heading ID pattern)
- Indexes your TypeScript codebase via AST — not regex
- Runs your test suite and correlates results back to requirements
- Builds a delta matrix showing the exact status of every requirement:
| Status | Meaning |
|---|---|
| ✅ SYNC | Spec, code, and tests all agree |
| ❌ GAP | Requirement exists in spec, nothing in code |
| ⚡ DRIFT:MODIFIED | Code diverges from spec intent |
| 🗑️ DRIFT:REMOVED | Spec active, code marked @deprecated |
| ➕ DRIFT:ADDED | Code added without spec coverage |
| 🔶 ORPHAN_CODE | Code exists, no spec requirement found |
| ❓ VAGUE | Requirement too ambiguous to map |
git clone https://github.com/rrtrytcg/spec-architect
cd spec-architect
npm installRequires Node 18+ and TypeScript. Uses ts-node to run directly — no build step needed.
npx ts-node --transpile-only index.ts initThis generates spec-architect.config.json in your project root. Edit it:
{
"version": "1.0",
"specGlob": "docs/**/*.md",
"codeGlob": ["src/**/*.ts", "src/**/*.tsx"],
"testCommand": "npx vitest run --reporter=json",
"e2eCommand": "npx playwright test --reporter=json",
"outputDir": ".spec-architect",
"mappingStrategy": "heading-regex",
"features": [
{
"id": "my_feature",
"specPath": "docs/my-feature.md",
"entryPoints": ["src/my-feature/**/*.ts"],
"testPattern": "my-feature*.test.ts"
}
]
}Spec files are plain markdown. Requirements are headings that follow the pattern PREFIX-NNN:
# My Feature
## FEAT-001: Users can log in with email
GIVEN a valid email and password
WHEN the user submits the login form
THEN they are redirected to the dashboard
## FEAT-002: Failed login shows error message
...# From your project root
npx ts-node --transpile-only /path/to/spec-architect/index.ts audit my_feature \
--json \
--config ./spec-architect.config.jsonOutputs:
.spec-architect/AUDIT_MY_FEATURE_<timestamp>.md— human-readable report.spec-architect/AUDIT_MY_FEATURE_<timestamp>.json— machine-readable for CI
spec-architect ships with a local web dashboard. Run it from the spec-architect directory:
npx ts-node --transpile-only gui-server.ts \
--root /path/to/your/project \
--port 4747Then open http://localhost:4747.
The GUI lets you:
- Point at a spec folder and auto-discover all your spec files
- Create and manage
spec-architect.config.jsonvisually - Run audits with live streaming output
- View the delta matrix with color-coded status rows
- Export the delta matrix as a markdown file for AI agents
- Add new features without touching the config directly
# Create config template
npx ts-node --transpile-only index.ts init
# Snapshot repo state
npx ts-node --transpile-only index.ts scan --config ./spec-architect.config.json
# Lint spec quality before auditing
npx ts-node --transpile-only index.ts lint my_feature --config ./spec-architect.config.json
# Full audit (add --json for machine output, --ci to exit 1 on gaps)
npx ts-node --transpile-only index.ts audit my_feature --json --config ./spec-architect.config.json
# Approve an audit (sign-off before shipping)
npx ts-node --transpile-only index.ts approve my_feature .spec-architect/AUDIT_MY_FEATURE_<ts>.md
# Verify audit hasn't drifted since approval
npx ts-node --transpile-only index.ts verify my_feature .spec-architect/AUDIT_MY_FEATURE_<ts>.md# .github/workflows/spec-audit.yml
- name: Run spec audit
run: |
npx ts-node --transpile-only /path/to/spec-architect/index.ts audit my_feature \
--json --ci \
--config ./spec-architect.config.jsonExit code is 1 if any blocking gaps exist. Pair with the JSON output for PR annotations.
spec-architect maps requirements to code using three strategies, in descending confidence:
| Method | Confidence | How |
|---|---|---|
@spec-req FEAT-001 JSDoc tag |
1.0 | Explicit annotation in code |
Frontmatter implements list |
0.8 | Spec frontmatter declares which files implement it |
| Heading ID regex match | 0.5 | Heading pattern FEAT-001: matched to symbol names |
Low-confidence mappings are surfaced as VAGUE and never silently ignored.
Each requirement gets a fidelity score (0–100%):
Base: mapping confidence × 40%
+30% if a test references this requirement
+30% if that test passes
×0.5 if implementation is @deprecated
×0.8 if implementation has a @todo
MIT — see LICENSE.
Contributions welcome.