Input
- Terraform
.tf/.tfvarsfiles and PR context or file diffs (required) - Validation output from the companion
terraform-validationreport or CI (optional): used to skip tool-detectable checks
Output Specification
Return structured Markdown in accordance with references/common-output-format.md. That file is the source of truth for the output contract.
Each issue must include file path with line reference (<path>#L<line>), risk summary, and remediation guidance.
Execution Scope
- Apply review checklist from references/common-checklist.md
- Do not modify Terraform files or approve/merge PRs
- Scope includes Terraform only; Terragrunt files are out of scope.
- Scope assumes a single repository context.
- Scope is provider-agnostic unless a referenced checklist item states provider-specific constraints.
USE FOR:
- reviewing Terraform PRs for security, architecture, and module design issues
- reviewing whole stacks or modules (no diff) for missing configuration, asymmetric settings, and failure paths that no one is notified about
- assessing cross-module risks and environment-specific concerns in Terraform changes
DO NOT USE FOR:
- executing validation tools (
terraform fmt,terraform validate,tflint,trivy) - implementing new Terraform resources as code changes
Reference Files Guide
- common-checklist.md (always read)
- common-output-format.md (always read)
- common-troubleshooting.md (read on failure)
- category-global.md (always read)
- category-security.md (always read)
- category-modules.md (always read)
- category-state.md (always read)
- category-config.md (always read)
- category-integration.md (always read)
- category-testing.md (always read)
- category-ci-lint.md (always read)
- category-compliance.md (always read)
- category-cost.md (always read)
- category-data-sources.md (always read)
- category-dependency.md (always read)
- category-migration.md (always read)
- category-naming.md (always read)
- category-ordering.md (always read)
- category-outputs.md (always read)
- category-patterns.md (always read)
- category-performance.md (always read)
- category-tagging.md (always read)
- category-tfvars.md (always read)
- category-variables.md (always read)
- category-versioning.md (always read)
- category-anti-patterns.md (always read)
Workflow
- Read PR context and module scope. If PR context is unavailable, review file diffs only and defer PR-context-dependent checks.
- If changed files contain no
.tfor.tfvars, setStatus: skippedin## Checks Summarywith reasonno Terraform review target. - Scope findings to changed files and hunks. Report violations in unchanged code outside the diff only under
## Expert Assessment, not## Issues. For ad-hoc file review without a diff, treat the whole file as in scope. - Exclude generated files and vendored third-party code (for example
.terraform/directories and.terraform.lock.hcl) from primary findings unless they introduce security-critical risk. - For very large PRs (>50 changed Terraform files), prioritize security/correctness checks first and defer low-risk style checks if evidence is insufficient.
- When validation output (companion
terraform-validationreport or equivalent CI results) is supplied, do not re-report failures those tools detect: take the overlapping ItemID's status from the tool result, cite the tool, and spend the review on judgment checks. Category items with a validationNote:name the known overlaps. - Apply the full review checklist and collect failed/deferred items. For
CFG-*checks, also look for what is missing per category-config.md. - For every finding, search the repository for sibling occurrences of the same pattern (including the mirrored side of paired modules or stacks) and fill
Siblings(none foundwhen empty). - Before judging any resource or module call (arguments, defaults, required permissions, service behavior), read its documentation at the version pinned in the code, such as the Terraform Registry page for the provider resource or module. Do not decide from memory. When the documentation cannot be read, defer the check or report the claim under
Unverified; never state it as fact. - If a referenced category file is missing, defer affected checks with the missing file path.
- Output required sections per references/common-output-format.md. Prioritize
SEC-*findings first, then correctness, then maintainability. For conflicting findings, prioritize the higher-severity category and document the conflict in## Issues.
Error Handling
| Condition | Severity | Action |
| ---------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------- |
| common-checklist.md unavailable | Fatal | Stop; report missing dependency |
| common-output-format.md unavailable | Recoverable | Note missing file; emit ## Checks Summary, ## Checks (Failed/Deferred Only), and ## Issues only |
| Changed files contain no .tf/.tfvars | Recoverable | Set Status: skipped in ## Checks Summary; reason no Terraform review target |
| Referenced category file missing | Recoverable | Defer affected checks; note missing file path |
Examples
- Prompt:
Review this Terraform PR and return failed/deferred checks only - Result: Structured report per references/common-output-format.md; do not run validators.
- Prompt:
Review this Terraform PR for security and module design - Result: Same output contract; evaluate from
.tfsource and PR context only — do not execute validator commands.