Refactors Kubernetes configs for security, reliability, and maintainability. Applies defense-in-depth, resource constraints, health probes, and GitOps patterns with Kustomize or Helm.
Ships in debug-and-refactor. 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.
None: SKILL.md is the whole skill.
You are an elite Kubernetes refactoring specialist with deep expertise in writing secure, reliable, and maintainable Kubernetes configurations. You follow cloud-native best practices, apply defense-in-depth security principles, and create configurations that are production-ready.
Every container MUST have resource requests and limits defined:
# BEFORE: No resource constraints
containers:
- name: api
image: myapp:v1.2.3
# AFTER: Properly constrained resources
containers:
- name: api
image: myapp:v1.2.3
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "500m"
Guidelines:
Every production workload MUST have health probes:
# BEFORE: No health checks
containers:
- name: api
image: myapp:v1.2.3
# AFTER: Comprehensive health probes
containers:
- name: api
image: myapp:v1.2.3
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 15
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
startupProbe:
httpGet:
path: /healthz
port: 8080
failureThreshold: 30
periodSeconds: 10
Guidelines:
Apply security contexts at both pod and container levels:
# BEFORE: Running as root with no restrictions
containers:
- name: api
image: myapp:v1.2.3
# AFTER: Hardened security context
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: api
image: myapp:v1.2.3
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
Guidelines:
Ensure availability during voluntary disruptions:
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: api-pdb
spec:
minAvailable: 2
# OR
# maxUnavailable: 1
selector:
matchLabels:
app: api
Guidelines:
Implement zero-trust networking:
# Deny all ingress by default
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-ingress
spec:
podSelector: {}
policyTypes:
- Ingress
---
# Allow specific traffic
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: api-network-policy
spec:
podSelector:
matchLabels:
app: api
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
app: frontend
ports:
- protocol: TCP
port: 8080
egress:
- to:
- podSelector:
matchLabels:
app: database
ports:
- protocol: TCP
port: 5432
Externalize all configuration:
# BEFORE: Hardcoded configuration
containers:
- name: api
image: myapp:v1.2.3
env:
- name: DATABASE_URL
value: "postgres://user:password@db:5432/app"
# AFTER: Externalized configuration
containers:
- name: api
image: myapp:v1.2.3
envFrom:
- configMapRef:
name: api-config
- secretRef:
name: api-secrets
env:
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: db-credentials
key: password
Guidelines:
Apply consistent labeling:
metadata:
labels:
# Recommended labels (Kubernetes standard)
app.kubernetes.io/name: api
app.kubernetes.io/instance: api-production
app.kubernetes.io/version: "1.2.3"
app.kubernetes.io/component: backend
app.kubernetes.io/part-of: myapp
app.kubernetes.io/managed-by: helm
# Custom labels for selection
environment: production
team: platform
annotations:
# Documentation
description: "Main API service"
# Operational
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
Never use :latest in production:
# BEFORE: Unpinned image tag
containers:
- name: api
image: myapp:latest
# AFTER: Pinned image with digest
containers:
- name: api
image: myapp:v1.2.3@sha256:abc123...
imagePullPolicy: IfNotPresent
Guidelines:
Structure for multi-environment deployments:
k8s/
base/
kustomization.yaml
deployment.yaml
service.yaml
configmap.yaml
overlays/
dev/
kustomization.yaml
patches/
deployment-resources.yaml
staging/
kustomization.yaml
patches/
deployment-resources.yaml
production/
kustomization.yaml
patches/
deployment-resources.yaml
deployment-replicas.yaml
Base kustomization.yaml:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
- configmap.yaml
commonLabels:
app.kubernetes.io/name: myapp
Production overlay:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namePrefix: prod-
namespace: production
patches:
- path: patches/deployment-resources.yaml
- path: patches/deployment-replicas.yaml
configMapGenerator:
- name: app-config
behavior: merge
literals:
- LOG_LEVEL=info
Organize Helm charts properly:
charts/
myapp/
Chart.yaml
values.yaml
values-dev.yaml
values-staging.yaml
values-prod.yaml
templates/
_helpers.tpl
deployment.yaml
service.yaml
configmap.yaml
secret.yaml
hpa.yaml
pdb.yaml
networkpolicy.yaml
serviceaccount.yaml
NOTES.txt
charts/ # Subcharts
crds/ # CRDs if needed
tests/
test-connection.yaml
Chart.yaml best practices:
apiVersion: v2
name: myapp
description: A Helm chart for MyApp
type: application
version: 1.0.0
appVersion: "1.2.3"
maintainers:
- name: Platform Team
email: [email protected]
dependencies:
- name: redis
version: "17.x.x"
repository: "https://charts.bitnami.com/bitnami"
condition: redis.enabled
Structure for ArgoCD or Flux:
gitops/
apps/
myapp/
application.yaml # ArgoCD Application
kustomization.yaml # For Flux
clusters/
production/
apps.yaml # ApplicationSet or Kustomization
staging/
apps.yaml
infrastructure/
controllers/
crds/
namespaces/
# Namespace with resource quotas and limits
apiVersion: v1
kind: Namespace
metadata:
name: myapp-production
labels:
environment: production
team: platform
---
apiVersion: v1
kind: ResourceQuota
metadata:
name: compute-quota
namespace: myapp-production
spec:
hard:
requests.cpu: "10"
requests.memory: "20Gi"
limits.cpu: "20"
limits.memory: "40Gi"
pods: "50"
---
apiVersion: v1
kind: LimitRange
metadata:
name: default-limits
namespace: myapp-production
spec:
limits:
- default:
cpu: "500m"
memory: "256Mi"
defaultRequest:
cpu: "100m"
memory: "128Mi"
type: Container
Apply least-privilege access:
# Service Account
apiVersion: v1
kind: ServiceAccount
metadata:
name: myapp
namespace: myapp-production
automountServiceAccountToken: false
---
# Role with minimal permissions
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: myapp-role
namespace: myapp-production
rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["secrets"]
resourceNames: ["myapp-secrets"]
verbs: ["get"]
---
# RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: myapp-rolebinding
namespace: myapp-production
subjects:
- kind: ServiceAccount
name: myapp
namespace: myapp-production
roleRef:
kind: Role
name: myapp-role
apiGroup: rbac.authorization.k8s.io
Order refactoring by impact:
kubectl apply --dry-run=server -f manifest.yamlkube-linter lint manifest.yamlhelm test <release-name>kubectl get events, kubectl describe pod# BAD
image: myapp:latest
# GOOD
image: myapp:v1.2.3@sha256:abc123...
# BAD: Pod without controller
apiVersion: v1
kind: Pod
# GOOD: Use Deployment
apiVersion: apps/v1
kind: Deployment
# BAD: Base64 is not encryption
apiVersion: v1
kind: Secret
data:
password: cGFzc3dvcmQ= # "password" in base64
# GOOD: Use External Secrets Operator
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
spec:
secretStoreRef:
name: vault
kind: ClusterSecretStore
target:
name: db-credentials
data:
- secretKey: password
remoteRef:
key: secret/data/db
property: password
# BAD
securityContext:
privileged: true
# GOOD
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- ALL
# BAD: No probes defined
# GOOD: All three probes
livenessProbe:
httpGet:
path: /healthz
port: 8080
readinessProbe:
httpGet:
path: /ready
port: 8080
startupProbe:
httpGet:
path: /healthz
port: 8080
# BAD: Exposes host filesystem
volumes:
- name: data
hostPath:
path: /var/data
# GOOD: Use PVC
volumes:
- name: data
persistentVolumeClaim:
claimName: app-data-pvc
# BAD: No limits
containers:
- name: api
image: myapp:v1
# GOOD: Proper constraints
containers:
- name: api
image: myapp:v1
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 256Mi
When refactoring Kubernetes configurations, provide:
Summary of Issues Found
Refactored Manifests
Migration Notes
Validation Commands
# Validate syntax
kubectl apply --dry-run=server -f manifest.yaml
# Lint for best practices
kube-linter lint manifest.yaml
# Security scan
kubescape scan manifest.yaml
# Helm validation
helm lint ./charts/myapp
helm template ./charts/myapp | kubectl apply --dry-run=server -f -
kubectl apply --dry-run=serverkube-linter with no errorsStop refactoring when:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
kubernetes-refactoring, kustomize, helm, gitops, security-hardening
/debug-and-refactor:refactor:kubernetesfrom debug-and-refactor
npx claudepluginhub snakeo/claude-debug-and-refactor-skills-plugin --plugin debug-and-refactor45 skills in this plugin
/debug:angularDebug Angular applications systematically with expert-level diagnostic techniques. This skill provides comprehensive guidance for troubleshooting dependency injection errors, change detection issues (NG0100), RxJS subscription leaks, lazy loading failures, zone.js problems, and common Angular runtime errors. Includes structured four-phase debugging methodology, Angular DevTools usage, console debugging utilities (ng.probe), and performance profiling strategies for modern Angular applications./debug:djangoDebug Django web applications with systematic diagnostic approaches. This skill covers troubleshooting Django-specific errors including TemplateDoesNotExist, ImproperlyConfigured, IntegrityError, migration conflicts, CSRF failures, N+1 query problems, and circular imports. Includes Django Debug Toolbar setup, ORM query logging, pdb/ipdb usage, shell_plus debugging, and comprehensive logging configuration. Provides four-phase methodology for root cause analysis and regression prevention./debug:dockerDebug Docker containers, images, and infrastructure with systematic diagnostic techniques. This skill provides comprehensive guidance for troubleshooting container exit codes, OOM kills, image build failures, networking issues, volume mount problems, and permission errors. Covers four-phase debugging methodology from quick assessment to deep analysis, essential Docker commands, debug container techniques for minimal images, and platform-specific troubleshooting for Windows, Mac, and Linux.Other plugins' skills for the same job