Banh Mi Guard (guard)
Dual-Gate Impact Analysis & Regression Guard for AI-Assisted Development
Enforcing the Sandwich Pattern with scope control, deterministic diff auditing, project invariants, and LLM gatekeeping.
guard wraps coding workflows in an automated safety harness that verifies changes before and after execution. It runs two gates around each task: a pre-task scope check and a post-task verification gate combining deterministic diff checks, static rules, project invariants, and an LLM review.
Live Documentation: https://okrath.github.io/banh-mi-guard/
Cross-Platform Installation (Windows, Linux, macOS)
Install the guard CLI globally on any platform:
# Recommended: Isolated global installation with pipx
pipx install banh-mi-guard
# Or with standard pip across all platforms:
pip install banh-mi-guard
For environment $PATH configuration, installation from GitHub main, and optional Alibaba OCR CLI setup, see CLI Reference: Installation & Environment Setup.
Five-Minute Quickstart
Integrate guard into your workflow in four simple steps:
# 1. PRE-TASK: Declare scope and capture baseline before editing code
guard pre "Implement mobile responsive navigation drawer" --scope src/components/nav
# 2. EDIT: Modify code using your AI agent (Claude Code, Cursor, Codex, etc.) or editor
# 3. POST-TASK: Verify diffs, static security rules, build health, and LLM approval
guard post
# 4. COMMIT: Commit approved changes (approvals are HMAC-signed; unapproved commits or unsigned older sessions are blocked)
git commit -m "feat: add responsive navigation drawer"
To run deep repository inspection with Alibaba OCR, use guard post --full. For a large or security-sensitive change, the post report asks you (through your agent) whether you want a deeper review by a panel of three reviewers, a full OCR review, or both.
Three-Pillar Architecture
Every modification is verified before and after execution across three layers:
- Deterministic Pre-Task Gate (0 tokens): Locks declared scope boundaries, records baseline snapshots, and evaluates project invariants.
- Deterministic Post-Task Verification (0 tokens): Audits diff blast radius, runs compilation/tests, checks for deleted references (
DEAD-REF), evaluates static rules (SEC-001toSEC-008), and detects code hygiene issues. - Generative LLM Gatekeeper: Configured LLM (Claude, GPT, DeepSeek, Ollama, or local agent CLIs) evaluates batched diffs and verified evidence for a final
APPROVEDorREVISEverdict. Approved sessions receive a cryptographic HMAC signature required by Git commit hooks.
For architectural diagrams, taxonomy, and security specifications, see Architecture Specification.
Command Overview
- Verification Harness (
guard pre,guard post,guard run): Enforces the Sandwich Pattern.guard presets scope and invariant baselines;guard postaudits diffs, executes test suites, and requests gate approval;guard runwraps external commands in both gates atomically. See CLI Reference: Pre & Post. - Project Invariants (
guard invariants): Enforces domain and team behavioral invariants without token costs using regex checks across local (.guard/invariants.json) and shared (guard.invariants.json) files. See CLI Reference: Invariants. - Agent & Hook Integration (
guard install,guard hook,guard agent,guard uninstall): Configures Git hooks (core.hooksPath) and injects directives into global agent instruction files (CLAUDE.md,AGENT.md). Agent hook adapters intercept edit tools to block out-of-scope or unauthorized modifications. See CLI Reference: Installation & Hooks. - Configuration & Setup (
guard config,guard setup): Interactive wizards for configuring LLM credentials (APIs or local agent CLIs likeclaude,codex,omp), syncing settings to Alibaba OCR, and choosing commit message policies. See CLI Reference: Configuration. - Review, Findings & Approvals (
guard review,guard finding,guard accept,guard reset): Runs on-demand LLM diff reviews, tracks deferred or rejected findings, provides an interactive decision screen when review budgets are exhausted, and archives sessions. See CLI Reference: Review & Accept. - Diagnostics & Supply-Chain Security (
guard doctor,guard update,guard untracked): Performs environment diagnostics, upgrades guard (directly from GitHub) or Alibaba OCR (under a 3-day supply-chain quarantine cooling period covering OCR only), and tracks untracked directory exclusions. See CLI Reference: Doctor & Update.
Documentation & Quality Reference
- 📖 CLI Command Reference: Complete option flags, syntax, and operational rules for every command.
- 🏛️ Architecture Specification: Detailed system taxonomy, defense layers, state isolation, and HMAC approval signing.
- 🔎 Review Options, Stages & Limits: Optional review stages of
guard post(reviewer panel, finding validation, test evidence, threat frame), what they cost, and the Not reviewed / limits section of the report. Developer-only measurement tool: Benchmark. - 🛡️ Quality Pillars & Matrix: 2D quality matrix (domains × pillars), static rule catalog, and scoring rules.
- 🚀 Releasing Guide: Release process, version tagging, and PyPI trusted publishing workflow.
- 🌐 Live Documentation Website: Interactive documentation guide and full feature matrix.
Running the Test Suite
Run the integration and unit test suite locally:
pytest
Metadata
Release files for banh-mi-guard 0.17.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| banh_mi_guard-0.17.4.tar.gz | 510.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| banh_mi_guard-0.17.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 824.8 kB
Release files / banh_mi_guard-0.17.4.tar.gz
| Download URL | banh_mi_guard-0.17.4.tar.gz |
|---|---|
| Size | 510.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3269b2eb3dfb92cd0285c98af60dcc5f4ea5d860ae0b21f9d4671dbdf365c811
|
|
BLAKE2b-256 checksum How to use checksums |
cbe41580ad972718f2b91da4d7b142748b7c097a0bf947530b4fdf4414fce737
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / banh_mi_guard-0.17.4-py3-none-any.whl
| Download URL | banh_mi_guard-0.17.4-py3-none-any.whl |
|---|---|
| Size | 314.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
724de8eaa73e82c5a5976c39d333b8c50543fc77c66efdac9ae7ce97f9f84619
|
|
BLAKE2b-256 checksum How to use checksums |
851f8672af560747966551f6860da20e054379a7dbfe91192521239a30c8f8d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency log