terraform-docs
$ terraform-docs Official Low Riskterraform-docs parses Terraform and OpenTofu HCL modules locally and emits Markdown tables, JSON ASTs, YAML, or tfvars without needing provider credentials. Agents can inspect module inputs, outputs, and dependencies as structured JSON or update README.md deterministically.
brew install terraform-docs Pure local HCL AST parser; terraform-docs json . runs in milliseconds with zero MCP server overhead.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
First-class json subcommand outputs clean structured metadata, never prompts on TTY, and returns predictable exit codes including --output-check drift detection.
- Native
terraform-docs json <path>structured output - Non-interactive execution and
--output-checkCI verification
Requires zero cloud credentials or network calls and defaults to stdout unless --output-file is explicitly passed.
- Zero auth required and read-only stdout default
- Delimited
--output-mode injectlimits file edits
Single static Go binary distributed via Homebrew, Docker, Go install, and release archives across macOS, Linux, and Windows.
- Zero runtime dependencies; single static Go binary
Eliminates manual HCL parsing and keeps module documentation synced with minimal context tokens.
- Supports
.terraform-docs.ymlconfig and JSON/YAML/Markdown formatters
Official terraform-docs project under MIT license with broad community adoption.
- Maintained at
terraform-docs/terraform-docsunder MIT
Well-structured documentation site with clear formatter references and config examples.
- Dedicated user guide and formatter docs at terraform-docs.io
Security, Auth & Guardrails
No authentication or cloud credentials required; operates purely on local HCL module files.
MIT open-source and completely free; runs 100% locally.
# terraform-docs Agent Rules - Prefer `terraform-docs json .` when inspecting module variables and outputs. - Preview stdout before passing `--output-file README.md`. - Use `--output-check` in CI to detect drift without mutating files.
Agent-Ready Command Recipes
Safe Read-Only Queries
terraform-docs json .
Outputs inputs, outputs, providers, and module calls as structured JSON without modifying files.
terraform-docs markdown table .
Renders the module documentation table to stdout for inspection before writing to disk.
Controlled Writes & Previews
terraform-docs markdown table --output-file README.md --output-mode inject .
Updates only the delimited BEGIN_TF_DOCS section in README.md via --output-mode inject.
Strengths for Agents
- + Outputs complete module inputs, outputs, and resources via
terraform-docs json .. - + Runs completely offline with zero cloud credentials or Terraform state access.
- + Supports
--output-checkto verify doc freshness without modifying files.
Caveats & Pitfalls
- ! Passing
--output-filewithout--output-mode injectoverwrites the target file. - ! No
--jsonglobal flag syntax; JSON is selected as thejsonsubcommand.