Invar Logo

From AI-Generated
to AI-Engineered Code

Invar brings decades of software engineering best practices to AI‑assisted development.

Through automated verification, structured workflows, and proven design patterns, agents write code that's correct by constructionβ€”not by accident.

πŸ€– Dogfooding β€” Invar's code is 100% AI-generated and AI-verified using itself

The Approach

Not a validator that checks code after the factβ€”a methodology that guides agents to write better code from the start.

Without Invar

  • No specification β€” Agent guesses intent, misses edge cases
  • No feedback loop β€” Errors accumulate undetected
  • No workflow β€” Jumps to implementation, skips validation
  • No separation β€” I/O mixed with logic, untestable

With Invar

  • Contracts as spec β€” @pre/@post define exact boundaries
  • Multi-layer verification β€” Static + doctest + property + symbolic
  • USBV workflow β€” Understand β†’ Specify β†’ Build β†’ Validate
  • Core/Shell split β€” Pure logic isolated, 100% testable

The key insight: process determines quality. When agents follow proven engineering practices, they produce code that meets specificationsβ€”verified automatically.

What It Looks Like

Agent workflow with Invar guidance

βœ“ Check-In: my-project | main | clean
━━ /develop β†’ SPECIFY (2/4) ━━
# Agent defines contract before implementation
@pre(lambda principal, rate, years: principal > 0 and rate >= 0)
@post(lambda result: result >= principal)
def compound_interest(principal, rate, years): ...
━━ /develop β†’ VALIDATE (4/4) ━━
$ invar guard --changed
WARN: missing doctest example (compound_interest)
# Agent fixes automatically, re-runs guard
$ invar guard --changed
Guard passed. (1 file, 0 errors)
βœ“ Final: guard PASS | 0 errors, 0 warnings
βœ“ Check-In: my-project | main | clean
━━ /develop β†’ SPECIFY (2/4) ━━
// Agent defines schema before implementation
const InterestInput = z.object({
principal: z.number().positive(),
rate: z.number().min(0),
years: z.number().int().positive()
});
function compoundInterest(input: InterestInput): number { ... }
━━ /develop β†’ VALIDATE (4/4) ━━
$ npm run test
WARN: missing test case (compoundInterest)
// Agent adds tests, re-runs validation
$ npm run test
All tests passed. (3 tests)
βœ“ Final: tests PASS | 0 errors, 0 warnings

Get Started

One command to set up your project

cd your-project && uvx invar-tools init

Interactive mode β€” select your agent. Add pip install invar-runtime for runtime contracts.

βœ… Claude Code

invar init --claude

βœ… Pi

invar init --pi

🚧 Cursor / Other

In progress

Built On

Decades of research, one integrated workflow

Foundational Theory

1976 Symbolic Execution (King)
1986 Design by Contract (Meyer)
2000 Property-Based Testing (QuickCheck)
2012 Functional Core/Imperative Shell (Bernhardt)

AI Code Generation Research

2023 Clover β€” Closed-loop verification
2023 Parsel β€” Hierarchical decomposition
2023 Reflexion β€” Self-reflection on failures
2024 AlphaCodium β€” Flow engineering

Inspired By

Eiffel Dafny Idris Haskell