Open-source language · semantic review · AGPL-3.0
KERN is a compact source format, compiler, and semantic review engine for AI-assisted software. Describe the product, let an LLM draft readable .kern, compile it to your stack, then run review rules that understand effects, guards, taint, routes, and framework contracts.
As of v4 it is a typed core language too — classes, enums, closures, and a first-class RAG node family that compile to real TypeScript and Python, with behavior parity enforced by differential conformance, not promised.
What it is
Raw generated code is long, framework-specific, and easy to misunderstand. KERN gives the model a structured language and gives your team a compiler plus review layer around the result.
Write less
KERN is indentation-based: nodes, props, style shorthands, handlers, types, routes, machines, and tests in a format that is easy to read and cheap for LLMs to generate.
Compile wider
The compiler emits framework-aware code for web, backend, terminal, MCP, Python, Go, and library targets from the same semantic source.
Review deeper
kern review combines AST rules, concept extraction, taint analysis, confidence scoring, native .kern rules, and MCP security checks.
Why LLMs improve
LLMs are strongest when the output format is small, regular, and explicit. KERN keeps layout, routes, types, effects, and review intent in one source tree, so the model has fewer tokens to juggle and humans have a smaller artifact to inspect before compiling.
prompt → .kern → compiled code → review
page name=Checkout
metadata title="Checkout"
schema name=Order
field name=email type=string
route path="/api/order" method=POST
validate schema=Order
handler
do expr={{ await db.orders.create(input) }}Compiler sees page, schema, route, validation, and effect boundaries.
Review can flag missing guards, tainted input, route drift, and unsafe side effects.
Before you ship
Kern looks for the bugs that appear when generated code crosses boundaries: database writes, network calls, auth guards, LLM prompts, client/server drift, and MCP tool handlers.
kern review src/ --recursive
! indirect-prompt-injection
DB result flows into an LLM prompt
without sanitization
~ unguarded-effect
write/network effect is not protected
by an auth or validation guardreview rule registry entries in source
MCP security rule IDs
concept extraction for TypeScript and Python
confidence scores and suppression metadata
Compiles to
First-class RAG
Your corpus, embedding contract, retriever, grounding policy, and evaluation cases are part of the program — typed, validated, and testable — instead of config scattered across notebooks. Citations, grounding, and eval thresholds become enforceable contracts, evaluated against a deterministic in-memory reference runtime.
Read the RAG docs →corpus name=Docs
source name=manuals kind=local uri="./docs/**/*.md"
chunking strategy=semantic maxTokens=600 overlap=80
retriever name=DocsSearch corpus=Docs topK=8 minScore=0.72
rag name=AnswerDocs retriever=DocsSearch citations=true
grounding requireCitations=true policy=strict
ragEval metric=faithfulness threshold=0.85
ragCase query="How do refunds work?"
ragAssert kind=sourceGlob value="docs/refunds.md"
ragAssert kind=citesRequiredLanguage evolution
The evolve pipeline scans TypeScript, detects recurring patterns, proposes templates or structural nodes, validates them, and stages the approved result. It is a way to turn local conventions into reviewable language constructs.
kern evolve:discover src/
scan
detect gaps
analyze patterns
propose templates
validate proposals
stage only approved outputStart here
Install the CLI, ask an LLM for .kern, compile to your target, and run kern review on the generated code.