Trust AI Code
Without Reading Every Line

You use AI to write code. Reading every line defeats the purpose.

Invar provides mechanical verification so you can trust AI output without manual review.

The Six Laws

Principles that make AI code verifiable

1

Separation

Pure logic (Core) and I/O (Shell) must be physically separate

2

Contract Complete

Define COMPLETE boundaries that uniquely determine implementation

3

Context Economy

Read map → signatures → implementation (only if needed)

4

Decompose First

Break complex tasks into sub-functions before implementing

5

Verify Reflectively

If fail: Reflect (why?) → Fix → Verify again

6

Integrate Fully

Verify all feature paths connect; local correctness ≠ global correctness

The Workflow: ICIDIV

AI follows this workflow for every task

I
Intent
C
Contract
I
Inspect
D
Design
I
Implement
V
Verify

Example — You: "Add a function to calculate discounted price"

IntentCore function (pure logic, no I/O)
Contract@pre: price > 0, discount ∈ [0,1]. @post: result ≥ 0
Inspectinvar sig — check existing patterns
DesignFile size OK, no extraction needed
ImplementWrite code with contracts and doctest
Verifyinvar guard — Smart Guard runs static + doctests
@pre(lambda price, discount: price > 0 and 0 <= discount <= 1) @post(lambda result: result >= 0) def discounted_price(price: float, discount: float) -> float: """ >>> discounted_price(100, 0.2) 80.0 """ return price * (1 - discount)

What You Get

Invar handles mechanical correctness. You focus on business logic.

Invar Verifies

• Contracts exist (boundaries were considered)
• Contracts aren't empty placeholders
• Doctests pass (behavior is proven)
• Pure logic has no I/O calls
• Code size limits respected

👤 You Judge

• Whether contracts match business requirements
• Whether edge cases are covered
• Whether the architecture is correct
• Whether to ship

Three Verification Levels

Choose depth based on your needs

$ invar guard --static # STATIC: rules only
✓ Static analysis passed
$ invar guard # STANDARD: rules + doctests (default)
✓ Static analysis passed
✓ Doctests passed
$ invar guard --prove # PROVE: + CrossHair verification
✓ Static analysis passed
✓ Doctests passed
✓ CrossHair verified (2 files, 4.5s)
# --prove runs automatically in pre-commit
# Incremental verification: only changed files (~5s)

Quick Start

1

Install

pip install python-invar
2

Initialize

invar init
3

Use AI

AI follows INVAR.md

Configure Your AI Tool

Claude Code
Automatic
Cursor
Rules → INVAR.md
Others
System prompt