arch-guard — guardrails for machine-written code
As AI tools write more of your codebase, architecture decays quietly: agents reinvent helpers that already exist, reach across layers they should never touch, and spin dependency cycles. arch-guard is the static linter that says no — in pre-commit hooks and in CI.
What it enforces
- Layered Boundary Enforcement: declarative rules like “UI components cannot import DB models directly” — defined per-layer in
arch-guard.config.json. - Duplicate Utility Detection: flags when an agent writes a helper that already exists in
src/utils/. - Circular Dependency Prevention: instant cyclic module graph checker.
- Zero-Overhead CLI: a full audit in < 1 second using fast AST parsing — cheap enough to run on every commit.
Why it exists
The AI-codegen era needs referees, not just players. arch-guard is one of a pair with langgraph-zod: one guards the graph at runtime, the other guards the repo at commit time.