kubectx
$ kubectx Community Med Riskkubectx (paired with kubens) switches the active cluster context or namespace in ~/.kube/config in one short command (kubectx <ctx>, kubectx -). For multi-agent or parallel shells, prefer passing kubectl --context <ctx> instead of mutating shared global kubeconfig state.
brew install kubectx kubectx edits the local ~/.kube/config file; context switching is purely local workstation state.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Deterministic line-based output (kubectx -c, KUBECTX_IGNORE_FZF=1), though it has no JSON output and bare kubectx opens interactive fzf if fzf is installed.
- Bare
kubectxinvokesfzfinteractively unlessKUBECTX_IGNORE_FZF=1is set - Plain newline-delimited output; no
--jsonflag
Only modifies local ~/.kube/config context/namespace pointers, though silently switching global current-context can cause parallel shells to target the wrong cluster.
- Mutates global
~/.kube/configstate across all shells sharingKUBECONFIG
Available as Go binaries or shell scripts via Homebrew, Krew, and GitHub releases across macOS, Linux, and Windows.
- Available via
brew install kubectxandkubectl krew
Convenient shorthand for human operators, though agents are generally safer using kubectl --context per command.
- Quick
-cinspection and-context toggling
Well-known open-source tool (ahmetb/kubectx) under Apache-2.0.
- Apache-2.0
ahmetb/kubectxrepository
Concise README documenting flags (-c, -d, -) and KUBECTX_IGNORE_FZF.
- Clear README and
--helpoutput
Security, Auth & Guardrails
Reads and updates current-context directly in ~/.kube/config (or $KUBECONFIG).
Apache-2.0 open-source CLI; free to use.
# kubectx Agent Rules - Always set `KUBECTX_IGNORE_FZF=1` when listing contexts. - Prefer `kubectl --context <ctx> -n <ns>` over running `kubectx <ctx>` so you do not silently alter the user's or parallel agents' global kubeconfig context.
Agent-Ready Command Recipes
Safe Read-Only Queries
fzf KUBECTX_IGNORE_FZF=1 kubectx
Lists all contexts one per line without launching an interactive fzf picker.
kubectx -c
Outputs only the current kubeconfig context name.
Controlled Writes & Previews
kubectx staging-cluster
Updates current-context in ~/.kube/config to staging-cluster.
Strengths for Agents
- +
kubectx -candKUBECTX_IGNORE_FZF=1 kubectxcleanly inspect kubeconfig contexts. - + Lightweight single-purpose tool with zero cluster API calls.
- + Cross-platform Go binary implementation alongside shell scripts.
Caveats & Pitfalls
- ! If
fzfis onPATH, running barekubectxwithoutKUBECTX_IGNORE_FZF=1enters an interactive picker. - ! Mutating global
~/.kube/configcurrent-contextcan surprise concurrent terminals or agents.