Kubernetes · AI agents · open source · v0.3
See what your AI agent's kubectl write would break before it runs
kube-belay is an open-source proxy that runs on your laptop between an AI agent (Claude Code, Cursor, an MCP server) and your Kubernetes cluster. Reads pass. Each write is replayed on the API server with dryRun=All, explained in plain words and held until you press a key in your terminal. It is a seat belt for cooperative agents. It does not stop an agent that wants to get around it.
What a command breaks depends on the cluster
"kubectl patch service web" looks harmless. Whether it leaves the Service with zero pods depends on pod labels, and those are not in the command, so a guard that matches patterns in the command text cannot tell. kube-belay asks the API server and reads the cluster around the object before the write happens.
What kube-belay does
Go · Apache-2.0 licence · version 0.3.0
Dry run of the exact request
Each write is replayed with dryRun=All. After your yes it is dry-run once more and the same bytes go through.
What follows, in plain words
37 rules in code, no model: what a namespace delete takes with it, a PVC whose volume has reclaim policy Delete, the pods behind a Service before and after, a binding to cluster-admin.
You approve in your terminal
A write goes through only on a keypress in the serve terminal. For a critical finding you type the word yes. If you do not answer in 100 seconds, the agent gets a 403.
Secrets stay away from the agent
A Secret's values wait for your yes before the agent can read them.
Preview without an agent
kube-belay preview -- kubectl delete namespace shop shows what the command would do and changes nothing. Works for helm too.
Observe mode
serve --observe lets everything through and reports what would have asked you.
Local
Talks only to your API server, sends no telemetry, installs nothing in the cluster. Decisions go to a hash-chained log.
Quick start
go install github.com/andronaft/kube-belay/cmd/kube-belay@latest
kube-belay preview -- kubectl delete namespace shop # what would it break? changes nothing
kube-belay serve --context staging --policy builtin # terminal 1: you approve here
export KUBECONFIG=~/.local/state/kube-belay/staging/agent.kubeconfig # terminal 2: the agent's
kube-belay agent-rules >> CLAUDE.md # how to read kube-belay's answers
claude
Questions
Why not give the agent a read-only kubeconfig?
If reads are all you need, do that: it is the stronger control. kube-belay is for when you want the agent to write and still see each write before it happens.
Is it a security boundary?
No. It does not stop an agent that wants to get around it: one running as your OS user can read your other kubeconfigs or stop the proxy. For a real boundary, run the agent as another user or in a container or VM, with only kube-belay's kubeconfig.
How is it different from kubectl diff?
kubectl diff shows the fields of the objects in your manifests. kube-belay takes the request the agent actually sends, shows what follows in the live cluster, then lets through exactly those bytes or nothing.
Will I end up pressing y all day?
Reads never ask. A write whose dry run changes nothing passes, and so do the agent's own dry runs. Run serve --observe for a day to see how often it would ask.
What does it work with?
Anything that uses a kubeconfig: kubectl, helm, client-go programs. Tested with Claude Code, kubectl 1.34, Helm 4.3, envtest and kind. Not yet run on EKS, GKE or AKS.
Read more
How and why I built it, and my other tools.