Regenerate a Terraform module's README.md by running `terraform-docs .` in the module directory, injecting the generated block between the BEGIN_TF_DOCS/END_TF_DOCS markers from the main.tf header comment, footer.md, and the module's variables, outputs, providers and resources. Use this skill whenever someone mentions terraform-docs, .terraform-docs.yml, "update/regenerate the Terraform README", BEGIN_TF_DOCS markers, a README that is out of date with the .tf files, "the docs table is missing a variable", "my header isn't showing up", "footer.md isn't being picked up", or when new variables, outputs or resources have been added to a Terraform module and the docs need to catch up. Also use it when setting up terraform-docs in a module that does not have it yet, since the config, footer and main.tf header block all have to exist before the first run works.
Ships in terraform-docs-readme. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
terraform-docs . reads .terraform-docs.yml, assembles a markdown block from four
sources, and injects it into README.md between the BEGIN_TF_DOCS and
END_TF_DOCS comments:
| Part of the block | Comes from |
|---|---|
| Narrative header — title, diagrams, tables | the leading /** */ comment in main.tf |
| Requirements, Providers, Inputs, Outputs, Resources | parsing every .tf file in the directory |
| Support / authorship footer | footer.md |
| Section order | the content template in .terraform-docs.yml |
Everything outside the markers is hand-written and terraform-docs never touches it. That is where prerequisites, common commands and CI/CD notes belong.
The golden rule: never hand-edit inside the markers. It looks like a normal
README and it is not — the next run overwrites it without warning. To change the
prose, diagrams or tables in the generated section, edit the /** */ block at the
top of main.tf and re-run.
The working directory is the user's Terraform repo, not this skill's folder, so
every scripts/ and assets/ path below is relative to the skill directory and must
be resolved before use. Set it once at the start of a session:
# personal install
SKILL_DIR=~/.claude/skills/terraform-docs-readme
# or, project install
SKILL_DIR=$(git rev-parse --show-toplevel)/.claude/skills/terraform-docs-readme
# Windows PowerShell
$SkillDir = "$env:USERPROFILE\.claude\skills\terraform-docs-readme"
If neither path exists, locate SKILL.md for this skill before running anything —
never guess a path and never fall back to a bare relative scripts/..., which
silently resolves against the user's repo and fails with a confusing "no such file".
On Windows the interpreter is usually py -3 or python, not python3. Check with
py -3 --version before assuming.
python3 "$SKILL_DIR/scripts/tfdocs_preflight.py" <module-dir>
Stdlib-only, cross-platform, changes nothing. It reports whether the binary exists,
whether its version satisfies both the .tool-versions pin and the minimum the config
actually requires, whether every file the config points at is present, and whether the
README has the markers. Exit 1 means at least one blocking problem.
Work through whatever it flags before running terraform-docs. The failures it catches are the ones that otherwise produce a successful-looking run with wrong output.
If the binary is missing, ask before installing. Show the options for their
platform, let them choose, run only that. Full commands and package IDs are in
$SKILL_DIR/references/install.md — read it rather than reciting from memory, the winget and
Chocolatey IDs differ in case and the pip package does not exist.
Short version: asdf install when the repo has a .tool-versions (preferred — it
matches whatever is already pinned), winget install --id Terraform-docs.Terraform-docs --exact or choco install terraform-docs on Windows,
Homebrew or a direct binary download on Linux/macOS.
Install and run the version the repo pins. If the pin is too old for the config, stop and tell the user — do not quietly install something newer. Bumping the pin is a repo change that affects every developer and the pipeline, so it needs their decision, and the fix is usually two lines:
terraform-docs 0.20.0 # in .tool-versions
asdf install
Version drift is worth checking even when everything appears fine. A pin of 0.14.1
alongside a config using footer-from means the docs are being generated by an
unpinned binary someone has on PATH, which is how two developers end up producing
different READMEs from the same source.
For a module that has never had terraform-docs, copy from assets/ and adapt:
Copy from $SKILL_DIR/assets/, not from a bare assets/:
cp "$SKILL_DIR/assets/terraform-docs.yml" .terraform-docs.yml
cp "$SKILL_DIR/assets/footer.md" footer.md
| Asset | Copy to | Notes |
|---|---|---|
assets/terraform-docs.yml | .terraform-docs.yml (module root) | Note the leading dot |
assets/footer.md | footer.md | Replace the team email, author and date |
assets/main.tf.header.example | top of main.tf | Must be the first thing in the file |
assets/README.skeleton.md | README.md | Only if there is no README at all |
The assets are deliberately minimal and generic. Every value in them is a stand-in —
replace all of it with the real module's title, accounts, DNS names and contacts. Do
not leave "Example Module Name" or example.com in a committed file.
The placeholders avoid <angle brackets> on purpose. With settings.html: true a
renderer can treat <TEAM_EMAIL> as an HTML tag and swallow it, so the placeholder
disappears instead of standing out as obviously unfilled.
For an existing README that has content but no markers, add them where the generated block should go rather than letting terraform-docs append (see gotcha 4).
From the module directory:
cd path/to/terraform
terraform-docs .
The bare command works because .terraform-docs.yml supplies formatter and
output.file. Running from anywhere else picks up a different config or none at all —
cd first, or pass -c path/to/.terraform-docs.yml.
git diff -- README.md
Check three things: the header changes are the ones intended, no hand-written content
above the markers moved, and new variables actually appear in the Inputs table. A
variable that is missing was almost certainly added to a file terraform-docs did not
scan — it reads the given directory only, not subdirectories, unless recursive is on.
terraform-docs extracts the header from a leading /** */ block and stops looking as
soon as it hits a terraform, provider, resource, variable or module
declaration. A block placed after any of those yields an empty header and a
successful exit code — the README just quietly loses its entire narrative section.
This is the most common cause of "my header isn't showing up".
Two features in the standard config are not available earlier: footer-from, and
.Module inside content (used by the hand-rolled Resources loop that prints
file#line positions). Against an older binary this fails or silently drops
sections. The preflight script computes the minimum from the config and compares.
If README.md is CRLF, terraform-docs writes the injected block with LF, leaving
one file with two line-ending styles. Verified behaviour, not a theory: a CRLF README
comes back with the hand-written half CRLF and the generated half LF. With
core.autocrlf=true this shows up as phantom whole-file diffs and noisy reviews.
Fix it once at the repo level rather than fighting it per-run:
*.tf text eol=lf
*.md text eol=lf
Then normalise the existing files (git add --renormalize .) and commit that
separately from a docs regeneration, so the two changes stay reviewable.
In inject mode with no BEGIN_TF_DOCS/END_TF_DOCS in the target file,
terraform-docs appends the generated block, with markers, to the end of the file
and exits 0. Nothing is lost, but the generated docs land underneath the hand-written
prose instead of wherever they were meant to go. Add the markers deliberately before
the first run.
output.mode: replace is a different thing entirely — it overwrites the whole file.
Do not switch a README with hand-written content to replace.
settings.escape: true renders valid_user_list as valid\_user\_list in the
output. That is correct markdown escaping, it displays fine, and it is not a diff to
"fix" — reverting it by hand just gets overwritten next run.
When content is set, it fully controls what appears and in what order. A section
listed in sections.show but absent from the content template is not rendered.
If a section has gone missing, check the template before checking the show-list.
modulesrecursive.enabled: true with path: "." is a misconfiguration — it makes
terraform-docs walk the module's own directory as if it were a submodule tree. Leave
recursive disabled unless there is a real modules/ directory, and set path
to that directory.
A mermaid fenced block in the main.tf header renders on GitHub and GitLab. It does
not render on Bitbucket Cloud, which shows the raw source.
If the repo lives in Bitbucket and diagrams need to display, the fix belongs in
main.tf, not in the README: pre-render the diagram to a committed SVG and put an
image reference in the header comment. Rewriting the README's generated block to point
at an SVG works exactly once — the next terraform-docs . throws it away. See the
mermaid-svg-bitbucket skill, and run it with --no-rewrite against a sidecar .mmd
so nothing tries to edit inside the markers.
terraform-docs --output-check . compares the current README against what would be
generated, prints README.md is out of date and exits 1 if they differ, and writes
nothing. Useful for confirming a README is current before opening a PR:
terraform-docs --output-check .
This is also the command to reach for if the repo later wants a CI gate or a pre-commit hook — it needs no credentials and cannot loop.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/terraform-docs-readme:terraform-docs-readmefrom terraform-docs-readme
npx claudepluginhub mbadali25/useful-claude-add-ons --plugin terraform-docs-readme