claude-skill-hcp-terraform / terraform-stacks
CLAUDE.md4 starsChanged 13 months agoMITView on GitHub
This is a Claude Skill repository for HashiCorp Terraform Stacks - a specialized knowledge base that provides comprehensive documentation and guidance for working with Terraform Stacks configurations. This is not a traditional software project with executable code, but rather a documentation repository structured as a skill module for Claude AI assistants. Purpose: Enable Claude to help users create, modify, validate, and troubleshoot Terraform Stack configurations (.tfcomponent.hcl and .tfdeploy.hcl files), manage multi-region/multi-environment infrastructure, and understand Terraform Stacks syntax and best practices.
- Commits and pushes
In this repository8 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- terraform-mcp-as-code/CLAUDE.mdCLAUDE.md
- terraform-style-guide/CLAUDE.mdCLAUDE.md
- terraform-test/CLAUDE.mdCLAUDE.md
- Terraform Infrastructure as CodeSkill
- terraform-stacksSkill
- terraform-style-guideSkill
- terraform-testSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
21 rules. About 0 are common, 18 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈18
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 29
[SKILL.md](SKILL.md): - Start here for high-level concepts, syntax overview, CLI commands, common patterns, and troubleshooting
- Distinctive: line 78
All files must be at root level (processed in dependency order)
- Distinctive: line 99
Each deployment has isolated state: - No shared state between deployments
- Distinctive: line 100
Dependencies are auto-inferred: - When components reference other component outputs
- Distinctive: line 102
Deployment groups are essential: - Always organize deployments into deployment groups, even single deployments.
- Distinctive: line 123
Best Practice: Every deployment should be organized into a deployment group, even if it's the only deployment in the Stack.
- Very specific: line 142
Use assume_role_with_web_identity in AWS provider config
- Distinctive: line 149
After successful destruction, remove the deployment block from configuration
- Very specific: line 163
Solution: All provider configurations must be at Stack level in .tfcomponent.hcl files
- Distinctive: line 176
Follow these naming patterns for clarity:
- Distinctive: line 186
All files are processed together by HCP Terraform, so the naming is for human organization only.
- Distinctive: line 193
No compilation or build commands
- Distinctive: line 194
No package manager or dependencies
- Distinctive: line 196
No Docker or containerization
- Distinctive: line 203
Update examples when syntax changes: - All code examples must remain valid and working
- Distinctive: line 205
Test HCL syntax accuracy: - Ensure all code blocks use correct Terraform Stacks HCL syntax (not regular Terraform)
- Distinctive: line 206
Include deployment groups in all examples: - Every example with deployments must include corresponding deployment_group blocks, even for …
- Distinctive: line 210
Use Git for all changes:
- Distinctive: line 222
All Terraform Stacks code examples use HCL syntax:
- Distinctive: line 241
When referencing syntax details, point to specific files:
- Distinctive: line 248
Use these exact terms consistently:
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md 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
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is a Claude Skill repository for HashiCorp Terraform Stacks - a specialized knowledge base that provides comprehensive documentation and guidance for working with Terraform Stacks configurations. This is not a traditional software project with executable code, but rather a documentation repository structured as a skill module for Claude AI assistants.
Purpose: Enable Claude to help users create, modify, validate, and troubleshoot Terraform Stack configurations (.tfcomponent.hcl and .tfdeploy.hcl files), manage multi-region/multi-environment infrastructure, and understand Terraform Stacks syntax and best practices.
Repository Structure
claude-skill-terraform-stacks/
├── README.md # Brief project description (2 lines)
├── SKILL.md # Main comprehensive guide (580 lines)
└── references/ # Detailed reference documentation
├── component-blocks.md # Component block specification (649 lines)
├── deployment-blocks.md # Deployment block specification (1009 lines)
└── examples.md # Complete working examples (1529 lines)Total: 3,767 lines of documentation organized into focused modules.
Documentation Architecture
Core Documentation Flow
- SKILL.md - Start here for high-level concepts, syntax overview, CLI commands, common patterns, and troubleshooting
- references/component-blocks.md - Deep dive into component configuration syntax for
.tfcomponent.hclfiles - references/deployment-blocks.md - Deep dive into deployment configuration syntax for
.tfdeploy.hclfiles - references/examples.md - Complete working examples from simple to complex scenarios
Content Organization
SKILL.md covers:
- Core concepts (Stack, Component, Deployment, Stack Language)
- File structure and organization
- Configuration blocks: variables, providers, components, outputs, locals, removed blocks
- Deployment configuration syntax
- CLI commands (
terraform stacks validate,plan,apply) - Common patterns (multi-region, component dependencies)
- Best practices and troubleshooting
references/component-blocks.md covers:
- Complete syntax reference for all component configuration blocks
- Detailed argument specifications with types and constraints
- Code examples for each block type
- Key differences from traditional Terraform syntax
references/deployment-blocks.md covers:
- Complete syntax reference for all deployment configuration blocks
- Identity token configurations (OIDC)
- Deployment groups and auto-approval rules
- Linked Stacks (publish outputs and upstream inputs)
- Cloud provider-specific configurations (AWS, Azure, GCP)
references/examples.md covers:
- Simple single-region Stack (with deployment group)
- Stack with private registry modules
- Multi-environment Stack (dev/staging/prod with deployment groups)
- Multi-region Stack with regional provider configurations
- Linked Stacks with cross-stack dependencies
- Multi-cloud Stack (AWS + Azure)
- Complete AWS production Stack with all features
- Destroying deployments safely
Key Terraform Stacks Concepts
Stack Language vs Traditional Terraform
Terraform Stacks use a separate HCL-based language distinct from traditional Terraform:
- Different file extensions:
.tfcomponent.hcl(components),.tfdeploy.hcl(deployments) - Different block syntax for providers (use
for_each, aliases in headers,configblocks) - Components wrap modules (modules cannot contain provider blocks)
- Outputs and variables require
typeargument - All files must be at root level (processed in dependency order)
Component Module Sources
Components can reference modules from multiple source types:
- Local paths:
./modules/vpcor../shared-modules/networking - Public registry:
terraform-aws-modules/vpc/aws(format:<NAMESPACE>/<NAME>/<PROVIDER>) - Private registry:
app.terraform.io/my-org/vpc/aws(format:<HOSTNAME>/<ORG>/<MODULE>/<PROVIDER>)- HCP Terraform SaaS: Use
app.terraform.io - Terraform Enterprise: Use your instance hostname
- Generic hostname: Use
localterraform.comfor multi-instance deployments
- HCP Terraform SaaS: Use
- Git repositories:
git::https://github.com/org/repo.git//modules/vpc?ref=v1.0.0 - HTTP/HTTPS archives:
https://example.com/modules/vpc.tar.gz
The version argument is supported only for registry sources (public and private). See references/component-blocks.md for complete details.
Critical Architecture Points
- Components are abstractions around modules - Each component specifies a source module, inputs, and providers
- Deployments are instances of the entire Stack - Used for different environments, regions, or accounts
- Each deployment has isolated state - No shared state between deployments
- Dependencies are auto-inferred - When components reference other component outputs
- Provider configurations support
for_each- Enable multi-region patterns with single configuration - Deployment groups are essential - Always organize deployments into deployment groups, even single deployments. This enables auto-approval rules, maintains consistency, and provides a foundation for scaling
Common Scenarios and Patterns
When Users Ask About Multi-Region Infrastructure
Guide them to use:
for_eachon provider blocks to create regional providersfor_eachon component blocks to deploy per region- Each region gets its own provider instance and component instance
See SKILL.md lines 442-476 for the complete pattern.
When Users Ask About Multi-Environment Deployments
Guide them to create:
- Multiple deployment blocks (one per environment)
- Each deployment gets its own inputs and isolated state
- Always create deployment groups to organize deployments (even for single deployments)
- Deployment groups enable auto-approval rules and provide consistent configuration patterns
Best Practice: Every deployment should be organized into a deployment group, even if it's the only deployment in the Stack. This establishes a consistent pattern and enables future scaling.
See references/examples.md for multi-environment example.
When Users Ask About Cross-Stack Dependencies
Guide them to use:
publish_outputblocks in the source Stack (exports values)upstream_inputblocks in the dependent Stack (imports values)- Reference upstream inputs in deployment inputs
See SKILL.md lines 375-407 for syntax.
When Users Ask About OIDC Authentication
Guide them to use:
identity_tokenblocks in.tfdeploy.hclwith appropriate audience- Reference token via
identity_token.<name>.jwt - Pass token to provider configuration in deployment inputs
- Use
assume_role_with_web_identityin AWS provider config
When Users Ask About Destroying/Removing Deployments
Guide them to:
- Set
destroy = truein the deployment block - Apply the plan through HCP Terraform (this destroys all resources)
- After successful destruction, remove the deployment block from configuration
Important: Using destroy = true ensures provider authentication is retained during resource destruction. See references/deployment-blocks.md lines 173-196 and references/examples.md "Destroying Deployments" section.
Common Errors and Solutions
"Deprecated filename usage" Warning
Issue: Files use .tfcomponent.hcl extension
Solution: Rename to .tfcomponent.hcl for component files; keep .tfdeploy.hcl for deployments
Provider Configuration Errors
Issue: Providers defined inside modules
Solution: All provider configurations must be at Stack level in .tfcomponent.hcl files
Circular Dependencies
Issue: Component A references Component B, and B references A Solution: Refactor to break circular reference or introduce intermediate component
Maximum Deployments Limit
HCP Terraform supports maximum 20 deployments per Stack. For more instances, use multiple Stacks or for_each within components.
File Naming Conventions
Follow these naming patterns for clarity:
variables.tfcomponent.hcl # Variable declarations
providers.tfcomponent.hcl # Provider configurations
components.tfcomponent.hcl # Component definitions
outputs.tfcomponent.hcl # Stack outputs
deployments.tfdeploy.hcl # Deployment definitionsAll files are processed together by HCP Terraform, so the naming is for human organization only.
How to Work with This Repository
No Build System
This is a documentation-only repository:
- No compilation or build commands
- No package manager or dependencies
- No automated tests
- No Docker or containerization
Making Changes
When updating documentation:
- Maintain consistency across files - Changes to syntax should be reflected in SKILL.md, appropriate references/ file, and examples.md
- Update examples when syntax changes - All code examples must remain valid and working
- Keep the architecture accurate - The "big picture" concepts in SKILL.md must align with detailed specs in references/
- Test HCL syntax accuracy - Ensure all code blocks use correct Terraform Stacks HCL syntax (not regular Terraform)
- Include deployment groups in all examples - Every example with deployments must include corresponding deployment_group blocks, even for single deployments
Version Control
Use Git for all changes:
git status # Check current changes
git add <files> # Stage changes
git commit -m "message" # Commit changes
git push # Push to remoteDocumentation Style Guide
Code Blocks
All Terraform Stacks code examples use HCL syntax:
# Correct block structure
component "example" {
source = "./modules/example"
inputs = {
key = value
}
providers = {
aws = provider.aws.this
}
}File References
When referencing syntax details, point to specific files:
- Detailed component syntax → references/component-blocks.md
- Detailed deployment syntax → references/deployment-blocks.md
- Working examples → references/examples.md
Terminology Consistency
Use these exact terms consistently:
- Stack (not "stack configuration" or "terraform stack")
- Component (not "module" - modules are what components wrap)
- Deployment (not "environment" - deployments can represent environments)
- Stack Language (not "HCL" - it's a separate language based on HCL)
CLI Commands (Terraform Stacks)
# Generate provider lock file
terraform stacks providers lock
# Validate Stack configuration
terraform stacks validate
# Plan specific deployment
terraform stacks plan --deployment=<name>
# Apply specific deployment
terraform stacks apply --deployment=<name>Note: These are not regular terraform commands - they are terraform stacks subcommands specific to Terraform Stacks.
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.

