Skip to main content
statuslinesSource-backedReview first Safety Privacy

kubectl Deployment Context Statusline

Claude Code statusline that shows the active kubectl context and namespace with a deployment-environment risk label.

by MkDev11·added 2026-06-04·
Claude Code
HarnessClaude Code
Language:bash
Review first review before installing

Open the source and read safety notes before installing.

Safety notes

  • The script is read-only and does not contact workloads, apply manifests, or change namespaces.
  • Risk labels are based on names; confirm the actual cluster and namespace before deployment commands.
  • Avoid running write-capable automation solely because the statusline says an environment looks like development.

Privacy notes

  • Context and namespace names can expose customer, region, cluster, or service names in screenshots.
  • kubectl reads local kubeconfig, which may reference private clusters and identities.
  • The script does not print server URLs or certificates.

Prerequisites

  • kubectl installed and configured for the environments you want visible.
  • A kubeconfig context selected before Claude Code starts or before the statusline refreshes.
  • Team naming conventions that distinguish production, staging, and development contexts.

Schema details

Install type
config
Troubleshooting
No
Runtime and command metadata
Script language
bash
Script body
#!/usr/bin/env bash
set -u

main() {
if ! command -v kubectl >/dev/null 2>&1; then
  echo "deploy: kubectl missing"
  exit 0
fi

context=$(kubectl config current-context 2>/dev/null || true)
if [ -z "$context" ]; then
  echo "deploy: no context"
  exit 0
fi

namespace=$(kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null || true)
if [ -z "$namespace" ]; then
  namespace="default"
fi

combined=$(printf '%s %s' "$context" "$namespace" | tr '[:upper:]' '[:lower:]')
if printf '%s' "$combined" | grep -Eq 'prod|production|live'; then
  risk="high"
elif printf '%s' "$combined" | grep -Eq 'stage|staging|preprod'; then
  risk="watch"
else
  risk="dev"
fi

printf 'deploy: %s | ns %s | %s\n' "$context" "$namespace" "$risk"
}

case $- in
  *n*) ;;
  *) main "$@" ;;
esac
Full copyable content
{
  "statusLine": {
    "type": "command",
    "command": "$CLAUDE_PROJECT_DIR/.claude/statuslines/kubectl-deployment-context-statusline.sh"
  }
}

About this resource

Source notes

  • Kubernetes kubectl documentation covers kubectl config current-context and config inspection commands.
  • This statusline keeps the output to context, namespace, and a name-based risk label so environment awareness is visible without issuing deployment actions.

Duplicate check

Checked existing statuslines, live HeyClaude statuslines, open pull requests, and repository content for kubectl-deployment-context-statusline, deployment environment, kubectl context, namespace warning, and production context statuslines. Existing Kubernetes content appears in MCP and hook categories, but no statusline entry or open PR covers deployment context.

Disclosure

Editorial statusline recipe. No paid placement or affiliate link is used.

#kubernetes#deployment#environment#claude-code

Source citations

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.