CLI Commands

All kern CLI commands and flags.

kern dev

Watch mode — auto-compiles .kern files on every change. This is the main command for local development.

kern dev <file.kern|dir> [--target=<target>] [--outdir=<dir>]

Flags

  • --target — Compilation target: nextjs, vue, nuxt, express, native, web
  • --outdir — Output directory for generated files

Examples

# Watch a single file, emit Next.js components
kern dev app.kern --target=nextjs --outdir=app/

# Watch an entire directory, emit Vue SFCs
kern dev kern/ --target=vue --outdir=src/

kern compile

One-shot compilation — processes files once and exits. Same flags as kern dev but without file watching.

kern compile <file.kern|dir> [--target=<target>] [--outdir=<dir>]

Examples

# Compile all .kern files in a directory
kern compile kern/ --target=nextjs --outdir=app/

# Single file compile for CI
kern compile dashboard.kern --target=vue --outdir=dist/

Additional flags

  • --facades — Auto-generate re-export facades in src/
  • --facades-dir=DIR — Custom facades directory
  • --barrel — Generate barrel index.ts in output dir
  • --strict-parse — Fail on parse errors
  • --json — Output structured JSON diagnostics (for LLM self-correction)

kern schema v3.2

Dumps the full KERN language schema as JSON — all node types, their props, allowed children, style shorthands, and multiline block types. Useful for LLM consumption and tooling integration.

kern schema [--json]

Example

$ kern schema --json > kern-schema.json
# Full schema: node types, props, children, shorthands

kern import v3.2

Convert existing TypeScript files to .kern source. Analyzes your code structure and generates the equivalent KERN representation.

kern import <dir|file> [--outdir=<dir>]

Example

$ kern import src/components/ --outdir=kern/
Imported 12 files → kern/
  dashboard.kern (47 lines, was 156 lines TS)
  settings.kern  (23 lines, was 89 lines TS)

kern review

Deep static analysis for TypeScript and Python. Runs 159 AST-based rules + 21 concept rules against your codebase.

kern review <dir|file> [flags]

Flags

  • --json — Machine-readable JSON output
  • --sarif — SARIF format for GitHub Security tab
  • --summary — Human-readable summary
  • --enforce — Exit with non-zero code if findings exceed threshold
  • --min-coverage=N — Minimum coverage percentage (used with --enforce)
  • --llm — LLM-exportable format (5x smaller IR)
  • --recursive — Recurse into subdirectories

Examples

# Review a directory recursively
kern review src/ --recursive

# JSON output for CI pipelines
kern review src/ --json --recursive

# SARIF for GitHub Security tab
kern review src/ --sarif > results.sarif

# Enforce minimum coverage in CI
kern review src/ --enforce --min-coverage=80 --recursive

# Human-readable summary
kern review src/ --summary

# LLM-assisted analysis
kern review src/ --recursive --llm

kern test

Native testing — runs .test.kern files. AST-shape assertions and runtime expression evaluation against .kern sources. KERN's own conformance suite is written this way. Full reference: /docs/test.

kern test <file-or-dir> [flags]

Common flags

  • --watch — Re-run on file changes
  • --bail — Stop on first failure
  • --grep <pattern> — Filter test names
  • --json — Structured run summary for CI
  • --coverage / --min-coverage <pct> — Rule coverage with threshold gating
  • --baseline <file> / --write-baseline <file> — Diff warnings against a saved baseline
  • --explain-rule <rule> — Explain what a single assertion rule checks
  • --generate — Scaffold a .test.kern next to a source file

Examples

# Run every .test.kern under a directory
kern test src/

# Watch mode
kern test src/ --watch

# CI: JSON output, fail on new warnings vs baseline
kern test src/ --json --baseline test-baseline.json

kern scan

Detects your project's framework versions and generates a kern.config.ts file with the appropriate target and settings.

kern scan <dir>

Example

$ kern scan .
Detected: Next.js 14.2, React 18, Tailwind 3.4
Generated kern.config.ts with target "nextjs"

kern init-templates

Initializes templates from the built-in catalog based on your package.json dependencies. Automatically detects Zustand, SWR, Prisma, and other common libraries.

kern init-templates [--package=<name>]

Flags

  • --package=<name> — Scope template initialization to a specific package

Example

$ kern init-templates
Found: [email protected], [email protected], [email protected]
Initialized 3 template sets in kern/templates/

kern evolve

Detects pattern gaps in your codebase and proposes new templates to fill them. Experimental — requires review before applying.

kern evolve <dir> [--approve] [--reject]

Flags

  • --approve — Accept all proposed templates
  • --reject — Reject all proposed templates

Example

$ kern evolve src/
Found 2 pattern gaps:
  1. Repeated fetch+loading+error in 4 components
  2. Modal open/close state in 3 components
Proposed: async-data-view.kern, modal-state.kern
Use --approve to accept or --reject to discard.

kern confidence

Analyzes the confidence graph for review findings. Shows how confidence scores propagate across rule layers and dependencies.

kern confidence <dir>

Example

$ kern confidence src/
Confidence graph: 47 findings, avg 0.82
  High (>0.9):  31 findings
  Medium (0.7-0.9): 12 findings
  Low (<0.7):   4 findings

kern version

Prints the installed kern CLI version.

kern --version