CLI
Run the correction lane locally with your own Anthropic API key.
Installation
Install globally:
npm install -g kontruaOr as a dev dependency:
npm install -D kontruaCommands
| Command | Description |
|---|---|
kontrua init | Write .kontrua.yml, add it to .gitignore, create docs/, and install git hooks (post-commit, post-merge) |
kontrua update | Run the correction lane against the working tree: regenerate delegated outputs; existing documents remain protected unless their paths allow managed generation |
kontrua preview | Dry run - shows what would change without writing files |
kontrua ci --provider <name> | Generate CI/CD config. --provider takes github or gitlab, and defaults to github |
kontrua context pull | Fetch the latest context artifacts from your Kontrua instance into the working tree |
kontrua context pull
Pulls the repository's current context layer (AGENTS.md, codemap, conventions, and architecture facts when enabled) from Kontrua into your working tree - useful for local agents that read files rather than MCP. Authenticate with a per-repo API token from the dashboard:
export KONTRUA_TOKEN=<your repo API token>
kontrua context pull # write artifacts into the current directory
kontrua context pull --dry-run # preview without writing
kontrua context pull --include-docs # also pull the human documents| Flag | Description |
|---|---|
--url <url> | Kontrua instance base URL (default: https://kontrua.com) |
--token <token> | Per-repo API token (or set KONTRUA_TOKEN) |
--dir <path> | Directory to write into (default: current directory) |
--include-docs | Also pull the human documents Kontrua holds for the repo |
--dry-run | Show what would be written without writing |
Paths returned by the server are validated before anything is written: an absolute path, or one that resolves outside the target directory, is skipped rather than followed.
MCP server
Kontrua also serves the context layer over the Model Context Protocol, so MCP clients (Claude Code, Cursor, and others) can fetch fresh context on demand instead of reading files. Point your client at the endpoint with the same per-repo API token as a Bearer header:
{
"mcpServers": {
"kontrua": {
"type": "http",
"url": "https://kontrua.com/api/mcp",
"headers": { "Authorization": "Bearer <your repo API token>" }
}
}
}The transport is Streamable HTTP with JSON-RPC 2.0, single response, no SSE stream: POST your messages to the endpoint. The server exposes two tools, and the token maps to exactly one repository, so an agent can never read another tenant's context.
| Tool | Arguments | Returns |
|---|---|---|
get_context | include_doc_views, an optional boolean: set it to true to get the human documents alongside the context artifacts. No other property is accepted. | A first text block of JSON - repo, verification (verified, broken, checkable, or null when nothing has been audited yet), freshness, freshnessDetail, artifactCount - then one text block per artifact, each opening with "=== <path> (<docType>) ===" and followed by the file content. |
get_verification | None. | One text block of JSON: repo, verification (verified, broken, checkable, unverifiable and brokenClaims, each with path, line, text and reason), then state, message, description, lagCommits, refreshedAt and refreshedSha. |
Reads are limited to 60 a minute per token, and a call with an unknown tool name comes back as a JSON-RPC error rather than an empty result.
kontrua update flags
| Flag | Description |
|---|---|
--repo <path> | Path to repo root (default: current directory) |
--since <ref> | Update based on changes since a git ref (e.g. HEAD~5) |
--range <range> | Update based on a git ref range (e.g. abc123..def456) |
--trigger <type> | Trigger type: commit or merge (used by git hooks) |
--dry-run | Preview changes without writing files |
Output modes
Configured via output.mode in .kontrua.yml:
| Mode | Behavior |
|---|---|
file-only | Write files to disk. You stage and commit manually. |
commit | Auto-commit doc changes after generation. |
pr | Create a local branch with doc changes. |
.kontrua.yml
Running kontrua init writes exactly this file:
# Kontrua - local configuration.
#
# The verdict (the deterministic audit of supported command and path
# references in selected context files) runs on the server at connect, push and pull request.
# It is free, unlimited, involves no model, and reads nothing from this file.
#
# This file drives the local correction lane only: "kontrua update" reads it,
# calls the Anthropic API with your own key, and generates enabled missing
# outputs or regenerates delegated outputs in your working tree. Existing
# README files are not regenerated. It does not run the web targeted-edit flow.
version: 1
ai:
model: claude-sonnet-4-6
# apiKey: ${ANTHROPIC_API_KEY} # or set ANTHROPIC_API_KEY env var
# The context layer: machine-first artifacts for AI coding agents.
# These values are the defaults; they are written out so the file says what
# the run will actually do.
context:
agentsMd:
enabled: true
output: AGENTS.md
conventions:
enabled: true
output: docs/CONVENTIONS.md
# Off by default: a repository overview is the one artifact class measured
# not to help an agent, so it does not cost every user tokens.
codemap:
enabled: false
output: docs/CODEMAP.md
# Off by default until a consumer (MCP, CLI) needs the JSON.
architectureFacts:
enabled: false
output: docs/architecture.facts.json
docs:
readme:
enabled: true
output: README.md
# Generation of an API reference is retired: the pipeline refuses it at plan
# time, so turning this on buys a skip line and nothing else. An existing
# docs/API.md is still audited like every other document, and the globs below
# keep their other job - they define what counts as a source file, which is
# how the run decides whether your conventions need regenerating.
api:
enabled: false
output: docs/API.md
include:
- "src/**/*.ts"
- "src/**/*.js"
architecture:
enabled: true
output: docs/ARCHITECTURE.md
changelog:
enabled: true
output: CHANGELOG.md
format: keepachangelog # or: conventional
output:
mode: file-only # file-only | commit | pr
commitMessage: "docs: auto-update documentation"
prBranch: docs/auto-update
exclude:
- "node_modules/**"
- "dist/**"
- "**/*.test.ts"
- "**/*.spec.ts"Two things worth reading twice. The api block ships disabled: generation of an API document is retired, and enabled: true would only earn the run a skip line saying so. An existing docs/API.md is still audited like any other document. Its include globs keep one job: they define what counts as a source file, which is how the run decides whether your conventions need looking at again. And the context section is written out rather than left implicit, so the file states what the run will do: AGENTS.md and conventions are on, the codemap and architecture facts are off. Edit those four values to change that.
kontrua init also appends .kontrua.yml to your .gitignore (it can reference an API key), creates docs/ if it is missing, and installs the two git hooks. An existing config file or hook is left alone rather than overwritten.
Config reference
| Key | Description |
|---|---|
ai.model | Which Claude model to use (default: claude-sonnet-4-6) |
ai.apiKey | API key via env var reference ${ANTHROPIC_API_KEY}, or set the env var directly |
context.* | Enable/disable each context artifact and set output paths. Written out by init at the values shown above, which are the defaults |
docs.* | Enable/disable each human document and set output paths |
docs.api.enabled | Generates nothing: API generation is retired. An existing API document is audited, never written |
docs.api.include | Glob patterns that define what counts as a source file, which is what decides whether conventions need regenerating. Use ['auto'] to detect them from the repository |
docs.changelog.format | keepachangelog or conventional |
output.mode | file-only, commit, or pr |
exclude | Glob patterns to skip |
kontrua update runs the correction lane on your machine: it reads the git history, calls the Anthropic API with your own key, and writes to your working tree. It needs no Kontrua account and consumes no plan allowance. kontrua context pull and the MCP server are the exception: both talk to kontrua.com with a per-repo API token, so they need a connected repository. They only read, so they consume no allowance either.Ready to prove your context is true?
Connect your first repository and Kontrua tells you how much of what your docs claim is still true, before it writes anything.