How it works
A drift check answers one question: does this code change actually do what it was supposed to do?
You write the intent in prose. The engine extracts the discrete requirements from it, then has several models independently judge each requirement against the real diff — every verdict has to cite a quote that mechanically matches the patch, so a model cannot vouch for code that is not there. It also reports the reverse: significant changes in the diff that no requirement explains.
Nothing to install in your repository beyond a job that calls the API. There is no bot, no app, and no webhook — your pipeline makes two HTTP requests and prints the report.
Note:Drift checks are most useful at a release boundary — the branch or PR that is about to be promoted. That is where "did we build what we said" has consequences, and where the spec was written by someone other than the author of the code.
Set up once
1. Create an API key with the prs:read scope in the ScopeDocs app under
Settings → API keys. Keys look like sk-sd_… and are shown once.
2. Add it as a repository secret named SCOPEDOCS_API_KEY, under
Settings → Secrets and variables → Actions. That is the only secret the check
needs — the backend URL has a default, and you override it only for a
self-hosted deployment.
3. Commit a spec file at .scopedocs/drift-spec.md.
Writing the spec
The spec is prose, not a checklist — the engine does the breaking-down. Four questions are enough:
What: shoppers can apply a discount code at checkout.
How: a code field on the checkout page, validated against the discount table
and applied to the order total before shipping is calculated.
Expected: a valid code lowers the total; an expired or unknown code shows an
error and leaves the total unchanged; the applied code is stored on the order.
How would you know: entering a valid code at checkout lowers the displayed
total, and the order record shows which code was used.
Anything between 20 and 40 000 characters works — a pasted ticket, a section of meeting notes, or a paragraph you typed.
Tip:Keep the spec in version control alongside the code it describes. A spec written before the change, by whoever asked for it, is what makes the check meaningful — a description written afterwards by the author always agrees with itself.
GitHub Actions
Use the scopedocs/spec-drift-check
action. It reads the spec, calls the API, polls for the result, and writes the
report into the job summary.
On a release pull request — the check appears alongside your other PR checks:
name: Spec drift check
on:
pull_request:
branches: [main] # your release branch
permissions:
contents: read
# One check per branch — a force-push shouldn't pay for a second run.
concurrency:
group: drift-${{ github.ref }}
cancel-in-progress: true
jobs:
drift:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: scopedocs/spec-drift-check@v1
with:
api-key: ${{ secrets.SCOPEDOCS_API_KEY }}
The pull request number comes from the event, and the spec falls back to the PR
description when .scopedocs/drift-spec.md is absent.
On every push to an integration branch, before the release PR exists,
compare the branch against its release base — add base-ref and change the
trigger:
on:
push:
branches: [qa]
jobs:
drift:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: scopedocs/spec-drift-check@v1
with:
api-key: ${{ secrets.SCOPEDOCS_API_KEY }}
base-ref: main # the release base to compare against
head-ref defaults to the branch that was pushed. A push event carries no PR
body, so the committed spec file is the only source here.
The action never breaks your build by accident: a missing spec, an invalid key,
an unreachable backend, or a failed run each report their reason and finish
successfully. Its status output tells you which happened — complete,
failed, timeout, error, or skipped — alongside coverage-score,
run-id, and report-path:
- uses: scopedocs/spec-drift-check@v1
id: drift
with:
api-key: ${{ secrets.SCOPEDOCS_API_KEY }}
- uses: actions/upload-artifact@v4
if: steps.drift.outputs.report-path != ''
with:
name: drift-report
path: ${{ steps.drift.outputs.report-path }}
Warning:A
pull_requestrun triggered from a fork receives no secrets, soapi-keyarrives empty and the action reports that instead of checking. Drift checks on fork contributions needpull_request_target, with the usual caution about running workflows with write-capable secrets against untrusted code.
Note:Prefer not to depend on a third-party action, or running somewhere other than GitHub Actions? The check is two HTTP requests — start a run, poll it, print
report_markdown. The Drift API reference has the request shapes and a worked example in curl, Python, and TypeScript.
Reading the report
report_markdown is rendered for you, so the job stays a plain curl. It leads
with the score, then the requirements grouped by verdict — drift first:
## Drift check: 70% of the intent shipped
`main...qa` in acme/backend · 5 requirements · jury of 3
### Missing — no evidence in the diff (1)
- an expired discount code shows an error
- The diff validates the code against the table but never checks its
expiry date, and no error path exists for an expired code.
### Partial — started but incomplete, or shipped switched off (1)
- the applied discount code is stored on the order
- The order model gained a discount_code column, but nothing writes to it.
### Covered (3)
- a valid discount code reduces the order total
- …
Verdicts mean:
| Verdict | Meaning |
|---|---|
covered | implemented, with a diff quote that proves it |
partial | started but incomplete, or shipped behind an off switch |
missing | no evidence in the diff |
contested | the models disagreed, or none could cite valid evidence |
The same run also appears in the ScopeDocs app under the workspace's Drift page, so whoever wrote the spec can read the result without opening your CI.
Failing the build on drift
Report-only is the right default: surface the drift first, enforce once the team trusts the verdicts. When you are ready, fail below a coverage floor:
- uses: scopedocs/spec-drift-check@v1
with:
api-key: ${{ secrets.SCOPEDOCS_API_KEY }}
base-ref: main
fail-under: "0.6" # fail the job below 60% coverage
A floor between 0.6 and 0.8 is a reasonable starting point. Prefer gating on the release boundary only — blocking every feature branch on a coverage number teaches people to write specs that score well rather than specs that are true.
Keeping the cost down
Every check is a full jury pass over the diff, so it is worth being deliberate about when one runs:
- Keep the
concurrencyblock so a rebase cancels the run it superseded instead of paying for both. - Skip draft pull requests.
- Trigger on the integration or release branch, not on every feature branch.
- Large diffs are capped before judging, and the report says so when a file was summarised or the comparison hit the provider's file limit — a 500-file release compare is worth splitting rather than checking in one pass.
Troubleshooting
| Symptom | Cause |
|---|---|
HTTP 401 | The key is wrong, expired, or the secret is not exposed to this job — a pull_request run from a fork gets no secrets. |
HTTP 403 | The key is valid but lacks the prs:read scope. |
HTTP 400 — multiple workspaces | An organization-wide key needs workspace_id in the body. |
HTTP 422 | The spec is under 20 or over 40 000 characters, or a branch target is missing base_ref. |
status: failed — "No changed files found" | The PR/MR number does not exist, the branch names are wrong, or the branch was deleted after its merge. Compare against a branch that still exists. |
Every requirement comes back missing | Usually a spec that describes a whole feature against a diff that carries one slice of it. Check a target that contains the work, or narrow the spec. |
Tip:The same check is available from a chat assistant over MCP, which is the quickest way to try one before wiring up CI: point it at a merged PR whose outcome you already know and see whether the verdicts match your memory.