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. 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:

  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

  • 📖 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.5

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.17.5
File Size Uploaded
banh_mi_guard-0.17.5.tar.gz 514.9 kB Details

Built distribution (wheel)

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

Total release size: 832.3 kB

Release files / banh_mi_guard-0.17.5.tar.gz

Download URL banh_mi_guard-0.17.5.tar.gz
Size 514.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6876c46e8eb7cc953274530237401d5254a1d4f78d9c10201ee63e1e5d39a1b5
BLAKE2b-256 checksum
How to use checksums
242bb53263d2d3a5ebb466c919b9327eed0e0d0450c301e257772490684027a7
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

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

Download URL banh_mi_guard-0.17.5-py3-none-any.whl
Size 317.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a8a37fc140ed42e9b595cf0c8a0a101148b2c0452ea9a24eeaeb267f0f2302b
BLAKE2b-256 checksum
How to use checksums
db49059897e26fb94528b341dac30758981091c57c5fdfa019a1c67a36572e75
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

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.17.5 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