home / skills / dasien / claudemultiagenttemplate / 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-codeReview the files below or copy the command above to add this skill to your agents.
---
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
---
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.
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.
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.