Explore the connected Kubernetes cluster and build a durable, reusable map — a short navigation map merged into AGENTS.md plus one skill per namespace. Use when asked to map, document, or build memory of the cluster.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Build Cluster Map?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/freelensapp-build-cluster-map-freelens-agentbridge-extension)
---
name: build-cluster-map
description: Explore the connected Kubernetes cluster and build a durable, reusable map — a short navigation map merged into AGENTS.md plus one skill per namespace. Use when asked to map, document, or build memory of the cluster.
---
# Build Cluster Map
Explore the Kubernetes cluster reachable through the inherited `KUBECONFIG` and
persist a durable map so future conversations do not have to re-explore it.
This skill is **idempotent**: on the first run it builds the map; on later runs
it **merges/refreshes** what already exists instead of duplicating it.
## Absolute rules
- **Read-only.** Use only read verbs (`get`, `describe`, `explain`, `top`,
`api-resources`, `version`, `helm get/status/list/history/show`). Never create,
apply, edit, delete, scale, patch, exec, port-forward, or restart anything.
- Always pass an explicit `-n <namespace>` for namespaced reads.
- **Never** read or record Secret *values*. Record only Secret *names* and *keys*.
- Keep everything concise. The map is meant to be cheap to load every session.
## Scope
- If the user names a single namespace, refresh only that namespace — regenerate
its `ns-map-<namespace>` skill and update just its entries in the navigation
map and the cluster-level skill. Otherwise map the whole cluster.
## Steps
1. **Identify the cluster.**
- `kubectl config current-context` for the context/cluster name (use it,
sanitized to lowercase kebab-case, as `<cluster>`).
- `kubectl version` for server version; infer the distribution when obvious
(EKS/GKE/AKS/k3s/OpenShift/kubeadm) from nodes and version metadata.
- `kubectl get nodes -o wide` for node count, roles, and kernel/runtime.
- `kubectl get ns` for the namespace inventory. Skip system namespaces
(`kube-system`, `kube-public`, `kube-node-lease`) unless the user asked for
a specific one.
2. **Explore namespaces in parallel.**
- Delegate **one subagent per namespace**, running **at most 5 in parallel**
(queue the rest). Use the read-heavy `explorer` agent. Each subagent is
read-only and pinned to its namespace.
- Each subagent produces a concise inventory: workloads
(Deployments/StatefulSets/DaemonSets/Jobs/CronJobs) with replica health;
Pods summary (restarts, notable statuses, images); Services + Ingresses /
Gateways with hostnames; ConfigMap & Secret **names and keys only, never
values**; PVCs / StorageClasses; RBAC (ServiceAccounts/Roles/RoleBindings);
NetworkPolicies; recent **Warning** Events grouped; `kubectl top` if metrics
are available; and a short "health & risks" note.
3. **Write one skill per namespace.**
- Path: `.agents/skills/ns-map-<namespace>/SKILL.md`.
- Front matter:
```yaml
---
name: ns-map-<namespace>
description: Map of the <namespace> namespace in <cluster> — workloads, services, config, storage, RBAC, risks. Use when working in this namespace.
---
```
- Body: the concise inventory from step 2. Overwrite/merge on re-run so it
stays fresh.
4. **Write one cluster-level skill.**
- Path: `.agents/skills/cluster-map-<cluster>/SKILL.md`.
- Cluster-wide detail only — nodes, versions/distribution, CRDs, ingress
controllers, StorageClasses, cross-namespace relationships, cluster-scoped
RBAC. **Do not** duplicate the short navigation map below.
5. **Merge the short navigation map into the instructions file** (`AGENTS.md`).
- Replace (or insert) the block delimited exactly by:
```markdown
<!-- BEGIN AGENTBRIDGE CLUSTER MAP -->
<!-- END AGENTBRIDGE CLUSTER MAP -->
```
- Keep it **short** — it is a quick navigator, not a report. It must let you
answer "which namespace owns X?" without exploring. Include:
- one line: `<cluster>` — server version, distribution, node count;
- a compact index mapping notable resources → namespace, e.g.
`service1, deploy/api, ingress host app.example.com → namespace1`.
- Do **not** list or point to the skills here (they load automatically).
- When refreshing a single namespace, update only that namespace's lines
inside the block and leave the rest untouched.
6. **Report** a one-paragraph summary of what was mapped (namespace count, skills
written/updated) and remind the user the map refreshes by mentioning
`$build-cluster-map` again, optionally naming a single namespace.
## A note on writes
Codex keeps `.agents/` read-only inside a writable workspace, so each skill file
written in steps 3 and 4 asks for approval before it lands. Approve them, or add
this workspace's `.agents` directory to `writable_roots` in `.codex/config.toml`
first — the editable settings file says how.