Skip to main content

Banh Mi Guard (guard)

Banh Mi Guard Logo - The Bánh Mì Sandwich Pattern
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.

License Python Documentation Platform Architecture

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.


Three-Pillar Architecture

Every modification is verified before and after execution across three layers:

  1. Deterministic Pre-Task Gate (0 tokens): Locks declared scope boundaries, records baseline snapshots, and evaluates project invariants.
  2. Deterministic Post-Task Verification (0 tokens): Audits diff blast radius, runs compilation/tests, checks for deleted references (DEAD-REF), evaluates static rules (SEC-001 to SEC-008), and detects code hygiene issues.
  3. Generative LLM Gatekeeper: Configured LLM (Claude, GPT, DeepSeek, Ollama, or local agent CLIs) evaluates batched diffs and verified evidence for a final APPROVED or REVISE verdict. 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 pre sets scope and invariant baselines; guard post audits diffs, executes test suites, and requests gate approval; guard run wraps 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 like claude, 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


Running the Test Suite

Run the integration and unit test suite locally:

pytest

Metadata

Release files for banh-mi-guard 0.16.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for banh-mi-guard 0.16.0
File Size Uploaded
banh_mi_guard-0.16.0.tar.gz 465.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for banh-mi-guard 0.16.0
File Interpreter ABI Platform
banh_mi_guard-0.16.0-py3-none-any.whl Python 3 none any Details

Total release size: 762.8 kB

Release files / banh_mi_guard-0.16.0.tar.gz

Download URL banh_mi_guard-0.16.0.tar.gz
Size 465.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a9cc6da98ddc869889b62a0b7fd1ab2cfd12a2d2c1c3712507248aecb157cac0
BLAKE2b-256 checksum
How to use checksums
a81843d86ac410b10b3d5b8bb5b21fe08c523261bb31b3aaadbf4135b206e5ce
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 8, 2026.

Transparency log

Release files / banh_mi_guard-0.16.0-py3-none-any.whl

Download URL banh_mi_guard-0.16.0-py3-none-any.whl
Size 297.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c3a7f8a724da8c3784409b30bc87a881e03140e7e15f2313e65f9a472624fb4
BLAKE2b-256 checksum
How to use checksums
7bc14523130b8c9c3f6d84263f633623fc8bfcfb7f8140fcd440c05449d9ea29
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 8, 2026.

Transparency log

Release history Release notifications | RSS feed

0.17.9

2 release files

0.17.8

2 release files

0.17.7

2 release files

This release

0.16.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page