infrastructure-validation
Skill66 starsChanged 5 months agoMITView on GitHub
Validates infrastructure-as-code with tool chains and checks for common mistakes. Use when working with Terraform (.tf, .tfvars), Ansible (playbooks, roles, inventory), Docker (Dockerfile, docker-compose.yml), Kubernetes (manifests, Helm charts), or CloudFormation. Also use when running terraform plan/apply, building Docker images, writing Helm templates, or when IaC changes touch security groups, IAM policies, or secrets.
In this repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- code-simplificationSkill
- documentationSkill
- git-workflowSkill
- import-spec-fileSkill
- import-specSkill
- lessons-learnedSkill
- parallel-dispatchSkill
- security-auditSkill
- shipyard-brainstormingSkill
- shipyard-debuggingSkill
- shipyard-executing-plansSkill
- shipyard-handoffSkill
- shipyard-tddSkill
- shipyard-testingSkill
- shipyard-verificationSkill
- shipyard-writing-plansSkill
- shipyard-writing-skillsSkill
- using-shipyardSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 27
Core principle: Never apply without plan review.
- Distinctive: line 33
Run in order. Each step must pass before proceeding.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- TOKEN BUDGET: 140 lines / ~420 tokens -->Infrastructure Validation
<activation>Activation Triggers
- Files matching:
*.tf,*.tfvars,Dockerfile,docker-compose.yml,playbook*.yml,roles/,inventory/ - Config:
.shipyard/config.jsonhasiac_validationset to"auto"ortrue - Templates with
AWSTemplateFormatVersion(CloudFormation) - YAML with
apiVersion:(Kubernetes)
Natural Language Triggers
- "validate terraform", "check docker", "lint ansible", "IaC validation", "infrastructure check"
</activation>Overview
IaC mistakes don't cause test failures -- they cause outages, breaches, and cost overruns. Validate before every change.
Core principle: Never apply without plan review. Like TDD requires tests before code, IaC requires validation before apply.
<instructions>Terraform Workflow
Run in order. Each step must pass before proceeding.
terraform fmt -check # 1. Format (auto-fix with fmt if needed)
terraform validate # 2. Syntax validation
terraform plan -out=tfplan # 3. Review every change -- NEVER skip
tflint --recursive # 4. Lint (if installed)
tfsec . OR checkov -d . # 5. Security scan (if installed)Drift detection: terraform plan -detailed-exitcode -- exit code 2 means drift. Document what drifted and why before overwriting.
Ansible Workflow
yamllint . # 1. YAML syntax
ansible-lint # 2. Best practices
ansible-playbook --syntax-check *.yml # 3. Playbook syntax
ansible-playbook --check *.yml # 4. Dry run (where supported)
molecule test # 5. Role tests (if configured)Docker Workflow
hadolint Dockerfile # 1. Lint (if installed)
docker build -t test-build . # 2. Build
trivy image test-build # 3. Security scan (if installed)
docker compose config # 4. Validate compose (if applicable)Kubernetes Workflow
kubectl --dry-run=client -f manifest.yml # 1. Client-side validation
kubectl --dry-run=server -f manifest.yml # 2. Server-side validation (if cluster access)
kubeval --strict manifest.yml # 3. Schema validation (if installed)
kubeconform -strict manifest.yml # 4. Schema validation alternative
kube-linter lint . # 5. Best practices (if installed)
helm template . | kubeval --strict # 6. Helm chart validation (if applicable)</instructions>Common Mistakes
Terraform
| Mistake | Fix |
| Local state file | Use remote backend (S3+DynamoDB, GCS) |
| No state locking | Enable lock table |
| Hardcoded secrets | Use variables + secret manager |
* in security groups | Restrict to specific CIDRs |
| Unpinned provider version | Pin in required_providers |
| Missing tags | Require via policy or module defaults |
Ansible
| Mistake | Fix |
| Plaintext secrets | ansible-vault encrypt |
shell instead of modules | Use native modules (apt, copy, etc.) |
| Everything as root | become: false by default, escalate only when needed |
Docker
| Mistake | Fix |
FROM ubuntu:latest | Pin to digest: FROM ubuntu:22.04@sha256:... |
| Running as root | Add USER nonroot |
COPY . . | Use .dockerignore, copy specific files |
| Secrets in ENV/ARG | Use build secrets or runtime injection |
| No health check | Add HEALTHCHECK instruction |
| Single-stage build | Use multi-stage builds |
Kubernetes
| Mistake | Fix |
| No resource limits | Set resources.requests and resources.limits |
| Running as root | securityContext.runAsNonRoot: true |
latest image tag | Pin exact version or digest |
| No liveness/readiness probes | Add probes matching app health endpoints |
| Default namespace for workloads | Use dedicated namespaces with RBAC |
| No network policies | Restrict pod-to-pod traffic with NetworkPolicy |
<rules>Red Flags -- STOP
terraform apply -auto-approvewithout prior plan review- Security group with
0.0.0.0/0on non-HTTP ports - IAM policy with
*action or*resource - Secrets in
.tf,.yml, orDockerfile - State file committed to git
latesttag on any base image- Container running as root in production
</rules><examples>Validation Finding Examples
Good Finding -- specific, shows the problem, gives the fix
**IaC-Critical: Overly permissive security group in modules/network/main.tf**
Resource: aws_security_group_rule.allow_all (line 34)
Problem: Ingress rule allows 0.0.0.0/0 on port 22 (SSH).
This exposes SSH to the entire internet.
Fix: Restrict to bastion host CIDR or VPN range:
cidr_blocks = [var.vpn_cidr]
Validation: `tfsec .` flagged this as HIGH severity (AWS018).Bad Finding -- vague, no location, no evidence
**Security Issue: Network configuration may be too open.**
Review the security groups for potential issues.</examples>Integration
Referenced by: shipyard:builder (detects IaC files, follows appropriate workflow), shipyard:verifier (IaC validation mode), shipyard:auditor (IaC security checks)
Pairs with: shipyard:security-audit (security lens for IaC), shipyard:shipyard-verification (IaC claims need validation evidence)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

