Skip to main content
skill CX Codex

setting-up-terraform — Claude Code skill: scaffold Terraform IaC

Walks your agent through a Terraform setup for cloud work: provider, variables, resources, remote state and CI. Useful when a repo is moving to infrastructure as code.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add spencerpauly/awesome-cursor-skills --skill setting-up-terraform -a claude-code
Open on GitHub

What setting-up-terraform does

The skill kicks in when you ask for Terraform or infrastructure-as-code setup. It creates an infra/ directory holding main.tf, variables.tf, outputs.tf, providers.tf and a modules/ folder, with terraform.tfvars kept out of version control.

In providers.tf it pins required_version at 1.5 or newer, adds the hashicorp/aws provider at ~> 5.0 and points the S3 backend at a state bucket. Swap in GCP or Azure as needed. Variables come with a type, a description and a default; resources such as VPC, RDS, S3 or Lambda land in main.tf, and repeated blocks move into modules. State locking on AWS uses DynamoDB. The .gitignore entries cover *.tfstate and *.tfvars.

It also writes a GitHub Actions workflow: terraform fmt -check, terraform validate and terraform plan run on pull requests, while apply waits for a merge into main behind an approval step. Provider versions get pinned because a major bump can break a working config. State files never go into git — they carry secrets and resource addresses.

What it helps with

  • lay out an infra/ folder with Terraform files in the right places
  • pin the provider and its version so upgrades do not break configs
  • move state to an S3 bucket and lock it with DynamoDB
  • keep .tfstate and .tfvars out of the repository
  • run a plan check on pull requests via GitHub Actions

Example prompts for the agent

  • Set up Terraform for AWS with an S3 backend, variables and modules under infra/
  • Write a CI pipeline that runs terraform plan on PRs and apply after merge
  • Split dev, staging and prod into separate state files

How to install setting-up-terraform

1Skills CLI (Vercel)

npx skills add spencerpauly/awesome-cursor-skills --skill setting-up-terraform -a claude-code

2Manually: put the files in place

~/.claude/skills/setting-up-terraform/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/setting-up-terraform/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about setting-up-terraform

How do I install setting-up-terraform in Claude Code?

Run npx skills add spencerpauly/awesome-cursor-skills --skill setting-up-terraform -a claude-code. The skill file then sits at ~/.claude/skills/setting-up-terraform/SKILL.md.

What does setting-up-terraform do?

It guides the agent through a Terraform build: project layout, provider config, typed variables, resources, remote state, .gitignore rules and a GitHub Actions pipeline.

What has to be in place before it runs?

Terraform 1.5 or later. The example backend relies on an S3 bucket plus a DynamoDB table for state locking.

Source text

SKILL.md · CC0-1.0
---
name: setting-up-terraform
description: Set up Terraform infrastructure-as-code for cloud resources, including provider configuration, modules, state management, and CI integration.
---

# Setup Terraform

Use this skill when the user asks to set up Terraform, infrastructure as code, cloud provisioning, or IaC.

## Steps

1. **Initialize the project structure**

   ```
   infra/
   ├── main.tf
   ├── variables.tf
   ├── outputs.tf
   ├── terraform.tfvars      # (gitignored)
   ├── providers.tf
   └── modules/
   ```

2. **Configure the provider** — in `providers.tf`:

   ```hcl
   terraform {
     required_version = ">= 1.5"
     required_providers {
       aws = {
         source  = "hashicorp/aws"
         version = "~> 5.0"
       }
     }
     backend "s3" {
       bucket = "my-terraform-state"
       key    = "prod/terraform.tfstate"
       region = "us-east-1"
     }
   }

   provider "aws" {
     region = var.aws_region
   }
   ```

   Adapt the provider for the user's cloud (AWS, GCP, Azure).

3. **Define variables** — in `variables.tf`, define inputs with types, descriptions, and defaults:

   ```hcl
   variable "aws_region" {
     type        = string
     default     = "us-east-1"
     description = "AWS region for resources"
   }

   variable "environment" {
     type        = string
     description = "Deployment environment (dev, staging, prod)"
   }
   ```

4. **Create resources** — in `main.tf`, define the infrastructure the user needs (VPC, RDS, ECS, S3, Lambda, etc.). Extract reusable patterns into modules under `modules/`.

5. **Configure remote state** — use an S3 bucket (AWS), GCS bucket (GCP), or Azure Storage for state. Enable state locking with DynamoDB (AWS).

6. **Add to `.gitignore`**

   ```
   *.tfstate
   *.tfstate.*
   .terraform/
   terraform.tfvars
   *.tfvars
   ```

7. **Add CI pipeline** — create a GitHub Actions workflow that runs `terraform fmt -check`, `terraform validate`, and `terraform plan` on PRs, with `terraform apply` on merge to main (with approval gate).

## Notes

- Never commit state files or `.tfvars` with secrets.
- Use workspaces or separate state files for dev/staging/prod.
- Pin provider versions to avoid breaking changes.
- Run `terraform fmt` before committing.

© spencerpauly · CC0-1.0 · spencerpauly/awesome-cursor-skills

Similar skills

All skills for DevOps and infrastructure →

From the same set64

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor