kubectx and kubens for Kubernetes context/namespace switching. Use for switching contexts/namespaces, fzf selection, shell completions, kube-ps1 prompts, KUBECONFIG management, or troubleshooting.
Ships in kubectx. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
CLI tools by ahmetb for fast Kubernetes context and namespace switching. Written in Go, single binaries. Both support fzf for interactive fuzzy selection.
# Homebrew (macOS/Linux)
brew install kubectx
# Arch
pacman -S kubectx
# Manual binary
curl -Lo kubectx https://github.com/ahmetb/kubectx/releases/latest/download/kubectx
curl -Lo kubens https://github.com/ahmetb/kubectx/releases/latest/download/kubens
chmod +x kubectx kubens && mv kubectx kubens /usr/local/bin/
# With fzf (enables interactive mode automatically)
brew install fzf
kubectx # List all contexts (current highlighted)
kubectx <name> # Switch to context
kubectx - # Switch to previous context (toggle)
kubectx -c # Show current context name
kubectx <new>=<old> # Rename context
kubectx -d <name> # Delete context
kubectx -d <name1> <name2> # Delete multiple contexts
kubectx -u # Unset current context
With fzf installed, bare kubectx opens interactive fuzzy finder instead of listing.
kubens # List all namespaces (current highlighted)
kubens <name> # Switch to namespace
kubens - # Switch to previous namespace (toggle)
kubens -c # Show current namespace
With fzf installed, bare kubens opens interactive fuzzy finder instead of listing.
~/.kube/config (or file(s) in $KUBECONFIG)kubectl config use-context <name>kubectl config set-context --current --namespace=<name>- toggle stores previous selection in ~/.kube/kubectx and ~/.kube/kubens# Merge multiple kubeconfig files
export KUBECONFIG=~/.kube/config:~/.kube/cluster-a:~/.kube/cluster-b
# kubectx sees all contexts across all files
kubectx # lists contexts from all kubeconfig files
When KUBECONFIG contains multiple files, kubectx operates across all of them. Changes are written to the first file in the list that contains the modified context.
kubectx production && kubens monitoring
# Force non-interactive even with fzf installed
KUBECTX_IGNORE_FZF=1 kubectx my-cluster
KUBECTX_IGNORE_FZF=1 kubens kube-system
# Use in scripts
current=$(kubectx -c)
kubectx staging
# ... do work ...
kubectx "$current" # restore
# Rename long auto-generated names to short memorable ones
kubectx prod=arn:aws:eks:us-east-1:123456:cluster/production
kubectx staging=gke_myproject_us-central1_staging
kubectx homelab=kubernetes-admin@homelab
| File | Content |
|---|---|
references/shell-integration.md | zsh/bash completions, kube-ps1 prompt, fzf config, zinit setup |
k3s skill for cluster setup, then kubectx to manage contextszinit-zsh skill for plugin installation in this dotfiles repoWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/kubectx:kubectxfrom kubectx
npx claudepluginhub kettleofketchup/kettleofskills --plugin kubectx