agentleFS
zircotezircote/terraform-lsp/CLAUDE.md

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

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
  1. Very specific:

    Run /setup to install all required tools, or manually:

    line 11
  2. Very specific:

    Run /validate to verify the plugin installation and tool availability.

    line 20
  3. Very specific:

    All hooks trigger on PostToolUse after Write|Edit operations.

    line 34
  4. Very specific:

    Use || true to prevent hook failures from blocking writes

    line 68
  5. Very specific:

    Use head -N to limit output verbosity

    line 69
  6. Very specific:

    Use command -v tool >/dev/null && for optional tool dependencies

    line 70
  7. Very specific:

    Use cd "$(dirname "$CLAUDE_FILE_PATH")" for directory-scoped commands

    line 71
  8. Very specific:

    Keep hooks fast (use --compact, limit output with head)

    line 96
  9. Very specific:

    Test hooks manually before committing: run the command directly on a .tf file

    line 98

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

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 terragrunt

Run /validate to verify the plugin installation and tool availability.

Key Files

FilePurpose
.lsp.jsonterraform-ls LSP configuration
hooks/hooks.json17 automated development hooks
.claude/commands/setup.md/setup command definition
.claude/commands/validate.md/validate command definition
.claude-plugin/plugin.jsonPlugin 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|Edit for 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 || true to prevent hook failures from blocking writes
  • Use head -N to 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:

  • .tf files map to terraform language server
  • .tfvars files map to terraform-vars language 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:

  1. trivy - Fast security vulnerability scanning (replaces deprecated tfsec)
  2. checkov - Compliance and policy scanning
  3. terraform-sensitive-check - Detects hardcoded secrets in config

Conventions

  • Prefer minimal diffs
  • Keep hooks fast (use --compact, limit output with head)
  • Documentation changes: update both README.md and commands/setup.md if relevant
  • Test hooks manually before committing: run the command directly on a .tf file

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.