Secure the Terraform Cursor writes
Cursor writes solid Terraform. In our study, AI-generated AWS config tracked hand-written modules on nearly every metric; the misses were the cross-resource kind — a secret whose rotation never gets wired up, an IAM role that can escalate through a chain no single file shows. Two small config files give Cursor a way to catch those itself, before the pull request.
Fix it in the session that wrote it
The appeal of scanning inside Cursor rather than in CI is that the fix is one turn away: the agent generates the Terraform, reads the findings, and corrects them before a reviewer ever opens the diff. It cuts both ways, though. Hand the agent a report full of false positives and it will happily "fix" code that was never broken. The findings audytx returns have already been checked against the resource graph, so the ones Cursor sees are worth acting on.
terraform validate — often an invented security argumentNumbers from the audytx AI-generated Terraform study.
Two steps
-
Add audytx to
.cursor/mcp.jsonGet a free Client ID, then add a project-level
.cursor/mcp.json(or~/.cursor/mcp.jsonto make it global). Cursor interpolates${env:…}, so the ID can live in your environment instead of the committed file:.cursor/mcp.json{ "mcpServers": { "audytx": { "url": "https://audytx.com/mcp", "headers": { "X-Client-ID": "${env:AUDYTX_CLIENT_ID}" } } } }This is a remote HTTP MCP server — no local process to run. Cursor picks up
scan_terraform,autofix_terraform,scan_cloudformation, and the rest on the next reload. -
Add an always-on project rule
Cursor reads
.cursor/rules/*.mdcfiles, which carry frontmatter that controls when they apply. AnalwaysApplyrule makes the scan standing policy, not something you re-ask each time:.cursor/rules/audytx-terraform.mdc--- description: Scan Terraform with audytx before a PR alwaysApply: true --- When a change touches Terraform, call the audytx scan_terraform tool on the full set of .tf files in the repo — not just the diff, because cross-resource reasoning needs the unchanged files too. Fix every High and Critical finding and re-scan. Use autofix_terraform for the mechanical ones: it applies the sound fixes and re-scans in one pass.
Prefer a single plain file? Cursor also reads an
AGENTS.mdat the project root — put the same instruction there.
The gaps a single-file review can't see
What you can expect it to catch — the patterns our study found models ship by default:
- Secrets Manager rotation. A secret gets created for a database password, but never the companion
aws_secretsmanager_secret_rotation. audytx finds the missing resource across the plan, not just a missing attribute on one. - IAM privilege-escalation paths.
iam:PassRoleinto a compute service the same principal controls is an escalation even when each statement reads scoped. audytx walks the documented paths across the trust graph. - Invented security arguments. Models reach for a knob that doesn't exist —
require_tls,require_ssl, a fused RDS argument — and the config failsterraform validate. Scanning surfaces the real attribute to set.
And the suppressions that keep the agent from chasing ghosts — a DLQ not asked to have its own DLQ, a role that reads privileged but can't escalate — each printed with its reasoning so the call is visible, not silent.
Same engine on every other surface
The MCP loop covers pre-PR. For the review itself, install the GitHub App — one comment per pull request, inline annotations, SARIF to GitHub Code Scanning — so anything the agent misses is still caught on the PR. Writing CloudFormation? The same loop works with scan_cloudformation, same rule ids and context.
Common questions
Where does the Client ID live so it isn't committed?
Cursor expands ${env:AUDYTX_CLIENT_ID} from your shell environment, so the .cursor/mcp.json in the repo holds only the reference — the secret stays in your environment. Set AUDYTX_CLIENT_ID in your shell profile or your machine's environment.
Does audytx store the Terraform Cursor sends it?
No. Files are parsed in memory and discarded when the response returns — the same posture as the GitHub App path. Only aggregate scan metadata is recorded, never file contents.
What's the difference between an .mdc rule and AGENTS.md?
Both give Cursor standing instructions. A .cursor/rules/*.mdc file carries frontmatter (description, globs, alwaysApply) that controls exactly when the rule applies — useful if you want it to fire only on Terraform paths. AGENTS.md is a plain markdown file at the project root with no metadata, applied more broadly. Either works for the audytx instruction.
How is this different from Checkov or tfsec in the same repo?
Those are single-resource pattern matchers — they flag a resource for a missing attribute regardless of whether context makes it benign. audytx pre-computes relationship graphs and suppresses findings context proves harmless, with the rationale shown. For an agent, that precision is a clean fix loop instead of false-positive churn. See the benchmark comparison.
Close the loop in your next Cursor session
Add the .cursor/mcp.json entry and the project rule, and let Cursor review its own Terraform — free during the beta.