plugins/cli-scripting/skills/kubectl/SKILL.md
kubectl command-line usage and scripting: kubeconfig and context management, output formats (jsonpath, custom-columns, go-template), all major verbs (get, describe, apply, delete, exec, logs, port-forward, rollout, scale, drain), workload resources, config/storage, networking, RBAC, node management, debugging (CrashLoopBackOff, ImagePullBackOff, OOMKilled), and scripting patterns (dry-run, diff, wait, jq, kustomize). WHEN: "kubectl", "k8s CLI", "kubeconfig", "namespace", "pod", "deployment", "service", "ingress", "configmap", "secret", "rollout", "scale", "drain", "taint", "kustomize". Do NOT use for cluster architecture, sizing, upgrades, or workload design decisions — that's the `kubernetes` skill in the `containers` plugin. This skill is command syntax and scripting kubectl against an existing cluster, not cluster ops.
npx skillsauth add chrishuffman5/domain-expert kubectlInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill covers kubectl, the Kubernetes command-line tool. It has deep coverage of:
When you receive a request:
Classify the request type:
references/core.mdreferences/commands.mdreferences/debugging.mdreferences/patterns.mdIdentify scope -- Determine namespace. Remind user to check kubectl config current-context and default namespace.
Prefer declarative -- Use kubectl apply -f over imperative commands for production workloads. Use imperative for quick debugging.
Use dry-run for safety -- Preview changes with --dry-run=client -o yaml before applying.
Provide complete commands -- Include namespace flags (-n) when relevant.
kubectl config get-contexts # list contexts
kubectl config current-context # show current
kubectl config use-context my-cluster # switch context
kubectl config set-context --current --namespace=myapp # set default ns
# Multiple clusters
KUBECONFIG=~/.kube/config:~/.kube/other kubectl config view --merge --flatten > ~/.kube/merged
kubectl get pods -o wide # extra columns
kubectl get pods -o yaml # full YAML
kubectl get pods -o json # full JSON
kubectl get pods -o name # resource names only
# JSONPath
kubectl get pods -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.phase}{"\n"}{end}'
kubectl get pod my-pod -o jsonpath='{.spec.nodeName}'
kubectl get secret my-secret -o jsonpath='{.data.password}' | base64 --decode
# Custom columns
kubectl get pods -o custom-columns='NAME:.metadata.name,STATUS:.status.phase,NODE:.spec.nodeName'
# Go template
kubectl get pods -o go-template='{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'
# Pods
kubectl run nginx --image=nginx:1.25 --port=80
kubectl run -it --rm debug --image=busybox --restart=Never -- /bin/sh
kubectl get pods -A -o wide
kubectl describe pod my-pod
kubectl logs my-pod -f --tail=100
kubectl logs my-pod --previous
kubectl exec -it my-pod -- /bin/bash
kubectl delete pod my-pod
# Deployments
kubectl create deployment nginx --image=nginx:1.25 --replicas=3
kubectl set image deployment/my-app my-app=myapp:v2
kubectl rollout status deployment/my-app
kubectl rollout undo deployment/my-app
kubectl rollout restart deployment/my-app
kubectl scale deployment my-app --replicas=5
# Services
kubectl expose deployment my-app --port=80 --target-port=8080 --type=ClusterIP
kubectl port-forward service/my-app 8080:80
kubectl describe pod my-pod # events + state
kubectl logs my-pod --previous # crashed container
kubectl get pod my-pod -o jsonpath='{.status.containerStatuses[0].lastState}'
kubectl debug my-pod -it --image=busybox --target=app # ephemeral container
kubectl get events --sort-by=.lastTimestamp # recent events
kubectl get events --field-selector=type=Warning # warnings only
1. Applying without checking diff
Always run kubectl diff -f manifest.yaml before kubectl apply in production.
2. Not using --previous for crashed container logs
When a container CrashLoopBackOff, kubectl logs shows current (empty) output. Use --previous.
3. Forgetting -n namespace flag
Without -n, commands target the default namespace. Set a default with set-context --current --namespace=X.
4. Using kubectl delete instead of declarative removal
Use kubectl delete -f manifest.yaml to match the apply workflow.
5. Draining nodes without --ignore-daemonsets
DaemonSet pods cannot be evicted. Always pass --ignore-daemonsets to kubectl drain.
6. Exit code 137 misidentified Exit code 137 = OOMKilled (128 + SIGKILL 9). Increase memory limits, do not look for application bugs.
7. Not checking endpoints after service creation
If kubectl get endpoints my-svc shows no endpoints, the service selector does not match any pod labels.
8. Ignoring resource requests/limits Pods without requests are best-effort and will be evicted first under memory pressure. Always set requests.
9. Using kubectl create in production
create fails if the resource exists. Use apply for idempotent operations.
10. Not using --field-selector for events
kubectl get events returns all events. Filter with --field-selector=involvedObject.name=my-pod.
references/core.md -- kubeconfig, contexts, namespaces, output formats (jsonpath, custom-columns, go-template), core verbs. Read for configuration and output questions.references/commands.md -- Complete command reference: workloads, config/storage, networking, RBAC, node management. Read for specific resource commands.references/debugging.md -- Pod debugging, ImagePullBackOff/CrashLoopBackOff/OOMKilled diagnosis, network debugging, events, explain. Read when troubleshooting.references/patterns.md -- Scripting: dry-run, diff, wait, jq integration, batch operations, kustomize, multi-container patterns. Read for automation scripts.scripts/01-cluster-health.sh -- Cluster overview: nodes, pod summary, resource usage, eventsscripts/02-app-debug.sh -- Application debugging: deployment, pods, logs, connectivityscripts/03-namespace-report.sh -- Per-namespace resource report with issue detectiontools
Bash 5.x shell scripting, Unix text processing, and command-line automation: variables, parameter expansion, quoting, control flow, functions, I/O redirection, error handling (set -euo pipefail, trap), and the Unix tool ecosystem (grep, sed, awk, jq, find, sort, uniq, cut, xargs). Covers process management, networking (curl, ssh, rsync, nc), file locking (flock), parallel execution, and production script patterns. WHEN: "Bash", "bash", "shell", "sh", ".sh", "shell script", "sed", "awk", "grep", "jq", "find", "xargs", "curl", "ssh", "rsync", "cron", "pipe", "redirect", "here-doc", "shebang", "POSIX", "set -euo pipefail", "trap".
tools
Azure CLI (az) command syntax and scripting: authentication (interactive, service principal, managed identity, SSO), output formats and JMESPath queries, resource groups, VMs, storage accounts/blobs, networking (VNets, NSGs, load balancers, DNS), Entra ID, AKS, App Service, Functions, databases (SQL, Cosmos DB, MySQL, PostgreSQL), Key Vault, Monitor/alerting, and infrastructure scripting patterns. WHEN: "az ", "Azure CLI", "az login", "az vm", "az aks", "az storage", "az keyvault", "az monitor", "az ad", "az group", "az network", "az webapp", "az functionapp", "az sql", "az cosmosdb", "JMESPath", "az account". Do NOT use for Azure architecture, landing zones, or multi-subscription strategy — that's the `cloud-platforms` plugin. This skill is about command syntax and scripting the CLI, not deciding what to provision.
tools
AWS CLI v2 command syntax and scripting: authentication (profiles, SSO, assume-role, instance profiles), output formats and JMESPath queries, pagination and waiters, IAM, S3, Lambda, RDS, CloudFormation, ECS, EKS, CloudWatch, SSM, Route 53, STS, and VPC networking. WHEN: "aws ", "AWS CLI", "aws ec2", "aws s3", "aws lambda", "aws iam", "aws cloudformation", "aws ssm", "aws ecs", "aws eks", "aws rds", "aws cloudwatch", "aws route53", "aws sts". Do NOT use for AWS architecture, service selection, multi-account strategy, or FinOps — that's the `cloud-platforms` plugin. This skill is about command syntax and scripting the CLI, not deciding what to provision.
development
Expert skill for Spring Boot across all supported versions (3.x and 4.0). Provides deep expertise in IoC/DI, auto-configuration, Spring MVC, WebFlux, Spring Data, Spring Security, Actuator, configuration management, testing, and embedded servers. WHEN: "Spring Boot", "Spring MVC", "WebFlux", "Spring Data", "Spring Security", "auto-configuration", "@SpringBootApplication", "Actuator", "Spring JPA", "Spring REST", "DispatcherServlet", "@RestController", "@ConfigurationProperties", "Spring profiles", "Spring testing".