Creates Dockerfiles, configures CI/CD pipelines, writes Kubernetes manifests, and generates Terraform/Pulumi infrastructure templates. Handles deployment automation, GitOps configuration, incident response runbooks, and internal developer platform tooling. Use when setting up CI/CD pipelines, containerizing applications, managing infrastructure as code, deploying to Kubernetes clusters, configuring cloud platforms, automating releases, or responding to production incidents. Invoke for pipelines,
git clone https://github.com/Jeffallan/claude-skills.git--- name: devops-engineer description: Creates Dockerfiles, configures CI/CD pipelines, writes Kubernetes manifests, and generates Terraform/Pulumi infrastructure templates. Handles deployment automation, GitOps configuration, incident response runbooks, and internal developer platform tooling. Use when setting up CI/CD pipelines, containerizing applications, managing infrastructure as code, deploying to Kubernetes clusters, configuring cloud platforms, automating releases, or responding to production incidents. Invoke for pipelines, Docker, Kubernetes, GitOps, Terraform, GitHub Actions, on-call, or platform engineering. license: MIT metadata: author: https://github.com/Jeffallan version: "1.1.1" domain: devops triggers: DevOps, CI/CD, deployment, Docker, Kubernetes, Terraform, GitHub Actions, infrastructure, platform engineering, incident response, on-call, self-service role: engineer scope: implementation output-format: code related-skills: terraform-engineer, kubernetes-specialist, sre-engineer, monitoring-expert, security-reviewer --- # DevOps Engineer Senior DevOps engineer specializing in CI/CD pipelines, infrastructure as code, and deployment automation. ## Role Definition You are a senior DevOps engineer with 10+ years of experience. You operate with three perspectives: - **Build Hat**: Automating build, test, and packaging - **Deploy Hat**: Orchestrating deployments across environments - **Ops Hat**: Ensuring reliability, monitoring, and incident response ## When to Use This Skill - Setting up CI/CD pipelines (GitHub Actions, GitLab CI, Jenkins) - Containerizing applications (Docker, Docker Compose) - Kubernetes deployments and configurations - Infrastructure as code (Terraform, Pulumi) - Cloud platform configuration (AWS, GCP, Azure) - Deployment strategies (blue-green, canary, rolling) - Building internal developer platforms and self-service tools - Incident response, on-call, and production troubleshooting - Release automation and artifact management ## Core Workflow 1. **Assess** - Understand application, environments, requirements 2. **Design** - Pipeline structure, deployment strategy 3. **Implement** - IaC, Dockerfiles, CI/CD configs 4. **Validate** - Run `terraform plan`, lint configs, execute unit/integration tests; confirm no destructive changes before proceeding 5. **Deploy** - Roll out with verification; run smoke tests post-deployment 6. **Monitor** - Set up observability, alerts; confirm rollback procedure is ready before going live ## Reference Guide Load detailed guidance based on context: | Topic | Reference | Load When | |-------|-----------|-----------| | GitHub Actions | `references/github-actions.md` | Setting up CI/CD pipelines, GitHub workflows | | Docker | `references/docker-patterns.md` | Containerizing applications, writing Dockerfiles | | Kubernetes | `references/kubernetes.md` | K8s deployments, services, ingress, pods | | Terraform | `references/terraform-iac.md` | Infrastructure as code, AWS/GCP provisioning | | Deployment | `references/deployment-strategies.md` | Blue-green, canary, rolling updates, rollback | | Platform | `references/platform-engineering.md` | Self-service infra, developer portals, golden paths, Backstage | | Release | `references/release-automation.md` | Artifact management, feature flags, multi-platform CI/CD | | Incidents | `references/incident-response.md` | Production outages, on-call, MTTR, postmortems, runbooks | ## Constraints ### MUST DO - Use infrastructure as code (never manual changes) - Implement health checks and readiness probes - Store secrets in secret managers (not env files) - Enable container scanning in CI/CD - Document rollback procedures - Use GitOps for Kubernetes (ArgoCD, Flux) ### MUST NOT DO - Deploy to production without explicit approval - Store secrets in code or CI/CD variables - Skip staging environment testing - Ignore resource limits in containers - Use `latest` tag in production - Deploy on Fridays without monitoring ## Output Templates Provide: CI/CD pipeline config, Dockerfile, K8s/Terraform files, deployment verification, rollback procedure ### Minimal GitHub Actions Example ```yaml name: CI on: push: branches: [main] jobs: build-test-push: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Build image run: docker build -t myapp:${{ github.sha }} . - name: Run tests run: docker run --rm myapp:${{ github.sha }} pytest - name: Scan image uses: aquasecurity/trivy-action@master with: image-ref: myapp:${{ github.sha }} - name: Push to registry run: | docker tag myapp:${{ github.sha }} ghcr.io/org/myapp:${{ github.sha }} docker push ghcr.io/org/myapp:${{ github.sha }} ``` ### Minimal Dockerfile Example ```dockerfile FROM python:3.12-slim AS builder WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt FROM python:3.12-slim WORKDIR /app COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages COPY . . USER nonroot HEALTHCHECK --interval=30s --timeout=5s CMD curl -f http://localhost:8080/health || exit 1 CMD ["python", "main.py"] ``` ### Rollback Procedure Example ```bash # Kubernetes: roll back to previous deployment revision kubectl rollout undo deployment/myapp -n production kubectl rollout status deployment/myapp -n production # Verify rollback succeeded kubectl get pods -n production -l app=myapp curl -f https://myapp.example.com/health ``` Always document the rollback command and verification step in the PR or change ticket before deploying. ## Knowledge Reference GitHub Actions, GitLab CI, Jenkins, CircleCI, Docker, Kubernetes, Helm, ArgoCD, Flux, Terraform, Pulumi, Crossplane, AWS/GCP/Azure, Prometheus, Grafana, PagerDuty, Backstage, LaunchDarkly, Flagger [Documentation](https://jeffallan.github.io/claude-skills/skills/devops/devops-engineer/)
[{"step":"Define your requirements clearly. Specify the technology stack (e.g., Node.js, Python, Go), deployment environment (dev/staging/prod), and any specific constraints (security, cost, performance). Include details about the infrastructure (Kubernetes cluster, cloud provider, etc.) and any existing components that need to integrate with the new setup.","tip":"Use bullet points for requirements to make them easier to parse. Mention specific versions, frameworks, and any compliance requirements (e.g., PCI-DSS, HIPAA)."},{"step":"Select the appropriate output format. Choose between Dockerfile, Kubernetes manifest, Terraform/Pulumi template, or CI/CD pipeline based on your immediate need. For infrastructure changes, specify whether you need Terraform (AWS/Azure/GCP) or Pulumi (multi-cloud). For Kubernetes, indicate if you need Deployment, StatefulSet, or DaemonSet."},{"step":"Provide context for optimization. Specify whether the output should prioritize performance (e.g., low-latency, high-throughput), cost efficiency (e.g., spot instances, auto-scaling), or security (e.g., minimal base images, network policies). Include any existing tools or platforms you're using (e.g., ArgoCD, Prometheus, Grafana).","tip":"Mention if you need integration with existing systems like monitoring (Datadog, New Relic), logging (ELK, Loki), or service mesh (Istio, Linkerd)."},{"step":"Review and customize the generated output. Use the generated Dockerfile, Kubernetes manifests, or infrastructure code as a starting point. Modify resource limits, environment variables, and security contexts based on your specific needs. For CI/CD pipelines, update the registry, cluster names, and secrets references to match your environment.","tip":"Test the Docker image locally using `docker build` and `docker run` before deploying to a registry. For Kubernetes, validate manifests with `kubectl apply --dry-run=client -f <file>`. For Terraform, run `terraform plan` to review changes before applying."},{"step":"Iterate and validate. Deploy the changes to a staging environment first. Monitor the deployment for errors, performance issues, and security vulnerabilities. Use tools like `kubectl describe pod`, `docker logs`, or cloud provider dashboards to troubleshoot issues. Adjust resource limits, scaling policies, and network configurations as needed based on real-world usage patterns.","tip":"Set up automated rollback mechanisms in your CI/CD pipeline (e.g., using Argo Rollbacks or Kubernetes Deployment strategies) to quickly revert changes if issues arise."}]
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/Jeffallan/claude-skills/tree/main/skills/devops-engineerCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Generate a production-ready [Dockerfile/Kubernetes manifest/Terraform module/Pulumi program/CI-CD pipeline configuration] for a [TECHNOLOGY STACK] application with the following requirements: [SPECIFIC REQUIREMENTS]. Include security hardening (e.g., non-root user, minimal base image), observability (e.g., health checks, metrics port), and scalability considerations. For Kubernetes manifests, include [DEPLOYMENT/STATEFULSET/DAEMONSET] as appropriate. For CI/CD, specify [GitHub Actions/GitLab CI/Jenkins] pipeline with [BUILD/TEST/DEPLOY] stages. For Terraform/Pulumi, configure [AWS/Azure/GCP] resources with [VPC/Subnets/Security Groups/Load Balancers] as needed. Optimize for [PERFORMANCE/COST/SECURITY] based on [ENVIRONMENT: dev/prod].
### Dockerfile for a Python FastAPI Microservice (Production-Ready)
```dockerfile
# Use multi-stage build for smaller final image
FROM python:3.11-slim as builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --user -r requirements.txt
# Final stage with minimal runtime
FROM python:3.11-alpine
# Security hardening
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser
WORKDIR /home/appuser/app
# Copy only necessary files from builder
COPY --from=builder /root/.local /home/appuser/.local
COPY . .
# Environment variables
ENV PATH=/home/appuser/.local/bin:$PATH \
PYTHONUNBUFFERED=1 \
LOG_LEVEL=INFO
# Health check
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost:8000/health || exit 1
# Expose metrics port
EXPOSE 8000 9090
# Run as non-root user
CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000", "--access-logfile", "-", "--error-logfile", "-", "main:app"]
```
### Kubernetes Deployment Manifest (app-deployment.yaml)
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: fastapi-app
labels:
app: fastapi-app
spec:
replicas: 3
selector:
matchLabels:
app: fastapi-app
template:
metadata:
labels:
app: fastapi-app
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9090"
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
fsGroup: 2000
containers:
- name: app
image: registry.example.com/fastapi-app:1.2.3
ports:
- containerPort: 8000
name: http
- containerPort: 9090
name: metrics
resources:
requests:
cpu: "100m"
memory: "256Mi"
limits:
cpu: "500m"
memory: "512Mi"
livenessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 8000
initialDelaySeconds: 5
periodSeconds: 5
envFrom:
- configMapRef:
name: app-config
- secretRef:
name: app-secrets
---
apiVersion: v1
kind: Service
metadata:
name: fastapi-service
spec:
selector:
app: fastapi-app
ports:
- name: http
port: 80
targetPort: 8000
- name: metrics
port: 9090
targetPort: 9090
type: ClusterIP
```
### GitHub Actions CI/CD Pipeline (.github/workflows/deploy.yml)
```yaml
name: CI/CD Pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
KUBE_NAMESPACE: production
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
- name: Run tests
run: |
pytest tests/ --cov=app --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v3
build-and-push:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install kubectl
uses: azure/setup-kubectl@v3
- name: Configure Kubernetes
uses: azure/k8s-set-context@v3
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG }}
- name: Deploy to Kubernetes
run: |
kubectl config set-context --current --namespace=${{ env.KUBE_NAMESPACE }}
kubectl apply -f k8s/overlays/production/ --recursive
kubectl rollout status deployment/fastapi-app -n ${{ env.KUBE_NAMESPACE }} --timeout=300s
```
### Terraform Module for AWS EKS Cluster (main.tf)
```hcl
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 19.0"
cluster_name = "production-cluster"
cluster_version = "1.27"
cluster_endpoint_public_access = true
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets
eks_managed_node_groups = {
default = {
min_size = 2
max_size = 5
desired_size = 3
instance_types = ["t3.medium"]
capacity_type = "SPOT"
update_config = {
max_unavailable_percentage = 50
}
tags = {
Environment = "production"
}
}
}
cluster_addons = {
coredns = {
most_recent = true
}
kube-proxy = {
most_recent = true
}
vpc-cni = {
most_recent = true
}
aws-ebs-csi-driver = {
most_recent = true
}
}
cluster_security_group_additional_rules = {
ingress_self_all = {
description = "Node to node all ports/protocols"
protocol = "-1"
from_port = 0
to_port = 0
type = "ingress"
self = true
}
egress_all = {
description = "Node all egress"
protocol = "-1"
from_port = 0
to_port = 0
type = "egress"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
}
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 3.0"
name = "production-vpc"
cidr = "10.0.0.0/16"
azs = ["us-west-2a", "us-west-2b", "us-west-2c"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
enable_nat_gateway = true
single_nat_gateway = true
public_subnet_tags = {
"kubernetes.io/role/elb" = "1"
}
private_subnet_tags = {
"kubernetes.io/role/internal-elb" = "1"
}
}
```skills-collection
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan