Kontrax: Gain Control of Your AI-Generated Code
Kontrax reconstructs the intent behind your code. It automatically infers each routine's hidden assumptions, special cases, guarantees and invariants, audits every call site against them, and reports what it finds — right inside your editor, across 10+ languages with zero compiler setup.
The Problem
AI-supported code generation has taken software development by storm, but engineering teams face major challenges:
Developers can now produce code faster than anyone can read or review it. Initially that feels like pure speed, but the code is still the product and developers remain fully responsible for it:
- Finding bugs: When code inevitably misbehaves or crashes, locating the root cause in unfamiliar, AI-generated logic is painful and time-consuming.
- Fixing bugs: Correcting issues without introducing subtle side effects requires understanding the code's unwritten assumptions.
- Preventing regressions: Ensuring subsequent AI prompts, refactorings, or human edits do not break existing functionality.
The Solution: Kontrax in Your Editor
Kontrax is an easy-to-install extension that ensures you retain complete control over AI-generated code.
Applicable to code written in any programming language, Kontrax analyzes the key properties of your codebase and produces in-editor diagnostics, clear documentation, and runnable tests.
The Properties (Design by Contract™)
Computer code is just a sequence of instructions. Kontrax reconstructs the intent behind those instructions by automatically inferring four kinds of properties, derived from the proven Design by Contract™ methodology:
| Property |
Meaning |
In-Editor Example |
Eiffel Form |
| Hidden Assumptions |
Conditions the code does not test, causing it to crash or malfunction when violated |
user_id must not be null; file must be open |
require |
| Special Cases |
Conditions handled in a dedicated or alternative way |
returns null or fallback default on empty input |
ensure (reported separately) |
| Guaranteed Outcomes |
Conditions that reliably hold when the routine finishes |
the connection is closed; balance is updated |
ensure |
| State Invariants |
Conditions that hold on both entry and exit |
temperature stays within -10..+40 °C |
invariant |
These properties express the abstract intent of your software, bridging the gap between raw implementation code and human understanding.
Extension Features
🛡️ Caller Safety Auditing & Problems Panel
Kontrax continuously checks call sites across your workspace against inferred preconditions. If a caller passes null or an invalid argument to a routine that assumes valid input, Kontrax flags the violation immediately in the VS Code Problems panel with full source context—stopping bugs before they reach production.
⚡ Deterministic-First (0 LLM Tokens)
Kontrax's static analysis runs 100% offline with 0 LLM tokens—making it fast, private, and deterministic. Generating reports and deeper domain-level rule synthesis require an LLM.
🏎️ Cockpit & Interactive Dashboards
- Cockpit View: An automotive-style instrument cluster displaying task progress, remaining credits and plan status, current task state (
Idle / Analysis), and run duration.
- Context & Route Selection: In the sidebar, browse your workspace by Files or Subsystems—with filtering and risky-routine counts—to select the exact Route covered by analysis and reports, or target the current file in one click.
- Reports Panel: Generate LLM-written reports for the selected Route directly from the dashboard.
📄 Clear, Actionable Reports
Using an LLM, Kontrax translates formal properties into clear English reports in Markdown (.md) and interactive HTML:
- Context Overview: High-level module architecture, dependency maps, and subsystem relationships.
- Behavioral Rules & Bug Audit: A ranked audit of behavioral rules, potential defects, and caller violations with severity ratings.
- Security Risks: Risk surfaces, input boundary hazards, and unchecked assumptions.
- Properties Catalog: Complete inventory of inferred contracts per routine.
🧪 Automated Test Generation
Kontrax generates runnable test suites directly from inferred properties:
- Assumption-breaking tests: Specifically designed to violate inferred hidden assumptions (e.g. boundary values,
null, malformed inputs), providing reproducible evidence of deficiencies so developers and AI agents can correct them.
- Guarantee-checking tests: Verifies inferred guarantees to serve as regression suites, ensuring future modifications do not break working functionality.
Supported Languages
Kontrax operates with zero compiler setup across:
- TypeScript / JavaScript
- Python
- Go
- Rust
- C / C++
- Java
- C#
- PHP
Getting Started in VS Code
- Install the Extension from the Marketplace or VSIX.
- Open your project folder in VS Code.
- Analyze:
- Right-click any function or file and select Kontrax: Analyze Implicit Rules for Function / File, or
- Open the Kontrax sidebar icon and click Analyze in the Cockpit view.
- Review Results:
- Check the Problems panel (
Ctrl+Shift+M / Cmd+Shift+M) for caller safety violations.
- View generated documentation and tests under
.kontrax/reports/.
Key Extension Commands
| Command |
Description |
| Kontrax: Analyze Implicit Rules for Function / File |
Analyze and infer contracts for the routine under cursor or active file |
| Kontrax: Synthesize Baseline Contracts |
Deterministic baseline contract synthesis from the AST |
| Kontrax: Verify Contracts and Audit Safety |
Audit all callers against inferred preconditions |
| Kontrax: Mine Contracts from Tests |
Extract behavioral contracts from existing test assertions |
| Kontrax: Infer Rules for Current Function |
Targeted LLM inference for deeper domain rules |
| Kontrax: Select LLM Provider |
Choose Ollama (local/offline), OpenAI, Gemini, Claude, NVIDIA, or OpenRouter |
| Kontrax: Clear Previous Computation |
Reset cache and clear generated reports |
| Kontrax: Show Output Logs |
Open the Kontrax output channel |
Configuration Settings
Configure Kontrax in VS Code Settings (Ctrl+, / Cmd+, searching for kontrax):
| Setting |
Type |
Default |
Description |
kontrax.provider |
string |
ollama |
LLM provider (ollama, openai, gemini, claude, nvidia, openrouter). |
kontrax.cloudModel |
string |
gpt-5.6-terra |
Model name for cloud providers. |
kontrax.ollamaModel |
string |
llama3 |
Local Ollama model name. |
kontrax.ollamaUrl |
string |
http://localhost:11434 |
Ollama server URL. |
kontrax.threshold |
number |
28 |
Risk score threshold for routine candidate selection. |
kontrax.verifyOnSave |
boolean |
false |
Automatically re-verify callers and update diagnostics on save. |
kontrax.include |
array |
[] |
Glob patterns or directories to include. |
kontrax.exclude |
array |
[] |
Glob patterns or directories to exclude. |
Excluding Files (.kontraxignore)
Kontrax automatically respects .gitignore (root and nested) and .git/info/exclude. To exclude additional files or directories from Kontrax only—without changing your .gitignore—create a .kontraxignore file at your workspace root using standard .gitignore syntax:
# Ignore generated files, vendor code, or unrelated folders
dist/
crates/
*.min.js
*.gen.ts
# Re-include a specific file (later rules win)
!keep.gen.ts
- Patterns are relative to the workspace root; patterns without
/ match at any depth.
- Trailing
/ matches directories; ! re-includes a previously excluded file (note: files inside an excluded directory cannot be re-included).
- Excluded files are skipped during scanning, verification, and LLM report generation—they are never read.
License
Proprietary. See LICENSE.txt for details.