Secure the Terraform Claude Code writes
In our June 2026 study (one model, measured on engine v0.5.1, not re-run since), the gaps in AI-written AWS config were cross-resource and operational, exactly the kind a single-file review misses. Give Claude Code the audytx MCP server and one standing instruction, and the agent that wrote the Terraform reads its own AWS security findings before the pull request exists.
The agent that wrote it is the fastest reviewer
Static scanners run after the code lands. When the author is an agent, you can move the review left of the pull request entirely: the same session that generated the Terraform scans it, reads the findings, and fixes them before a human ever sees a diff. That only works if the findings are precise — an agent drowning in false positives will "fix" benign code and churn. audytx's cross-resource context is what keeps the signal clean enough to hand an agent.
Our June 2026 study scanned Terraform written by one model (Claude Opus 4.8). It was measured on engine v0.5.1 and has not been re-run on the current engine, so read its numbers on that page, with their date, and not as current figures.
Two steps
-
Register the MCP server
Get a free Client ID from the dashboard (the plaintext UUID is shown once), then add the server:
claude mcp add --transport http audytx https://audytx.com/mcp \ --header "X-Client-ID: YOUR_CLIENT_ID"
That's the standard remote-HTTP MCP registration. audytx exposes
scan_terraform,autofix_terraform,scan_cloudformation, and the rest of the tool list; discovery is open, andtools/callis authenticated by the Client ID you just passed. -
Give Claude Code a standing instruction
Claude Code reads
CLAUDE.mdat the repo root automatically. Add a line so it scans without being asked every time:# CLAUDE.md Before opening a pull request that touches .tf files, call audytx scan_terraform on the full set of Terraform files in the repo — not just the diff; cross-resource reasoning needs the unchanged files too. Fix every High and Critical finding, then re-scan. For the mechanical ones, autofix_terraform applies the sound fixes and re-scans in one pass.
Pass the complete file set, not only the changed files — audytx builds IAM trust graphs, attack paths, and DLQ-identity edges across resources, and it can't reason about a file you withhold.
The gaps a single-file review can't see
These are the patterns our June 2026 study found one frontier model ship by default — the reason this setup earns its place:
- Secrets Manager rotation. The model creates an
aws_secretsmanager_secretfor a database password but never the companionaws_secretsmanager_secret_rotation. A pattern matcher flags the secret for a missing attribute; audytx finds the absent companion resource and fires with a rationale that names it. - IAM privilege-escalation paths. A role that can
iam:PassRoleinto a compute service it also controls is an escalation even when every individual statement looks scoped. audytx traces the documented paths across the trust graph. - Async wiring without alarms. The model reaches for dead-letter queues but forgets to alarm on them; it enables encryption but omits rotation. Reliability and observability gaps dominate the count; outright security holes are rare.
The suppressions matter just as much — the false positives audytx removes so the agent doesn't chase them: a DLQ that isn't asked to have its own DLQ, a Lambda flagged for a missing DLQ when nothing invokes it asynchronously, an IAM role that reads privileged but can't escalate. Each suppression is printed with its reasoning, so the agent (and you) can check the call.
Same engine on every other surface
The MCP loop is the pre-PR half. For the review half, install the GitHub App — it posts a summary comment on the pull request with the same findings, inline annotations, and SARIF to GitHub Code Scanning, so anything the agent missed still gets caught on the PR. Building CloudFormation instead of Terraform? The same agent loop works with scan_cloudformation — same rule ids, same context.
Common questions
Does audytx store the Terraform Claude Code sends it?
Not the files themselves: files sent to scan_terraform are parsed in memory and discarded when the response returns. audytx does keep a record of each finding (rule, message, resource, file and lines) for 90 days, then deletes it. File contents are never part of that record.
Is this free?
Yes. The Free plan includes 100 scans per month for your account, shared across all your Client IDs. The GitHub App has its own Free allowance for each installation. Each accepted scan uses one credit; non-scan helpers are free, and scans audytx fails to complete are refunded asynchronously. A scan that skips a file it cannot read and analyses the rest is a completed scan. No credit card.
Why scan the whole repo instead of just the files Claude Code changed?
Because the highest-value findings are cross-resource. Whether a Lambda needs a dead-letter queue depends on what invokes it; whether an IAM role can escalate depends on the roles it can assume. Those edges live in files the current change may not touch. audytx scans everything you send it; you can then filter the report to the files you changed.
How is this different from Checkov or tfsec running in the same repo?
Those tools mainly check one resource at a time, so a resource missing an attribute is flagged whether or not other resources make it harmless. audytx also looks at how resources relate and shows the reason when it holds a finding back. For an agent, that means less false-positive churn in the fix loop.
Close the loop in your next Claude Code session
Register the MCP server, add the CLAUDE.md line, and let the agent review its own Terraform. The Free plan includes 100 scans a month.