InfraDots logo
Documentation

Review & implement locally

Run the InfraDots review and implement agents on your own machine. It is free, needs no InfraDots account, and nothing is sent to InfraDots. Only the model calls leave your machine.

Prerequisites

  1. The idp CLI. Download the archive for your platform from the releases page and put idp on your PATH.
  2. Docker. The CLI runs the public image public.ecr.aws/e5i7i1j1/idp-agent. Without Docker, use --native with an installed idp-agent.
  3. A model. Set ANTHROPIC_API_KEY, or set MODEL_PROVIDER=bedrock|vertex|foundry with MODEL_MAP and that provider's credentials.

Review

idp agent review --offline            # current directory
idp agent review --offline ./infra    # a path

The review covers everything since the branch left the base branch, committed or not, including new files. The repository is mounted read-only.

OptionMeaning
--base BRANCHBranch to compare against. Default: the remote's default branch
--plan FILEA plan to review alongside the code
--guidance FILETeam guidance file. Default: .infradots/guidance.md if present
--instructions "focus on IAM"Extra focus for this review
--modelModel to use
--iac terraform|tofuWhich tool runs the fmt check. It uses terraform/tofu from your PATH and is skipped if missing
-f jsonJSON output
--nativeRun idp-agent directly instead of Docker
--imageUse a different agent image
--dry-runShow what would run without running it

Exit codes: 0 approved, 1 changes requested, 2 error.

Reviewing a plan

terraform plan -out tfplan
terraform show -json tfplan > plan.json
idp agent review --offline --plan plan.json

--plan accepts the JSON from terraform show -json, or the text output of terraform plan. The streaming terraform plan -json log is refused.

In CI

idp agent review --offline --base origin/main -f json > review.json

The exit code fails the job when the agent requests changes (1) or errors (2). The review needs the base branch's history to find where your branch left it, so check out the full history (for example fetch-depth: 0 with actions/checkout).

As a pre-push hook

Each review calls the model, so run it before you push rather than on every commit. Save this as .git/hooks/pre-push and make it executable:

#!/bin/sh
idp agent review --offline || exit 1

Team guidance

Put your team's standards in .infradots/guidance.md in the repository, or pass another file with --guidance. This file is used by offline reviews only. Reviews on the platform use your organization's reviewer guidance.

Implement

idp agent implement --offline "add a lifecycle rule that expires logs after 90 days" ./infra

The request must be an infrastructure-code request. It first passes an input gate, and anything else is declined. The agent works in a git worktree on a new branch idp-agent/<timestamp>-<random>, cut from your last commit. Your checkout and uncommitted work are untouched, and uncommitted changes are not on the branch. It commits as you (your git user.name and user.email, without running hooks or signing) and never pushes.

OptionMeaning
--patchInclude the full diff in the report
-f jsonJSON output
--model, --iac, --native, --image, --dry-runSame as for review

The report lists the commits, a diffstat and the commands to:

  • review: git diff BASE...BRANCH
  • try: git switch BRANCH
  • discard: git branch -D BRANCH

If nothing changed, no branch is left. Exit codes: 0 a branch was made, 1 nothing changed (or not an infrastructure request), 2 error.

What the agents look up

Agents check the public Terraform and OpenTofu registries for the newest provider and module versions and for a resource's reference (arguments, attributes, examples). With --iac tofu, the OpenTofu registry is asked first. This needs outbound HTTPS to registry.terraform.io and api.opentofu.org.

Docker or --native

By default the CLI runs the agent in the idp-agent Docker image (Docker Desktop, Colima and OrbStack all work), with the repository mounted read-only for a review and read-write for an implementation, which commits its branch to it. Use --native to run an idp-agent installed on your machine instead, or --image to pick a specific image.

Troubleshooting

SymptomFix
Exit code 2 with a message about a missing keySet ANTHROPIC_API_KEY, or MODEL_PROVIDER with MODEL_MAP and credentials
Docker not foundInstall and start Docker, or use --native
Plan file refusedUse terraform show -json tfplan, not the streaming terraform plan -json log
Registry access blockedThe agent says the lookup failed and carries on without it

Next steps