Automated PR Review
& BDD Criteria Auditing
Configure agents to audit incoming PR diffs against Given-When-Then BDD specifications and enforce token spend caps
On Day 9, you deploy an automated PR review gate that audits incoming Git diffs against Given-When-Then BDD specifications. You will run the BDD auditor script locally on your machine, test it against feature diffs, and inspect the generated Markdown report.
pr-review-report.md) highlighting missing assertions, untested edge cases, and token spend.BDD Specification & Local Feature Branch Setup
Set up a local BDD specification file in your workspace to act as the baseline audit reference.
concepts/login-feature.md in your local project:---
type: Concept
title: "User Authentication BDD Spec"
description: "Acceptance criteria for user authentication flows"
---
# Feature: User Authentication
Scenario: Member Login
Given a registered user navigates to "/login"
When they enter valid email and password
Then they are redirected to "/dashboard"git checkout -b feature/login-updatePR BDD Auditor Prompt & Sample Response
Instruct your AI assistant to generate the automated PR review script that compares incoming code diffs against BDD acceptance criteria.
@workspace Create an automated PR Review step in our CI pipeline that acts as a Quality Engineering auditor.
The agent step must:
1. Inspect the incoming Git diff between the PR branch and main.
2. Compare the code changes against the BDD specifications located in concepts/ or tests/.
3. Check for:
- Missing unit or E2E assertions for newly added routes/components.
- Non-compliance with Given-When-Then formatting.
- Untested edge cases (e.g., error responses, invalid user inputs).
4. Output a formatted Markdown summary report (pr-review-report.md).
Generate the script scripts/qe-part2/audit-pr-bdd.js and provide instructions to run it locally.I have generated `scripts/qe-part2/audit-pr-bdd.js`. Key Capabilities: - Parses Git diff using `git diff origin/main...HEAD` (with local fallback). - Evaluates Given-When-Then BDD criteria and test suite coverage. - Computes estimated token review cost ($0.02 USD). - Writes a formatted `pr-review-report.md` build artifact. β Execute locally via: node scripts/qe-part2/audit-pr-bdd.js
Local Script Execution & Report Inspection
Execute the audit script on your machine to verify report generation before pipeline deployment.
node scripts/qe-part2/audit-pr-bdd.jscat pr-review-report.mdInteractive Simulator & Done-When Checklist
Test interactive PR review gate scenarios using the in-browser simulator below:
Automated PR BDD Audit Gate & Token Budget Governor
Simulate enterprise policy-as-code: Audit PR diffs against Given-When-Then BDD specs and enforce strict $0.50 spend caps.
feature/stripe-3ds-checkout+142 lines, -18 lines across 4 files (checkout.ts, stripe.ts, api/pay.ts, pay.test.ts)- β
Running
node scripts/qe-part2/audit-pr-bdd.jsoutputspr-review-report.md. - β Diff analysis detects modified files and Given-When-Then keywords.
- β CI pipeline attaches the Markdown audit report as a downloadable artifact.
β’ Large Diffs (5000+ Lines): To prevent LLM context exhaustion, pass file paths and summarized hunk headers to the agent rather than raw binary diffs.
β’ Comment Spam: When posting review comments on GitHub, configure the bot to update existing PR comments by ID rather than creating new threads on every push.