Keep acceptance criteria aligned with code.
Lightweight GitHub Action to prevent spec drift in PRs.
Spec Drift Guard checks your PR description for acceptance criteria (AC IDs) and verifies that each AC appears in the actual code/test/analytics changes. If any AC ID is missing from the diff, the action fails.
This keeps requirements tied to implementation and prevents ?spec drift.?
- Add a PR template with AC IDs:
## Acceptance Criteria
- [ ] AC-1: User can reset password
- [ ] AC-2: Email is sent within 60 seconds- Add the workflow:
name: Spec Drift Guard
on:
pull_request:
types: [opened, edited, synchronize]
jobs:
spec-drift:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: kappa9999/[email protected]
with:
token: ${{ github.token }}
ac_regex: "AC-[0-9]+"
require_ac: "false"
fail_on_missing: "true"- Parses the PR body using
ac_regex(defaultAC-[0-9]+). - Collects all files changed in the PR.
- Marks an AC as covered if it appears in a file name or in the diff patch.
- Fails the PR if any AC IDs are missing (configurable).
token(required): GitHub token.ac_regex: Regex to find AC IDs in PR body.require_ac: Fail if no AC IDs are found.fail_on_missing: Fail if any AC IDs are missing from changes.summary: Write a summary to the Actions summary.
See docs/POLICY.md.
This repo includes a demo PR branch that exercises the action:
- AC-1 is referenced in
docs/DEMO_PR_BODY.md - AC-2 is referenced in
src/demo.js
- GitHub API
patchcontent can be truncated for large diffs. - If an AC is covered but not explicitly referenced in diffs, the action will still fail.
- Per-path rules (tests vs analytics)
- Optional deep content scan
- PR comment with actionable fixes