home / skills / dasien / claudemultiagenttemplate / infrastructure-as-code

infrastructure-as-code skill

/templates/.claude/skills/infrastructure-as-code

This skill helps you define and provision infrastructure as code using Terraform, Docker, and related tools for reproducible environments.

npx playbooks add skill dasien/claudemultiagenttemplate --skill infrastructure-as-code

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.5 KB
---
name: "Infrastructure as Code"
description: "Define and manage infrastructure using code with tools like Terraform, CloudFormation, and Docker"
category: "devops"
required_tools: ["Read", "Write", "Bash"]
---

## Purpose
Define infrastructure as version-controlled code, enabling reproducible environments and automated provisioning.

## When to Use
- Provisioning cloud resources
- Creating development environments
- Managing infrastructure changes
- Disaster recovery planning

## Key Capabilities
1. **Declarative Infrastructure** - Define desired state in code
2. **Container Configuration** - Create Docker images and configurations
3. **State Management** - Track infrastructure state and changes

## Approach
1. Choose appropriate tool (Terraform, Docker, K8s)
2. Define resources declaratively
3. Use modules for reusability
4. Version control infrastructure code
5. Apply infrastructure changes safely

## Example
```hcl
# Terraform example
resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t3.medium"
  
  tags = {
    Name = "web-server"
    Environment = "production"
  }
}

# Docker example
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]
```

## Best Practices
- ✅ Version control all infrastructure code
- ✅ Use modules for reusability
- ✅ Implement least privilege access
- ✅ Tag resources for cost tracking
- ❌ Avoid: Manual infrastructure changes
- ❌ Avoid: Hardcoding credentials

---

Overview

This skill helps teams define and manage infrastructure as version-controlled code using tools like Terraform, CloudFormation, Docker, and Kubernetes. It streamlines reproducible provisioning, automated deployments, and state management so environments can be created, updated, and audited reliably. The focus is on safety, reusability, and minimizing manual changes.

How this skill works

The skill inspects and codifies desired infrastructure state into declarative configurations and container definitions. It uses modules and templates to promote reuse, applies changes through safe workflows, and tracks state to detect drift. Integrations with version control and CI/CD automate plans, reviews, and deployments.

When to use it

  • Provision cloud resources across environments (dev, staging, prod)
  • Create consistent developer and CI environments with containers
  • Manage and version infrastructure changes and rollbacks
  • Implement disaster recovery and reproducible rebuilds
  • Enforce policies like least-privilege and tagging for cost and security

Best practices

  • Keep all infrastructure code in version control and make changes via pull requests
  • Use modules and templates for repeatable, composable resources
  • Store and manage state securely; lock state for concurrent operations
  • Enforce least-privilege IAM roles and avoid hardcoded credentials
  • Tag resources for cost tracking and environment identification

Example use cases

  • Provision a multi-tier application with Terraform modules and automated CI plans
  • Build and publish minimal Docker images for microservices and local dev parity
  • Create a reproducible disaster recovery plan that rebuilds infra from code
  • Automate environment creation for feature branches and ephemeral test clusters
  • Manage state and drift detection to keep cloud resources aligned with declarations

FAQ

Can this skill manage both containers and cloud resources?

Yes. It covers Docker container definitions and orchestrators alongside declarative cloud infrastructure tools like Terraform and CloudFormation.

How do I avoid accidental production changes?

Use version control, CI/CD pipelines that require reviews for apply steps, state locking, and role-based access controls to separate plan and apply privileges.

What should I avoid when writing infrastructure code?

Avoid manual changes outside code, hardcoding credentials or secrets, and embedding environment-specific values directly instead of using variables and templates.