Create deployment scripts for various platforms
✓Works with OpenClaudeYou are a DevOps automation engineer. The user wants to create reusable deployment scripts for multiple platforms (AWS, Docker, Kubernetes, traditional servers).
What to check first
- Verify target platform credentials are configured (
aws configure,kubectl config view, Docker daemon running) - Check if deployment target environment variables exist (
.envfile or system exports for API keys, registry URLs, image names) - Confirm deployment artifact exists (built Docker image, compiled binary, or packaged application)
Steps
- Define deployment configuration using environment variables and a
.env.examplefile for reference - Create platform-specific deployment functions (AWS, Docker, Kubernetes, SSH-based)
- Implement pre-deployment health checks (connectivity, permissions, service availability)
- Add rollback logic that captures previous state before applying changes
- Implement logging and error handling with timestamps and exit codes
- Create idempotent operations so re-running the script is safe
- Add deployment verification steps (health checks, endpoint tests, log inspection)
- Package the script with a
Makefileor wrapper for easy invocation
Code
#!/bin/bash
set -euo pipefail
# Configuration
DEPLOYMENT_ENV="${DEPLOYMENT_ENV:-staging}"
DEPLOYMENT_LOG="/var/log/deployment-$(date +%Y%m%d-%H%M%S).log"
BACKUP_DIR="/opt/backups"
ROLLBACK_SNAPSHOT=""
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
log() {
echo -e "${GREEN}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $*" | tee -a "$DEPLOYMENT_LOG"
}
error() {
echo -e "${RED}[ERROR]${NC} $*" | tee -a "$DEPLOYMENT_LOG"
exit 1
}
warn() {
echo -e "${YELLOW}[WARN]${NC} $*" | tee -a "$DEPLOYMENT_LOG"
}
# Pre-deployment checks
pre_deployment_checks() {
log "Running pre-deployment checks..."
if [[ -z "${DOCKER_IMAGE:-}" ]]; then
error "DOCKER_IMAGE environment variable not set"
fi
if ! command -v docker &> /dev/null; then
error "Docker is not installed or not in PATH"
fi
if ! docker ps &> /dev/null; then
error "Cannot connect to Docker daemon"
fi
log "Pre-deployment checks passed"
}
# Deploy to Kubernetes
deploy_kubernetes() {
local app_name="$1"
local image="$2"
local replicas="${3:-3}"
log "Deploying $app_name to Kubernetes cluster..."
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related DevOps & CI/CD Skills
Other Claude Code skills in the same category — free to download.
GitHub Actions Setup
Create GitHub Actions workflow files
GitLab CI Setup
Create .gitlab-ci.yml pipeline configuration
Jenkins Pipeline
Generate Jenkinsfile for CI/CD
Env Manager
Manage environment variables across environments
Infrastructure as Code
Generate Terraform/Pulumi configurations
Auto Release
Set up automated releases with semantic versioning
Rollback Script
Create rollback procedures and scripts
Blue-Green Deploy
Configure blue-green deployment strategy
Want a DevOps & CI/CD skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.