Don't Hope AI Code Is Correct.
Know It.

Invar provides mechanical verification for AI-generated code. Pre-commit hooks catch violations before they reach your repository.

Without Invar

  • AI writes code that looks correct
  • You review but can't catch everything
  • Bugs slip through to production
  • Trust erodes over time

With Invar

  • AI writes code with contracts
  • Guard mechanically verifies rules
  • Pre-commit hooks block violations
  • Confidence through verification

How It Works

Three layers of mechanical verification

🛡️

Guard

Static analysis checks architecture rules, contract presence, file sizes, and purity. Catches issues before they become bugs.

📝

Contracts

@pre/@post decorators document and enforce function behavior. Invalid inputs fail fast with clear messages.

🚫

Pre-commit Hooks

Automatic enforcement on every commit. Violations block the commit. No exceptions, no "I forgot to run tests."

See It In Action

$ pip install python-invar
Successfully installed python-invar
$ invar init
Created INVAR.md, CLAUDE.md, .pre-commit-config.yaml
Installed pre-commit hooks
$ invar guard
Files checked: 12 | Errors: 0 | Warnings: 0
Code Health: 100% ████████████████████ (Excellent)

Core/Shell Architecture

Separate what CAN fail from what SHOULD NOT fail

🧠 Core (Pure Logic)

  • No I/O operations
  • @pre/@post contracts required
  • Doctests for examples
  • Fully deterministic

🐚 Shell (I/O Boundary)

  • File, network, CLI operations
  • Returns Result[T, E]
  • Calls Core for logic
  • Handles the messy world

Quick Start

1

Install

pip install python-invar
2

Initialize

invar init
3

Verify

invar guard