terraform-lsp
CLAUDE.md2 starsChanged 11 months agoMITView on GitHub
A Claude Code plugin providing Terraform development support through terraform-ls LSP integration and 17 automated hooks for code quality, security, and infrastructure validation. Run /setup to install all required tools, or manually: Run /validate to verify the plugin installation and tool availability. All hooks trigger on PostToolUse after Write|Edit operations. Hooks use command -v checks to skip gracefully when optional tools aren't installed. Hook categories: - Core (.tf): format, validate, init check, plan hint - Linting (.tf): tflint, todo/fixme detection…
- Installs packages
In this repositoryOne other file it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
The file
We split this CLAUDE.md into the rules it gives an agent
9 rules. About 0 are common, 0 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
Run /setup to install all required tools, or manually:
- Very specific: line 20
Run /validate to verify the plugin installation and tool availability.
- Very specific: line 34
All hooks trigger on PostToolUse after Write|Edit operations.
- Very specific: line 68
Use || true to prevent hook failures from blocking writes
- Very specific: line 69
Use head -N to limit output verbosity
- Very specific: line 70
Use command -v tool >/dev/null && for optional tool dependencies
- Very specific: line 71
Use cd "$(dirname "$CLAUDE_FILE_PATH")" for directory-scoped commands
- Very specific: line 96
Keep hooks fast (use --compact, limit output with head)
- Very specific: line 98
Test hooks manually before committing: run the command directly on a .tf file
≈ “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
A Claude Code plugin providing Terraform development support through terraform-ls LSP integration and 17 automated hooks for code quality, security, and infrastructure validation.
Setup
Run /setup to install all required tools, or manually:
# macOS (Homebrew)
brew tap hashicorp/tap
brew install hashicorp/tap/terraform hashicorp/tap/terraform-ls \
tflint trivy checkov terraform-docs infracost terragruntRun /validate to verify the plugin installation and tool availability.
Key Files
| File | Purpose |
.lsp.json | terraform-ls LSP configuration |
hooks/hooks.json | 17 automated development hooks |
.claude/commands/setup.md | /setup command definition |
.claude/commands/validate.md | /validate command definition |
.claude-plugin/plugin.json | Plugin metadata |
Hook System
All hooks trigger on PostToolUse after Write|Edit operations. Hooks use command -v checks to skip gracefully when optional tools aren't installed.
Hook categories:
- Core (
.tf): format, validate, init check, plan hint - Linting (
.tf): tflint, todo/fixme detection - Security (
.tf): trivy, checkov, sensitive value detection - Variables (
.tfvars): format, sensitive check - Terragrunt (
terragrunt.hcl): format, validate - Hints (
main.tf,variables.tf): docs, cost, provider upgrade suggestions
When Modifying Hooks
Edit hooks/hooks.json. The hooks use Claude Code's standard event-based format:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [{ "type": "command", "command": "..." }],
"conditions": { "fileExtensions": [".tf"] }
}
]
}
}Key fields:
matcher: Tool name pattern (e.g.,Write|Editfor file operations)conditions.fileExtensions: File types to match (e.g.,[".tf", ".tfvars"])conditions.pathPatterns: Path globs for specific files (e.g.,["**/main.tf"])
Best practices:
- Use
|| trueto prevent hook failures from blocking writes - Use
head -Nto limit output verbosity - Use
command -v tool >/dev/null &&for optional tool dependencies - Use
cd "$(dirname "$CLAUDE_FILE_PATH")"for directory-scoped commands
When Modifying LSP Config
Edit .lsp.json. The extensionToLanguage map controls which files use the LSP:
.tffiles map toterraformlanguage server.tfvarsfiles map toterraform-varslanguage server
Terraform-Specific Guidance
Directory Structure
Terraform validation and init require working in the correct directory. Hooks use cd "$(dirname "$CLAUDE_FILE_PATH")" to ensure commands run in the module directory.
Provider Initialization
Many terraform commands require terraform init first. The terraform-init-check hook warns when .terraform directory is missing.
Security Scanning
The plugin includes three layers of security scanning:
trivy- Fast security vulnerability scanning (replaces deprecated tfsec)checkov- Compliance and policy scanningterraform-sensitive-check- Detects hardcoded secrets in config
Conventions
- Prefer minimal diffs
- Keep hooks fast (use
--compact, limit output withhead) - Documentation changes: update both README.md and commands/setup.md if relevant
- Test hooks manually before committing: run the command directly on a
.tffile
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.

