# A Claude Code skill that knows nothing about our clusters

> How we let Claude Code work in our Kubernetes clusters: a team skill that holds only rules, a runbook that holds the facts, and stop rules that hand problems back to people.

Published 2026-12-02 by Nick Sawinyh.
Tags: claude-code, engineering, agents.
Canonical: https://sawinyh.com/blog/claude-code-kubernetes-team-skill/

---

**TL;DR** We gave Claude Code a team skill for our Rancher-managed Kubernetes clusters, and the skill holds no facts. It holds eight rules and a routing table. Every hostname, namespace and deploy rule lives in a runbook of plain pages that people read too, and the plugin ships the runbook inside it. The rules that matter most are stop rules: on a dead token or a refused verb, the agent stops and reports instead of trying another credential or another command. A hook cannot carry this, because blocking kubectl would block the reads, which are most of the work. Enforcement sits in RBAC and short-lived keys. Each page carries a Verified line and a block of facts that a read-only script checks against the live clusters.

The most common wrong answer about our clusters was "it's not deployed." It came from people and from agents alike, and it was almost never true. The service was running. The question had gone to the wrong cluster.

We run several [Rancher](https://www.rancher.com/)-managed Kubernetes clusters, and every product reaches them through the same GitLab CI and Helm convention. In the first half of November we turned what we knew about working on them into a shared repository with two readers: a runbook for people, and a [Claude Code](https://code.claude.com/docs/en/overview) plugin with one skill for agents.

It follows on from the [post on where Claude Code know-how belongs](https://sawinyh.com/blog/claude-code-skills-vs-mcp-vs-claude-md/). That one ended on a limit: my skills sat in a gitignored directory and existed on one machine. A team skill has to solve that problem first, and then the more interesting one, which is what an agent should do when it holds your kubeconfig.

## The mistakes that kept repeating

Before the repository existed, what you needed to reach and inspect a cluster lived in per-project notes, many of them already marked stale. The design doc for the repository opened with a list of mistakes that recurred across products, and the runbook's failure page added more. Most of the skill's rules exist because of one of these.

| Mistake | What it looked like | What handles it now |
|---|---|---|
| Asking the wrong cluster | An empty result, read as "not deployed". The context named after production also hosts stage for several products. | Pick the context from the hostname, then confirm the namespace exists |
| Editing a values file no job deploys | A correct change that never shipped. In most repos a push to `main` deploys the stage leaf onto the live host, and no release tag has ever been cut. | Each product page states which CI rule deploys the live host |
| Treating a dead token as a missing permission | Hunting for a different credential or context. Personal Rancher keys expire within days, and the CI token can die too. | On `system:unauthenticated`, stop and report |
| Copying database passwords to a laptop | Secrets in a terminal, sometimes the wrong ones | Query from inside the service's own pod |
| Trusting a green job | A pipeline passed and the change was absent | Verify against the running pod, the database, the live API |

The fourth row has a detail I like. The runbook warns that the credentials in a database's own pod are not always the ones that work, and that the application pod talking to that database is the one to trust. A credential sitting in the obvious place can be the wrong one, and the manifests will not tell you.

## Why the skill holds no facts

The skill file opens by stating its own design: the facts live in the runbook beside the skill, and the skill holds only the rules. It tells the agent to read the pages it needs before acting and not to answer cluster questions from memory.

The runbook is a handful of pages, each named for when you need it: getting access, which cluster a host lives on, how a product reaches a cluster, inspecting what runs, rolling out, and a table of failure signatures. Then there is a page per product. Every product page has the same shape, so the agent can rely on it: repository, cluster and namespace for stage and prod, workloads, hosts, which CI rule deploys the live host and whether tags exist, data stores and which pod holds working credentials for each, and a link to the product's own deploy runbook.

I split it this way for two reasons. The first is staleness. A fact copied into a skill is a second copy, and the second copy is the one nobody updates, because nobody reads it except the model. A runbook page gets read by the person who is stuck at that moment, and a person notices when a page is wrong.

The second is that people and agents end up working from the same page. When an agent tells you which cluster a service is on, you can open the page it read and check. When a teammate fixes the page, the agent's next answer changes. Nothing has to be kept in sync because only one copy exists.

The packaging makes this work. The design doc first put the plugin in a subdirectory, with the runbook beside it at the repository root. Installing it that way would have cached the plugin without the runbook. We made the repository root the plugin instead, so the skill reaches the pages by a relative path and every install carries them.

The skill's description line is the one place where specifics do appear: it lists the kinds of work that should trigger it (kubectl, helm, a deployed pod or database, a CI deploy job, a release tag) and the host patterns our products live under. As the earlier post argued, the description decides whether a skill ever fires, so it is the one place where naming concrete things pays for itself.

## Eight rules, and the two that do the real work

Here are the rules, with our hostnames and names taken out.

1. **Pick the context from the hostname**, using the clusters page, then confirm with `kubectl --context <ctx> get ns`.
2. **Read-only by default.** Restarting, scaling, `set image`, deleting a pod, playing a CI deploy job, pushing a tag, writing to a database or patching a secret each need the user's explicit go-ahead for that specific action.
3. **Never print a credential.** Check a token by length or prefix only. Move it through the clipboard into the command that installs it, then clear the clipboard.
4. **Use a service's credentials from inside its pod.** Pipe a script into `kubectl exec -i` that reads the pod's own environment.
5. **Verify against the running system**: the pod's image and age, a row in the database, the live API.
6. **On `system:unauthenticated`, stop.** The token is dead. Report it with the renewal steps. Do not switch to another context or credential to get around it.
7. **On `forbidden`, stop.** Check with [`kubectl auth can-i`](https://kubernetes.io/docs/reference/kubectl/generated/kubectl_auth/kubectl_auth_can-i/) and report what the account lacks. Do not look for a different verb that achieves the same effect.
8. **Release tags ship to production.** Never push one to try something.

Most of these are what a careful engineer already does. Rules 6 and 7 are different, because they are aimed at a habit that makes agents useful everywhere else.

An agent that hits an error tries something else. In a codebase that is the job: a test fails, it reads the failure and changes the approach. On a cluster the same instinct turns dangerous. A refused `patch deployments` invites a `delete pod`, which restarts the workload just as well. A dead token for one context invites a working token for another, and the agent ends up running reads against a cluster nobody pointed it at. Each step looks like persistence, and taken together they amount to getting around access control.

So the rules treat `unauthenticated` and `forbidden` as the cluster's final answer. The useful output at that point is a precise report of what was refused, with the `can-i` result that proves it, handed to a person who can decide.

The pod rule deserves a line of its own. Running the query inside the service's pod, with the script on stdin, means no password crosses to the laptop, the terminal or the model's context. The runbook's inspecting page also has the agent list the pod's environment variable names with the values cut off before writing the query, so it learns which variables exist without ever seeing a secret.

## Isn't a hook the real guardrail?

This is the strongest objection, and I have made it myself. The [hooks post](https://sawinyh.com/blog/claude-code-hooks-enforce-not-advise/) argues that a rule in a prompt is a request, and only a hook is a guarantee. A skill is a prompt that loads on demand. Rule 2 is advice.

[@fluixoo](https://x.com/fluixoo/status/2112605625234358440) put the same case plainly on 2026-10-20: prompts are suggestions, and the one part of their setup they would never delete is a PreToolUse hook that exits with code 2 on `git push`, deploys, `terraform`, `kubectl` and a list of other commands. A few days earlier [they reported](https://x.com/fluixoo/status/2110642003637674167) testing a first version against hundreds of real commands and finding that `kubectl apply` and `terraform apply` walked straight through it. That is the right instinct and a fair warning about how leaky pattern matching is.

It does not fit this job. A hook that blocks `kubectl` blocks `kubectl logs`, `kubectl get` and `kubectl exec` into a pod to run a read-only query. Those reads are most of what the agent is there for. A hook fine-grained enough to allow `exec` for a `SELECT` and refuse it for an `UPDATE` would have to parse arbitrary scripts piped over stdin, and it would still be guessing.

The cluster does not have to guess. [Kubernetes RBAC](https://kubernetes.io/docs/reference/access-authn-authz/rbac/) already knows which verbs on which resources each account may use, and short-lived keys scoped to one cluster bound how long and where a key works. That is where enforcement lives for us. The skill's job is narrower: make the agent pick the right cluster, stay on reads until someone says otherwise, and stop when the cluster refuses instead of searching for a path around the refusal.

Where an account does hold write rights, in namespaces its owner administers, RBAC says yes, and the only thing between a suggestion and a restart is rule 2. Nothing in our setup changes that. In those namespaces the skill is advice and nothing more.

Here is the path the skill sets, with the stop branches drawn in, since they are the point.

<div style="display:flex;justify-content:center;margin:1.5em 0;"><pre style="background:#24292e;color:#e1e4e8;padding:0.9rem 1.2rem;border-radius:6px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:0.84em;line-height:1.45;margin:0;width:max-content;max-width:100%;white-space:pre;word-wrap:normal;box-sizing:border-box;overflow-x:auto;">  Task names a host or a product
        │
        ▼
  Read the product page: cluster,
  namespace, which CI job deploys
        │
        ▼
  kubectl --context &lt;ctx&gt; get ns
        │
  namespace there? ── no ──▶ wrong cluster:
        │                    re-read the host
       yes
        │
        ▼
  Read: logs, image, pod age,
  a query from inside the pod
        │
  needs a write? ── no ──▶ report what runs
        │
       yes
        │
        ▼
  Ask the user for this one action
        │
        ▼
  Cluster answers
        │
   ok ──┴── unauthenticated / forbidden
   │                  │
   ▼                  ▼
  verify the     STOP: no other context,
  live state     no other verb
                      │
                      ▼
                Draft an ops issue,
                file it only on "yes"
&nbsp;
  every refusal ends with a person,
  never with a second attempt</pre></div>

## Keeping a runbook true when an agent reads it

A runbook an agent trusts has to be right more often than a runbook people skim, because the agent will act on a stale line with full confidence. We added two things for that.

Every page opens with a `Verified:` line saying when it was last checked and how, down to the command that was run. A reader can tell at a glance whether a page describes this week or last quarter, and the agent can tell the user which check backs a claim.

Product pages and the clusters page also end with a `verify` block, a short list of facts in a fixed format: a context and a namespace, or a context, a namespace and a workload. A script in the repo reads every block and runs a read-only `kubectl get` for each line. It prints `ok`, `missing` or `unreachable`, the last meaning the person running it has no access to that cluster, and it exits non-zero on anything missing. It does not run in CI, since CI has no personal key. It runs before anyone changes a page.

The skill adds one rule on top. If what the agent observes contradicts a page, it trusts the observation, tells the user which page and line is stale, and offers to fix it. When an agent changes a product's infrastructure, a new namespace or a renamed workload, it updates that product's page in the same piece of work, re-runs the check, and leaves the commit and push to the person.

One more rule covers where the fix goes. The installed copy of the plugin lives under `~/.claude/plugins/` and is overwritten on every update. An agent that fixes a page there has fixed it for nobody. The skill says to edit a clone of the repository and never the installed copy.

## Escalation is a draft, never an action

Some problems cannot be fixed from a developer's laptop: a dead CI token, a missing grant, anything at the cluster level such as nodes, ingress, DNS or storage. When rule 6 or 7 stops the agent, or the fix needs rights the account does not have, the skill routes the problem to the team that runs the clusters, as an issue in their tracker.

The skill spells out how. Search for an open issue with the same error text first, and comment there if one exists. Write a body with the product, the goal, the cluster, namespace and workload, the exact error, each command run and what it returned, including the `can-i` output, and what is needed. Never include a token, password, kubeconfig or secret value. Show the user the title and body, and file only after they say yes. Then stop, and leave that part of the task until the team replies.

That ordering, draft first and file on approval, is what keeps the agent from becoming a source of noise in another team's queue.

## What stays in a personal skill

Not everything about the clusters belongs in the shared repository. What one person's account may do differs from a teammate's, and a description of my access is true for me and wrong for everyone else. So it lives in a personal skill on my machine, not in the team runbook.

That skill's main rule is about not trusting a grant you have not checked on the exact cluster. Access on one cluster says nothing about another, even when the projects and namespaces look the same. Before planning any write, run `can-i` on the exact context and namespace, and report the answer rather than an assumption. Never mint a one-time credential until `can-i` says the place it goes is writable, because a credential with nowhere to live has to be revoked.

The split is the same one the shared skill makes, one level down. Shared facts go in the shared runbook. Facts about one person go in that person's skill. Rules that hold for everyone go in the shared skill, and none of them name anyone.

## Shipping it as a plugin from a private repo

The install is two commands, run on the VPN with git access to our GitLab:

```sh
claude plugin marketplace add https://<our-gitlab>/<group>/infra-skills.git
claude plugin install cluster-infra@infra-skills
```

The repository carries a `.claude-plugin/marketplace.json` that lists one plugin whose source is the repository itself. The [plugin marketplace documentation](https://code.claude.com/docs/en/plugin-marketplaces) says such a repository can be private and that an administrator can require it on every machine. We tested the install in a throwaway Claude Code config directory, over HTTPS with the machine's existing git credentials, and confirmed the cached skill could reach the runbook pages by its relative path. Updates come through `claude plugin marketplace update`.

The design doc also lists what we did not check. Its acceptance test, which asks an agent with the plugin installed to inspect a product and expects it to load the right page, pick the right context and stay read-only, was not run during that first pass, because the throwaway config had no Claude login. Some `verify` lines report `unreachable` for anyone without a key to that cluster. Both gaps sit in the doc in plain words, the same way a `Verified:` line records how each page was checked.

Vendors are shipping cluster skills of their own now. [CoreWeave announced CoreWeave Skills](https://x.com/CoreWeave/status/2119897909336445151) on 2026-11-09, a skill set that lets Claude Code build a cluster on their service, add a GPU node pool and serve a model. That is a skill for operating someone's platform. Most of what a team needs for its own clusters has little to do with Kubernetes: which of your clusters a hostname means, which job actually ships, which pod holds the working password, and when to stop and hand the problem to a person.

## Frequently asked questions

### Can Claude Code run kubectl against a Kubernetes cluster?

Yes. Claude Code runs shell commands, so it can use kubectl and helm with whatever kube contexts and credentials exist on the machine. That is the reason to constrain it: it acts with exactly the rights of the key it finds. Our team skill instructs it to stay read-only by default, to confirm the context against the hostname before reading, and to ask for an explicit go-ahead before each write, such as a restart or a secret patch. Those are instructions, so the hard limits still come from RBAC and short-lived keys.

### Should a Kubernetes skill for Claude Code contain cluster details?

Ours deliberately does not. The skill holds rules and tells the agent which runbook page to read for a given task. Hostnames, namespaces, cluster mappings and deploy rules live in the runbook, which people read too. Facts copied into a skill go stale without anyone noticing, while a runbook page with a Verified line and a drift check can be kept true.

### Is a PreToolUse hook enough to make kubectl safe for an agent?

A hook can block a command pattern, but a blanket block on kubectl also blocks reading logs, checking an image or querying a database from a pod, which is most of what the agent is there to do. Telling a dangerous write apart from a safe one depends on the cluster's own permissions, so we leave enforcement to RBAC and short-lived keys, and use the skill to make the agent stop when the cluster says no.

### How do you share a Claude Code skill with a team privately?

Put it in a private git repository with a marketplace.json file, then each person runs claude plugin marketplace add with the repository URL and claude plugin install with the plugin name. The documentation says a marketplace repository can be private and an administrator can require it on every machine. We made the repository root the plugin, so the runbook pages travel with the skill when it installs.


---

Source: Nick Sawinyh, https://sawinyh.com/blog/claude-code-kubernetes-team-skill/
Nick Sawinyh writes on AI, engineering, product, and crypto business development at sawinyh.com.
Site index for agents: https://sawinyh.com/llms.txt
