Skip to main content

CLI, MCP, LSP, and VS Code extension for kustomize manifest drift detection

Project description

kdrift

CLI, MCP, LSP, and VS Code extension for kustomize manifest drift detection. Discovers which overlays are affected by your changes, renders baselines and candidates, and diffs per-resource.

Install

uv tool install kdrift
# or: pip install kdrift

Requires Python 3.13+ and kustomize on PATH.

For unreleased changes on main:

uv tool install git+https://github.com/mikedougherty/kdrift

Usage

kdrift diff                             # diff all affected overlays vs HEAD
kdrift diff k8s/base/deployment.yaml    # diff overlays affected by this file
kdrift diff --overlay k8s/dev           # diff only this overlay
kdrift diff --ref main~3                # diff against a specific ref
kdrift diff --ref main~5..main~2        # compare two commits
kdrift diff -C /path/to/repo            # target a different repository
kdrift diff --format json               # structured JSON output
kdrift diff --check                     # exit non-zero if drift exists (CI/pre-commit)
kdrift diff --watch                     # continuous mode: re-diff on file save

How It Works

  1. git diff --name-only HEAD finds changed files
  2. Dependency graph maps changes to affected leaf overlays (parses all kustomization.yaml reference types)
  3. kustomize build renders baseline (via git worktree, cached) and candidate (working tree)
  4. Two-phase per-resource diff: exact GVK+namespace+name match, then generator-aware matching for hash-suffixed ConfigMap/Secret names
  5. Output as unified diff or structured JSON

Configuration

Create .kdrift.yaml anywhere in your directory tree (searched upward from CWD):

kustomize_args:
  - "--enable-helm"
  - "--load-restrictor"
  - "LoadRestrictionsNone"
kustomize_binary: /usr/local/bin/kustomize  # optional, defaults to PATH
env:                                        # extra env vars for kustomize subprocess
  HELM_REGISTRY_TOKEN: "abc123"

All fields can be overridden via environment variables (KDRIFT_KUSTOMIZE_BINARY, KDRIFT_KUSTOMIZE_ARGS, KDRIFT_KUSTOMIZE_ENV_<NAME>). See the knowledge doc for details.

Development

make deps        # Install dependencies
make validate    # Run all checks (lint + typecheck + test)
make test        # Tests only
make typecheck   # mypy strict mode

See docs/development.md for detailed setup.

Quick Start: MCP Server for Claude Code

Give your AI agent kustomize drift detection in two steps:

1. Install kdrift:

uv tool install kdrift

2. Add to your Claude Code MCP config (.claude.json or project .mcp.json):

{
  "mcpServers": {
    "kdrift": {
      "command": "kdrift",
      "args": ["mcp"]
    }
  }
}

That's it. Your agent now has four tools: kdrift_diff, kdrift_discover, kdrift_affected, kdrift_render. Ask it to "check what my kustomize changes affect" and it will use them.

3. (Optional) Add agent instructions for deeper context on how to use kdrift:

@path/to/kdrift/docs/agents/AGENTS.md

Or copy docs/agents/ into your project's agent instructions directory. The files are self-contained and agent-agnostic.

Agent Integration

kdrift ships with agent-readable instructions in docs/agents/. These work with any AI coding assistant that supports AGENTS.md or similar instruction files.

VS Code Extension

The vscode-kdrift/ directory contains a VS Code extension that shows drift diffs in a side panel, modeled after the built-in Markdown Preview. See vscode-kdrift/README.md for setup and development.

LSP Server (IDE integration)

kdrift lsp          # stdio transport, configure in your LSP client
kdrift lsp --debug  # enable file logging to ~/.cache/kdrift/kdrift.log

Provides diagnostics on save, CodeLens annotations, and hover info.

Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kdrift-0.1.3.tar.gz (976.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kdrift-0.1.3-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file kdrift-0.1.3.tar.gz.

File metadata

  • Download URL: kdrift-0.1.3.tar.gz
  • Upload date:
  • Size: 976.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kdrift-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6ebd81eec1c9172118e5c6c67c9d0a2544919a9099e2f418df08c8a6c677fec5
MD5 06caa803161970e2c0b325a1417f6cec
BLAKE2b-256 20aacbbf7414a59f4a3d51aef07257fbf2ccafcecf038b3e3bcb00dc2fb56084

See more details on using hashes here.

Provenance

The following attestation bundles were made for kdrift-0.1.3.tar.gz:

Publisher: publish.yaml on mikedougherty/kdrift

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kdrift-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: kdrift-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kdrift-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f9952f0d0c1efcd4fc535a1524d438481db71dbf7ff18588d8f6134dd4b1409e
MD5 1d90e3d632ee42c0db8e8b0fa36944de
BLAKE2b-256 440c7d761d9717b6c96fa0d07298206de7cc6ebb85aa01af1826797ffff61ae9

See more details on using hashes here.

Provenance

The following attestation bundles were made for kdrift-0.1.3-py3-none-any.whl:

Publisher: publish.yaml on mikedougherty/kdrift

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page