- How you use it
- You ask for it
- What it can do
- writes files
- What's inside
The option
| Option | ASkill · v1.0.0terraform-style-guide skill (HashiCorp) |
|---|---|
| How you use it | You ask for it |
| What it can do | writes files |
| What's inside |
What this thread does
The problem
You ask an agent for "an RDS instance for my orders service" and get Terraform that validates and plans fine but has no encryption, no deletion protection or an open security group. You would like that caught before a PR, not after.
What the source says
An r/Terraform thread (5 September 2026, by u/Ano--05007, the author of a Checkov-based MCP server) announced a tool that scans Terraform while the agent writes it. The replies are more useful than the tool:
- Steering is not a guardrail. A commenter says prompts and instruction files are suggestions: what you trust the model to follow cannot also be the thing that verifies it; build the flow so the model cannot skip the controls.
- Existing deterministic checks already work. Another commenter says their process barely changed after adopting Claude Code: same Git hooks locally and same CI, because the checks humans need also work for agents. Another asks why spend model tokens when Trivy, Checkov, tfsec or OPA exist, and suggests pre-commit or an agent hook. A third prefers pre-commit with OPA policies that encode their own standards.
- The tool itself. The maker confirmed it wraps Checkov and adds compact findings, remediation snippets and templates; he also conceded that a hook gives the same scan-after-write behaviour.
A hook-based version
This is my sketch of the pattern the commenters describe; I have not run it. In Claude Code, a PostToolUse hook on Edit|Write receives the tool input as JSON on stdin; exiting with code 2 feeds stderr back to the agent. The hook script could be:
#!/bin/sh
f=$(jq -r '.tool_input.file_path // empty')
case "$f" in
*.tf) checkov -f "$f" --compact --quiet >&2 || exit 2 ;;
esac
Register it under hooks.PostToolUse with matcher Edit|Write in .claude/settings.json (check the current hooks docs for the exact shape), keep the same Checkov or Trivy run in pre-commit and CI so the check also fires when the agent is not involved, and store the script and config where the agent cannot edit them.
How to describe it to your agent
A hook runs Checkov after each.tfedit made throughEditorWrite. If it reports findings, fix them in the Terraform; do not addskipcomments or edit the hook or its config. If a finding is a deliberate exception, list it for me instead.
Mistakes to check
- Letting the agent add
#checkov:skipcomments to get green. - Running the scan only in CI: the agent then iterates through several failed pipelines.
- Treating a clean scan as "safe": scanners miss things (in a 6 September comment, the maker said Checkov missed a literal password and that he had added a check in his own tool).
- Putting baselines only in CLAUDE.md.
Limits
Not run by me. The hook is my sketch; the thread's evidence is practitioner opinion. A related thread covers policy checks on the plan JSON (OPA) and another covers what should hard-fail a pipeline.
Primary source
Primary sources: Claude Code hooks reference, Claude Code memory docs (Anthropic) and the Checkov suppression docs (Checkov, Prisma Cloud). Checked: PostToolUse accepts a matcher such as Edit|Write; the tool has already run, so exit code 2 cannot block it but shows stderr to Claude; the settings.json hooks shape (event, matcher group, handler list) matches the sketch; the memory docs say Claude treats CLAUDE.md as context, not enforced configuration, and recommend a PreToolUse hook to block an action; Checkov accepts inline checkov:skip=<id>:<reason> comments, which backs the "agent adds skip comments" warning. Read via the public RSS copy on 2026-11-14: the post and readable comments support the scan/fix loop, deterministic Git hooks and CI, OPA preference, Checkov engine and the maker's agreement that a PostToolUse hook supplies scan-while-writing behaviour. This comment list may be a subset. Re-read on 2026-11-14: the hooks and memory references; the PostToolUse input example includes tool_input.file_path. The Checkov CLI reference confirms --compact and --quiet. The hook remains an unrun sketch.
Started from a post by @Ano--05007, packaged by the editor. Original post
- 01 · YouPaste the line from Try it into your agent.
- 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
- 03 · YouApprove a one-line report. Nothing is posted without you.