Open-Source Wikis

/

Terraform

/

By the numbers

hashicorp/terraform

By the numbers

A quantitative snapshot of hashicorp/terraform collected on 2026-04-30 from this clone, at commit 88f5be2141.

Size

Metric Value
Total Go source files (internal/, non-test) 1,271
Total Go test files (internal/, *_test.go) 633
Top-level Go files (root package, main) 12
Lines of source code (internal/**/*.go excluding tests) ~300,219
Direct + transitive Go module dependencies (lines in go.sum) 1,141
Total commits on main 35,355
xychart-beta horizontal
    title "Source files per top-level package (top 15, excluding tests)"
    x-axis ["command", "terraform", "stacks", "backend", "configs", "states", "addrs", "lang", "rpcapi", "plans", "moduletest", "legacy", "cloud", "getproviders", "tfdiags"]
    y-axis 0 --> 260
    bar [245, 155, 139, 87, 69, 50, 46, 42, 35, 33, 33, 33, 26, 21, 20]

The package layout is bottom-heavy in two areas:

  • internal/command/ (245 files) holds one *.go per CLI subcommand plus their tests, plus the views/, arguments/, and jsonformat/ rendering machinery. Several individual files are very large — meta_backend.go alone is 114,878 bytes.
  • internal/terraform/ (155 files) is the graph engine. The node_resource_*.go and transform_*.go family of files contain most of the per-vertex evaluation logic.

internal/stacks/ (139 files, multiple subdirectories) is the third-largest area despite being a newer subsystem; see stacks.

Activity

Recent activity, derived from git log on this clone:

Metric Value
Earliest commit 649cf336e8, 2014-05-21
Most recent commit 88f5be2141, 2026-04-29
Span ~12 years
Unique committer names 1,054

The 90-day window before the snapshot date contains active feature development (the 1.16.0-dev cycle), with daily merges to main. Day-to-day churn concentrates in:

  • internal/command/ (CLI flags and views)
  • internal/terraform/ (graph engine fixes for new features)
  • internal/stacks/ (the newest subsystem)
  • internal/configs/ (language-level features and validation)

Bot-attributed commits

This repository's history was created mostly before LLM-assisted authorship was common. A search of the commit log shows the dominant non-human authors are dependency bots (Dependabot for Go modules, the changelog automation that creates .changes/ entries) and the release pipeline. There is no factory-droid[bot] or copilot[bot] co-authorship in the merged history at the snapshot date — note that this is a lower bound, since inline AI tools leave no trace in git metadata. The current CONTRIBUTING.md adds explicit AI-usage guidance asking contributors to disclose AI involvement and to mark LLM-agent PRs with "🤖🤖🤖" in the title.

Complexity hotspots

Single largest source files (non-test) at the snapshot:

File Bytes
internal/command/meta_backend.go 114,878
internal/command/init.go 49,604
internal/command/meta_backend_migrate.go 43,765
internal/configs/test_file.go 40,683
internal/command/meta.go 30,467
internal/configs/config.go 40,808
internal/cloud/backend.go 54,122

Test files routinely exceed 100 KB; the largest is internal/terraform/context_apply_test.go at 372 KB and internal/terraform/context_plan_test.go at 211 KB. These are intentional — terraform.Context is the coordinator for plan and apply, so its tests cover an enormous matrix of scenarios.

The internal/terraform/testdata/ directory has 388 sub-directories, one per fixture configuration used by the engine tests. Similar fixture trees exist under internal/command/testdata/ (192 sub-directories) and internal/configs/testdata/ (25 sub-directories).

Dependencies

Source Notes
go.mod direct dependencies ~150 (search the file for require ( blocks)
go.sum total lines 1,141
Notable HashiCorp libraries hashicorp/hcl/v2, hashicorp/cli, hashicorp/go-plugin, hashicorp/terraform-svchost, hashicorp/terraform-config-inspect
Notable third-party libraries zclconf/go-cty (dynamic value type), apparentlymart/go-shquot (shell quoting), mitchellh/colorstring (terminal colors), mattn/go-shellwords (env-var arg splitting), go.opentelemetry.io/otel (telemetry)

See reference/dependencies for a longer treatment.

Tests and fixtures

  • 633 _test.go files in internal/.
  • A second tree of acceptance and end-to-end tests in internal/command/e2etest/ (binary-level CLI tests) and internal/backend/remote/e2e/ (HCP Terraform integration).
  • internal/legacy/ retains test scaffolding for the pre-0.12 representation of provider data, used by tests that still depend on those types.

The test-to-source ratio (633 / 1271) is roughly 1 test file for every 2 source files. In hot subsystems like internal/terraform/, the ratio inverts: each node_*.go typically has a substantially larger node_*_test.go.

Provider plugin protocol

The repo ships two protocol versions side-by-side:

File Bytes Notes
docs/plugin-protocol/tfplugin5.proto 32,852 Protocol v5 — used by the bulk of existing providers
docs/plugin-protocol/tfplugin6.proto 37,448 Protocol v6 — supports newer features (server capabilities, deferred actions, identity, ephemerals)

Both protocols are supported simultaneously by Terraform Core; see plugin-protocol.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

By the numbers – Terraform wiki | Factory