Summary
CodeGraph currently has no support for HCL/Terraform files (.tf, .tfvars, .hcl). Terraform is one of the most widely-used IaC tools, and many repos (especially infrastructure repos) consist entirely of .tf files. Currently these files are silently skipped during indexing with "No files found to index".
What's needed
A pre-compiled tree-sitter-hcl.wasm already exists in the npm ecosystem:
Adding support would follow the exact same pattern as existing languages — three changes:
tree-sitter-wasms — vendor or reference the tree-sitter-hcl.wasm file
grammars.js — add .tf/.tfvars/.hcl to EXTENSION_MAP, add hcl to WASM_GRAMMAR_FILES
languages/hcl.js — create an HCL extractor (resource blocks, module blocks, data blocks, locals, variables, outputs, provider blocks, etc.) and register in languages/index.js
Key HCL/Terraform node types
The grammar exposes these block types that are relevant for code intelligence:
block — generic HCL block (with labels for resource/module/data names)
module_block — Terraform module references
resource_declaration / data_declaration — resource and data source references
variable_declaration / output_declaration / locals_declaration
provider_declaration / terraform_declaration
function_call — Terraform built-in functions
Example
resource "azurerm_resource_group" "example" {
name = "example-rg"
location = "uksouth"
}
module "vnet" {
source = "../modules/vnet"
resource_group_name = azurerm_resource_group.example.name
}
data "azurerm_client_config" "current" {}
This would be extremely valuable for anyone using Claude Code with Terraform infrastructure repos. Happy to contribute a PR if you're open to it!
Summary
CodeGraph currently has no support for HCL/Terraform files (
.tf,.tfvars,.hcl). Terraform is one of the most widely-used IaC tools, and many repos (especially infrastructure repos) consist entirely of.tffiles. Currently these files are silently skipped during indexing with "No files found to index".What's needed
A pre-compiled
tree-sitter-hcl.wasmalready exists in the npm ecosystem:@tree-sitter-grammars/tree-sitter-hclv1.2.0tree-sitter-hcl.wasm(92.5KB) andtree-sitter-terraform.wasm(92.5KB)Adding support would follow the exact same pattern as existing languages — three changes:
tree-sitter-wasms— vendor or reference thetree-sitter-hcl.wasmfilegrammars.js— add.tf/.tfvars/.hcltoEXTENSION_MAP, addhcltoWASM_GRAMMAR_FILESlanguages/hcl.js— create an HCL extractor (resource blocks, module blocks, data blocks, locals, variables, outputs, provider blocks, etc.) and register inlanguages/index.jsKey HCL/Terraform node types
The grammar exposes these block types that are relevant for code intelligence:
block— generic HCL block (with labels for resource/module/data names)module_block— Terraform module referencesresource_declaration/data_declaration— resource and data source referencesvariable_declaration/output_declaration/locals_declarationprovider_declaration/terraform_declarationfunction_call— Terraform built-in functionsExample
This would be extremely valuable for anyone using Claude Code with Terraform infrastructure repos. Happy to contribute a PR if you're open to it!