Docs
Enough to install kv-cli, run it and put it in CI. Each section links to the full document on GitHub.
Install
pip or uv
pip install kv-cli uv tool install kv-cli
Either one installs the prebuilt binary from a wheel, with no Rust toolchain needed: Linux x86-64 and ARM64 (glibc and musl), macOS Apple silicon and Intel, and Windows x86-64. On any other platform, pip builds from source, which needs Rust and a C compiler.
Homebrew
brew install kovallent/tap/kv-cli
Release binary
# macOS / Linux: set TARGET to the archive name for your platform, minus kv-cli- and .tar.gz TARGET=aarch64-apple-darwin curl -sSL "https://github.com/kovallent/kv-cli/releases/latest/download/kv-cli-$TARGET.tar.gz" | tar xz sudo mv kv-cli /usr/local/bin/ kv-cli --version
Each release ships SHA256SUMS. To verify a download, run grep "$TARGET" SHA256SUMS | shasum -a 256 -c (or sha256sum -c on Linux). macOS says the app "cannot be opened"? The binary is not notarized and browser downloads are quarantined: run xattr -d com.apple.quarantine kv-cli.
Quickstart
cd ~/your-pipeline-repo kv-cli audit # works with built-in defaults kv-cli init # optional: write .kovallent.yaml to tune the rules
Exit 0 means compliant and 1 means findings. To read real output before trusting the tool with your own code, run it on the bundled samples:
git clone https://github.com/kovallent/kv-cli && cd kv-cli kv-cli init # created ./.kovallent.yaml kv-cli audit --strict samples/ # FAIL 31 errors, 25 warnings — by design kv-cli audit --show-clean samples/ # also lists each clean file, with its scope kv-cli fix samples/deploy.py # FIXED applied 18 changes across 1 file kv-cli audit samples/compliant.py # PASS — must always be clean
It found nothing. Is it working?
- Your SQL pins nothing kv-cli checks, or isn't a dbt model. dbt SQL models are checked for pinned infrastructure (KV003) only. Python gets the full audit; notebooks and config files are scanned for credentials only.
- Your functions are not governed. By default, KV001 covers functions named like
deploy*,run_*,*_pipeline,*_jobormain, or decorated with@task. Runkv-cli initand editapplies_to. - A framework owns your signatures. Check the scope line. A low
in scopecount with a highframework-exemptcount means the exemption is working, not missing things.
kv-cli audit --show-clean names each clean file with its own scope. If no file matched at all, that is not a pass: the run exits 2 with no files to audit.
CI gate
GitHub Action
uses: kovallent/kv-cli@<tag> installs the release binary for the runner, verifies it against the release's SHA256SUMS, annotates each finding on the pull request, writes a job summary with the scope block, and exits with kv-cli's exit code. The gate is that exit code, computed on the runner, so it works without any Kovallent service.
name: kovallent
on:
pull_request:
push:
branches: [main]
jobs:
gate:
name: Kovallent gate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: kovallent/kv-cli@v0.16.0
with:
expect-contract: ${{ vars.KOVALLENT_CONTRACT_SHA }}To upload the JSON report, set upload-url. The Action authenticates with a GitHub Actions OIDC token, so the calling workflow needs permissions: id-token: write. The upload is best-effort and never changes the result.
A failing job blocks a merge only once it is a required status check. Whoever can edit the workflow can drop the gate, so protect .github/workflows/ with CODEOWNERS and code-owner review.
GitLab CI/CD and CircleCI
A GitLab CI/CD component and a CircleCI orb do what the Action does: they install the release binary, verify it against SHA256SUMS, run kv-cli audit --format sarif, keep the SARIF log as an artifact, and exit with kv-cli's exit code. They have no upload.
CI: every input, required checks, protecting the workflow, SARIF, GitLab and CircleCI
Pre-commit
repos:
- repo: https://github.com/kovallent/kv-cli-pre-commit
rev: v0.16.0
hooks:
- id: kv-cli # audits staged Python, notebooks and config files
- id: kv-cli-contract # validates .kovallent.yaml when it changes
- id: kv-cli-strict # manual stage: pre-commit run kv-cli-strict --hook-stage manual --all-fileskv-cli-pre-commit declares the hooks as language: python and pins kv-cli to the same version, which pip installs from the prebuilt wheels: no contributor needs a Rust toolchain. repo: https://github.com/kovallent/kv-cli still works too, as language: rust, building kv-cli from source on first run.
A hook is advisory: --no-verify skips it, and a fresh clone installs none. It is where a finding is cheapest to fix. The CI gate is what guarantees compliance.
VS Code and Cursor extension
The Kovallent kv-cli extension shows kv-cli findings as editor diagnostics in VS Code and Cursor: missing contract parameters (KV001), hardcoded credentials (KV002), pinned infrastructure (KV003) and naming rules (KV004), in Python, notebooks, config files and dbt SQL models.
Install kv-cli first
The extension runs the kv-cli on your PATH, or the one in the kovallent.path setting, and never downloads one, so the editor, your pre-commit hook and CI run the same version. It needs kv-cli 0.9.0 or later, and 0.14.0 or later to check dbt SQL models. If it can't find kv-cli, it says so once and runs nothing.
What it shows
- One diagnostic per finding, read from
kv-cli audit --format json, on open and on save, never on a keystroke. kv-cli reports a line, not a column, so the whole line is underlined. The rule code links to the rule's page for your kv-cli version, and KV002 details arrive redacted. - Files kv-cli couldn't fully check (
syntax_error,sql_not_parsed,unreadable) get an Information diagnostic at line 1 and are never shown as clean. - A status bar item for the active file: its error and warning counts,
clean (N enforced),nothing enforced,credentials onlyorclean (SQL model). It never calls a single file "compliant": that word belongs to kv-cli's run-levelPASS.
Applying a fix
On a KV001 or KV002 diagnostic, Apply kv-cli fix to this file saves the file, opens the output of kv-cli fix --dry-run beside the editor, lists each manual: item, and runs kv-cli fix only after you confirm. Cancelling writes nothing. KV003 and KV004 never get a fix action.
Privacy and workspace trust
The extension makes no network calls and collects nothing. In an untrusted workspace (Restricted Mode) it ignores a workspace-level kovallent.path, because a cloned repository could point it at any program; kv-cli on your PATH or in your user settings still runs.
AI agents (MCP)
kv-cli mcp serves kv-cli's checks to AI coding agents (Claude Code, Cursor, VS Code and any other Model Context Protocol client) as tools they call directly, instead of running kv-cli in a shell and parsing its text output.
- The same binary, the same rules.
mcpis a subcommand of the kv-cli you already install, so the agent, your editor, pre-commit and CI run the same rules at the same version. - Local only. The client starts
kv-cli mcpas a subprocess and talks to it over stdin and stdout: no listening socket, no network call and no account. - It can't weaken the gate. No tool edits the contract, reads the fingerprint pinned in CI, or declares a check passed, and no result contains a credential.
Install
Install kv-cli as usual (see Install) and check that the client will find it:
kv-cli --version
If your editor doesn't inherit your shell's PATH, use the full path to kv-cli (from which kv-cli) as the command in the configurations below. Each one starts kv-cli mcp in your repository.
Claude Code
Add it for yourself, in the current project:
claude mcp add --transport stdio kv-cli -- kv-cli mcp
Everything after -- is the command Claude Code runs. To share the server with your team, add --scope project, or commit this as .mcp.json at the repository root:
{
"mcpServers": {
"kv-cli": {
"type": "stdio",
"command": "kv-cli",
"args": ["mcp"]
}
}
}Claude Code asks each person to approve a project-scoped server before using it. Check the connection with claude mcp get kv-cli.
Cursor
Create .cursor/mcp.json in the repository for the project, or ~/.cursor/mcp.json for every project:
{
"mcpServers": {
"kv-cli": {
"type": "stdio",
"command": "kv-cli",
"args": ["mcp"]
}
}
}VS Code
For Copilot, use .mcp.json at the workspace root to share the server with your team, or ~/.copilot/mcp-config.json (or $COPILOT_HOME/mcp-config.json) for every workspace:
{
"mcpServers": {
"kv-cli": {
"type": "stdio",
"command": "kv-cli",
"args": ["mcp"],
"tools": ["*"]
}
}
}In the user file, also set "cwd" to the repository: VS Code's Copilot runtime may not report roots, and without them kv-cli's workspace is the directory it was started in. Guided setup is Chat: Open Customizations, then MCP Servers, then Add Server.
Any other client
Configure a stdio server whose command is kv-cli with the single argument mcp, started in your repository. kv-cli speaks MCP 2026-07-28 and answers clients that open with the 2025-11-25 initialize handshake.
Check that it works
Ask the agent to run kv-cli's contract_show tool. The result starts with # effective contract: and the contract's path, then # fingerprint. If it says built-in defaults where you expected your .kovallent.yaml, kv-cli was started outside the repository: set the working directory (cwd) in the client's configuration.
| Tool | What it does | Writes? |
|---|---|---|
audit | Audits the given paths (default: the workspace) as kv-cli audit --format json does, with an optional strict. Returns the JSON output unchanged, plus exit_code and verdict. | No |
explain | A rule's reference for a code, KV001 to KV004, as kv-cli explain prints it. | No |
contract_show | The effective contract, defaults marked, and its fingerprint. | No |
contract_check | Validates the contract and lists each problem with its line. | No |
frameworks | The built-in framework profiles and what each contributes. | No |
fix_preview | For the given paths, the fix kv-cli fix would apply: a unified diff with flagged values redacted, the manual: items, and a preview_id. | No |
fix_apply | Applies one preview, given only its preview_id. | Yes |
The audit verdict
verdict is kv-cli's own: PASS (exit 0), FAIL (exit 1, findings) or TOOL ERROR (exit 2, with isError set). Findings are a normal result, not an error, so an agent can tell "your code has problems" from "the check couldn't run". audit is a local check, not the gate: it never compares the contract with the fingerprint pinned in CI, so there is no contract-drift verdict here. Drift is decided in CI, where the pin is.
Previewing and applying a fix
fix_preview plans the fix with kv-cli fix's own logic and writes nothing. fix_apply takes only its preview_id and writes exactly that preview, with .kvbak backups as kv-cli fix makes them. It refuses, writing nothing, unless the preview is unused and less than 10 minutes old, every file in it is byte-for-byte as it was, the contract's fingerprint hasn't changed, and the fix planned again is the one previewed. It never touches .kovallent.yaml. As after kv-cli fix, rotate any credential moved out of the source and delete the .kvbak backups once you've reviewed the change.
What an agent can't do
- Change the contract. No tool writes
.kovallent.yaml, runsinit, or takes a contract path or an override. - Touch the pin. No tool sets, changes or reads the expected fingerprint, which lives in CI.
- Declare a pass. Results carry kv-cli's own verdict, unchanged, and no tool waives, suppresses or baselines a finding. A pull request passes only when kv-cli exits
0in CI. - See a credential. Every result redacts flagged values as the terminal output does, every line of a fix preview included.
- Read or write outside the workspace. Every path must resolve inside the workspace (the client's roots, or the directory the server started in) after
..and symbolic links; anything else is refused. - Reach the network. There is no tool for it, and the server makes no network call.
This server isn't a sandbox: an agent with its own shell or file tools can still edit any file, .kovallent.yaml included. What catches a weakened contract is the pinned fingerprint in CI, which fails the run with exit 3.
Troubleshooting
- The client can't start the server. Use the full path to
kv-clias thecommand, and runkv-cli mcp --helpto check that your installed kv-cli has themcpcommand. - "outside the workspace". Pass a path inside the repository, or start the server in the right folder.
- Results use the built-in defaults. Set the client's working directory to the repository.
- "no preview" or "has changed since the preview". Previews are single use, expire after 10 minutes and don't survive a restart. Call
fix_previewagain.
MCP guide: client sources, protocol details and the reasons behind each limit
Contract file validation
kv-cli init writes a first line pointing editors at the JSON Schema for that release. Unknown keys, wrong types and invalid values in .kovallent.yaml are flagged as you type, and keys autocomplete with their documentation. It works in VS Code with the Red Hat YAML extension; in JetBrains IDEs, map the schema under Languages & Frameworks → Schemas and DTDs → JSON Schema Mappings.
This validates the contract file only. kv-cli itself never fetches the schema; kv-cli contract schema prints it for an offline copy.
Configuration: the contract file, patterns, editor validation, upgrading
Commands
| Command | Purpose |
|---|---|
kv-cli init | Write a commented .kovallent.yaml and report what it enables. --force overwrites. |
kv-cli audit [PATHS] | Scan for violations. --strict, --format json or sarif, --config, --expect-contract. |
kv-cli fix [PATHS] | Apply the standard fixes, backing up each file to .kvbak. --dry-run, --no-backup. |
kv-cli explain [CODE] | Print a rule's reference: what it catches, how to fix it, how to suppress it. |
kv-cli contract check | Validate the contract without scanning code, listing every problem with its line. |
kv-cli contract show | Print the effective contract, with every default marked, and its fingerprint. |
kv-cli contract schema | Print the JSON Schema for .kovallent.yaml, for editor validation. |
kv-cli frameworks | Show the built-in framework profiles and what each contributes. |
kv-cli schema | Print the JSON Schema of the --format json output. |
kv-cli mcp | Serve these checks to AI coding agents over MCP, on stdin and stdout. See AI agents (MCP). |
Every command takes --help, with examples. To suppress one finding, add a trailing # kovallent:allow-secret (KV002) or # kovallent:allow-infra (KV003). To exempt a function from KV001 and KV004, add its name to applies_to.exempt_name_patterns.
Security
- It runs locally. kv-cli is a single binary that parses your code on your machine or CI runner, and needs no account.
- It makes no network call. Not even for the contract's JSON Schema, which your editor follows on its own.
- It redacts values. A credential is shown as
value "s3…" (<redacted>, 20 chars)in the terminal, and the JSON report, SARIF log and Action annotations carry the same redacted detail, never the value. - Release binaries are checksummed. Each release ships
SHA256SUMS; the GitHub Action, GitLab component and CircleCI orb verify the binary against it before extracting, and a mismatch fails the step. fixrewrites your code, on purpose. Runkv-cli fix --dry-runfirst. Each changed file is backed up to.kvbak; when a credential is moved,fixlists the backups that still hold it in plaintext and reminds you to rotate it.- It is open source under the MIT License.
Report a vulnerability to security@kovallent.com.