Requirement coverage for your codebase. Like test coverage, but for acceptance criteria.
Your tests pass. Your lint passes. But does the code actually do what the spec says?
specgate reads your acceptance criteria, finds the evidence for each one in your
codebase, and tells you which requirements are unproven. It is deterministic —
no LLM calls at runtime, no API key, no network. Same repo, same spec, same
score. Every time.
npx --yes --package=https://github.com/aazh2026/specgate/releases/download/v0.1.7/specgate-0.1.7.tgz specgate Requirement coverage: 80% (5 criteria)
✔ covered 4
~ inferred 0
! untested 0
✗ uncovered 1
Criterion Status Evidence
------------------------------------------------------------------------------
AC-1 covered #test/export.test.js:12
User can export invoices as CSV
AC-2 covered #test/export.test.js:21
Export respects the date range filter
AC-5 uncovered —
Admin can schedule a recurring monthly export
Gaps:
AC-5 Admin can schedule a recurring monthly export
AI coding agents write code fast. The spec is where the truth lives — and it
rots first. Three months later nobody can tell whether AC-12 is implemented,
half-implemented, or silently broken. Test coverage tells you which lines ran.
It tells you nothing about which requirements exist.
specgate closes that gap:
| test coverage | requirement coverage | |
|---|---|---|
| unit of measure | line / branch | acceptance criterion |
| answers | "is this code exercised?" | "is this requirement met?" |
| misses | a whole unimplemented feature | — |
# from npmjs — no account, no token
npx --yes specgate-cli
# or install it
npm install --save-dev specgate-cli
# or straight from the git tag
npx --yes github:aazh2026/specgate
# or with Homebrew
brew install aazh2026/specgate/specgate
# or as a container image (no local Node needed)
docker run --rm -v "$PWD:/workspace" -w /workspace ghcr.io/aazh2026/specgate:0.1.7
# or clone and run it directly
git clone https://github.com/aazh2026/specgate
cd specgate && node bin/specgate.jsIf you work inside DeepSeek Harness,
dsh-specgate exposes the same
engine to the agent as a tool, so it can check requirement coverage before it
claims a task is done:
dsh plugin --profile web add dsh-specgateThe plugin is deterministic and local, just like the CLI: no LLM call at runtime, no network, no API key.
Requires Node.js 20+. No runtime dependencies.
On the npm package name. The package is published as
specgate-cli, notspecgate. The unscopedspecgatename is refused by the npm registry because an unrelated package namedspec-gatealready exists and npm's name-confusion rule blocks near-identical names.specgate-cliis the same code with the samespecgatecommand; only the package name differs.
The same tarball is also published to GitHub Packages as
@aazh2026/specgate. Be aware of one registry rule before you use it:
npm.pkg.github.com requires an auth token for every read, even though
the package is publicly visible. An anonymous install returns
401 authentication token not provided.
npm install @aazh2026/specgate --registry https://npm.pkg.github.comwith a .npmrc carrying a GitHub token that has the read:packages scope:
//npm.pkg.github.com/:_authToken=ghp_xxx
This is a fallback for people who already have a GitHub token — npmjs
(specgate-cli) needs no credentials at all.
If your project has no written spec yet, scaffold one:
npx --yes --package=https://github.com/aazh2026/specgate/releases/download/v0.1.7/specgate-0.1.7.tgz specgate initThat writes a starter SPEC.md with the acceptance criteria already structured,
plus a .github/workflows/requirements.yml CI gate. It detects your stack
(language, test runner, package manager) so the scaffold matches your project.
Then edit the criteria, tag your tests, and scan:
npx --yes --package=https://github.com/aazh2026/specgate/releases/download/v0.1.7/specgate-0.1.7.tgz specgatespecgate # auto-discover the spec, print a report
specgate --spec docs/SPEC.md # point it at a specific spec
specgate --format json # machine-readable output
specgate --min 80 # fail CI below 80% coverage
specgate --fail-uncovered # fail if anything is uncovered
specgate --sarif-out specgate.sarif # upload to GitHub code scanning| Flag | Meaning |
|---|---|
--spec <file> |
Spec file to read. Repeatable. |
--format <fmt> |
text (default), json, or sarif |
--min <n> |
Exit 1 if the coverage score is below n |
--fail-uncovered |
Exit 1 if any criterion has no evidence |
--fail-untested |
Exit 1 if any criterion is implemented but untested |
--json-out <file> |
Write the JSON report to a file |
--sarif-out <file> |
Write a SARIF report for GitHub code scanning |
--force |
With init: overwrite existing files |
--name <name> |
With init: project name for the spec title |
-v, --verbose |
Show every criterion, not just the gaps |
specgate does four things, all locally:
1. Parse the spec. It finds your acceptance criteria and gives each one a
stable id. If you wrote ids, it keeps them. If you didn't, it mints AC-1,
AC-2, … in document order, so the tool still works on a plain bullet list.
## Acceptance Criteria
- [ ] AC-1: User can export invoices as CSV
- [ ] [AC-2] Export respects the date range filter
- [ ] Export fails loudly when the storage backend is unavailableIt also reads Gherkin/Cucumber .feature files — a feature file is a spec
by construction, so every scenario becomes an acceptance criterion:
Feature: Invoice export
@AC-1
Scenario: Export invoices as CSV
Given an invoice exists
When the user requests an export
Then a CSV file is producedA scenario tagged @AC-1 keeps the same id as the markdown criterion, so a
SPEC.md and a feature file can describe the same requirement without
double-counting it. Untagged scenarios get SC-1, SC-2, … in document
order. Scenarios are matched against their steps as well as their title, so a
step definition like Given("the user requests an export") counts as evidence
even when the scenario title says something else.
2. Index the code. It walks your repo for source and test files, skipping
node_modules, dist, and friends. Identifier boundaries are respected:
resetPassword, export_csv, and HTTPResponse are all split correctly, so a
criterion written in English prose can match code written in camelCase.
3. Find evidence, in tiers.
| Tier | Status | What it means |
|---|---|---|
tagged |
covered |
An explicit marker — // AC-1, # AC-1, [AC-1] — points at the criterion. |
named |
inferred |
A test name matches the criterion's distinctive words. A hint, not a guarantee. |
text |
untested |
Only implementation code matched. Nothing pins the behaviour down. |
| — | uncovered |
No evidence anywhere. |
4. Score. Evidence tiers are weighted, because they are not equally trustworthy:
score = 100 × (covered×1.0 + inferred×0.75 + untested×0.4 + uncovered×0.0) / total
inferred is discounted on purpose. A test named resetPassword might test
something else entirely. Only an explicit tag is worth full credit.
The quickest way in:
# .github/workflows/requirements.yml
name: Requirement coverage
on: [pull_request]
jobs:
specgate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aazh2026/specgate@v0.1.7
with:
min: 80
fail-uncovered: trueThe action exposes the score as an output:
- id: specgate
uses: aazh2026/specgate@v0.1.7
- run: echo "Coverage was ${{ steps.specgate.outputs.score }}%"Or run the CLI directly:
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: npx --yes github:aazh2026/specgate --min 80 --fail-uncoveredThe gate is the point. A spec that says "the user can export invoices as CSV" should stop a pull request that doesn't implement it.
For GitHub code scanning, upload the SARIF report:
- run: npx --yes github:aazh2026/specgate --sarif-out specgate.sarif --format sarif
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: specgate.sarifOr let the action do it:
- uses: aazh2026/specgate@v0.1.7
with:
sarif: specgate.sarif
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: specgate.sarifAnything Markdown works. specgate looks for a heading matching
acceptance criteria, acceptance, requirements, user stories, criteria
(or 验收标准 / 需求 / 用户故事), and treats the bullets under it as criteria.
Criteria without an explicit id still get one. If your team prefers plain prose, this is enough:
## Acceptance Criteria
- User can export invoices as CSV
- Export respects the date range filterIf your team already numbers things, use it:
## Acceptance Criteria
- [ ] AC-1: User can export invoices as CSV
- [ ] REQ-12: Export respects the date range filterTo move a criterion from inferred to covered, point at it:
// AC-1: User can export invoices as CSV
test('exports invoices as CSV', () => { /* ... */ });# AC-2: Export respects the date range filter
def test_export_respects_date_range():
...import { runSpecgate } from 'specgate';
const report = runSpecgate({ root: process.cwd(), specFiles: ['docs/SPEC.md'] });
report.summary; // { score, total, covered, inferred, untested, uncovered }
report.criteria; // [{ id, text, status, evidence: { tier, file, line } }]
report.stats; // { filesScanned, testFiles }Rust test detection is file-level. A #[cfg(test)] mod marks a mixed source
and test file as a test file; it does not restrict evidence to the test module.
Being honest about what this is:
- It matches text, not meaning. A criterion written as "the operator can
revoke a session" will not match a function called
deleteTokenunless the words overlap. Use explicit tags for anything that matters. inferredis a heuristic. It is weighted down for that reason, but it is not proof.- English and Chinese prose both tokenise, but a spec mixing languages works best when criteria are written in the language that matches the code identifiers.
- It is not a test runner. It does not know whether your tests pass. Pair it with your existing test suite.
Issues and pull requests are welcome. Run the tests with:
npm testMIT
