Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Kubectl

BSecurity

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\", \"de...

4 stars
0 votes
0 copies
0 views
Added 9/24/2026
devopsgobashnodekubernetesdebugging

Works with

cli

Security Analysis

B88/100
criticalAccesses sensitive system or user directories

Pro scans all 8 files and shows the line behind each finding

Scanned 9/24/2026

$npx -y skills add chrishuffman5/domain-expert --skill kubectl --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Kubectl?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Kubectl
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/chrishuffman5-kubectl/badge)](https://www.skillsdirectory.com/skills/chrishuffman5-kubectl)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: kubectl
description: "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."
license: MIT
---

# kubectl Expert

This skill covers kubectl, the Kubernetes command-line tool. It has deep coverage of:

- Configuration (kubeconfig, contexts, namespaces, multiple clusters, auth)
- Output formats (default, wide, yaml, json, jsonpath, custom-columns, go-template)
- All major verbs (get, describe, create, apply, delete, edit, patch, exec, logs, port-forward, cp, top, explain, diff, rollout, scale, autoscale, drain, cordon, taint)
- Workload resources (pods, deployments, replicasets, statefulsets, daemonsets, jobs, cronjobs)
- Configuration and storage (configmaps, secrets, PVCs, PVs, storage classes)
- Networking (services, ingress, network policies, endpoints, DNS debugging)
- RBAC (roles, rolebindings, clusterroles, clusterrolebindings, service accounts, auth can-i)
- Node management (labels, taints, cordon, drain, top)
- Debugging (pod states, CrashLoopBackOff, ImagePullBackOff, OOMKilled, ephemeral containers, events)
- Scripting patterns (dry-run, diff, wait, jq integration, batch operations, kustomize)

## How to Approach Tasks

When you receive a request:

1. **Classify** the request type:
   - **Configuration/context** -- Load `references/core.md`
   - **Resource management** -- Load `references/commands.md`
   - **Debugging/troubleshooting** -- Load `references/debugging.md`
   - **Scripting/automation** -- Load `references/patterns.md`

2. **Identify scope** -- Determine namespace. Remind user to check `kubectl config current-context` and default namespace.

3. **Prefer declarative** -- Use `kubectl apply -f` over imperative commands for production workloads. Use imperative for quick debugging.

4. **Use dry-run for safety** -- Preview changes with `--dry-run=client -o yaml` before applying.

5. **Provide complete commands** -- Include namespace flags (`-n`) when relevant.

## Core Expertise

### Configuration

```bash
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
```

### Output Formats

```bash
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}}'
```

### Common Operations

```bash
# 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
```

### Debugging

```bash
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
```

## Common Pitfalls

**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`.

## Reference Files

- `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

- `scripts/01-cluster-health.sh` -- Cluster overview: nodes, pod summary, resource usage, events
- `scripts/02-app-debug.sh` -- Application debugging: deployment, pods, logs, connectivity
- `scripts/03-namespace-report.sh` -- Per-namespace resource report with issue detection

Attribution

chrishuffman5chrishuffman5
View sourceSee grades on GitHubMore from chrishuffman5 →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Terraform Module Library

Build reusable Terraform modules for AWS, Azure, and GCP infrastructure following infrastructure-as-code best practices. Use when creating infrastructure modules, standardizing cloud provisioning, or implementing reusable IaC components.

401991 votes

sematext-otel

Wire a service's OpenTelemetry output to Sematext Cloud. Walks through region, App-type, instrumentation flow (managed OTLP endpoint vs Sematext Agent), and signal selection (traces/metrics/logs), then produces the exact env-var block and points at a runnable reference example in this repo. Invoke when instrumenting a new app for Sematext.

01 votes

Deployment Patterns

Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications. Use when setting up deployment infrastructure or planning releases.

2699140 votes

Babysit

Watch a pull request or review cycle until it is ready to merge. Use when asked to babysit, monitor, or keep checking PR comments, reviews, and CI until all actionable issues are resolved.

971540 votes

V7 Roster

Interact with the Paperclip control plane API for task coordination and governance. Use when checking assignments, updating issue status, posting comments, delegating work, managing routines, or calling Paperclip API endpoints.

953190 votes
View all in devops →