plansift
Exact, local review of OpenTofu and Terraform plans before apply, as three
Hermes tools.
tofu plan / terraform plan is the last chance to see that a change will
destroy a database, replace every instance in a module or quietly drop a
bucket. On real infrastructure the plan is thousands of resources and
megabytes of JSON, far too much to put in a model's context, and the
dangerous line is easy to miss in the human-readable output. plansift reads the
plan's JSON on disk and returns exact answers: what is deleted or replaced
and why, which attribute forces each replacement, what changed outside the
tool, and whether the plan passes the rules you set.
It reads the JSON of a saved plan:
tofu plan -out=plan.tfplan # or: terraform plan -out=plan.tfplan
tofu show -json plan.tfplan > plan.json # or: terraform show -json plan.tfplan > plan.json
plansift never runs tofu or terraform itself. A saved binary plan or the
event stream of plan -json is recognised and refused with the command that
converts it, and a state file (show -json without a plan) is refused too.
UTF-16 files, which Windows PowerShell 5.1's > writes, are read like UTF-8 ones.
Why a tool and not a prompt or skill
-
Exact counts and nothing missed. Every delete, replace and forget is
listed, with the plan's own reason (replace_because_cannot_update,
replace_because_tainted,delete_because_each_key, ...) in plain words,
the replacement order (destroy before create, or create before destroy) and
the attributes that force it. Real output on OpenTofu'srequires-replacefixture:{"address": "test_instance.test", "action": "replace", "order": "destroy_before_create", "reason": "replace_because_cannot_update", "why": "an attribute that cannot be changed in place changed", "forced_by": ["ami"]} -
Attribute-level diffs a model can read.
before -> afterper changed
attribute,(known after apply)for unknown values, and a
forces_replacementflag on the attribute that causes the replacement. JSON
documents stored in strings (IAM policies, task definitions) are diffed
inside, so one added action shows aspolicy (json) Statement[0].Action[1]
rather than two 2 KB strings. -
Secrets stay out of the context. Values the provider marks sensitive are
replaced by(sensitive value), before or after the change, at any depth. As a
second line of defence, text under attribute names that look like secrets
(password,secret,token,private_key,api_key,access_key,
credential,connection_string, ...) is replaced by
(redacted: secret-like attribute name)even when the provider did not mark
it. Numbers and booleans under such names stay visible
(get_password_data = false). The same applies inside JSON documents stored
in strings and to the HCL generated for imports. Input variable values and output
values are never returned (outputs by name and action only), and a set element
in a replacement path is shown as[…], not by its value. -
A deterministic gate.
tf_plan_checkturns "don't let the agent destroy
production" into a rule that returnspassed: falsewith each violation.
Tools
All three always return a JSON string. A bad path or a file that is not a plan
returns { "ok": false, "error": "..." } rather than raising. Each result
starts with file, format_version, version (the terraform_version
field, which OpenTofu also writes), errored, and complete, applyable and
timestamp when the plan has them.
Actions are create, update, replace, delete, forget (removed from
state and the real object kept), read (data sources) and no-op. import
and move are tags that combine with an action: an import is often a
no-op, and a move may be one as well. Unrecognised action lists from a newer
version are kept as other:<actions> and flagged, not dropped.
Address patterns (address, only, except): * matches any run of
characters, including dots and brackets; ? matches one character; everything
else is literal. So module.db.*, *aws_db_instance.* and
aws_instance.web[0] mean what they say. A pattern also matches a moved
resource's previous address.
tf_plan_summary
| arg | type | required | default | meaning |
|---|---|---|---|---|
path | string | yes | - | plan JSON file |
max_items | integer | no | 25 | entries per list (cap 500) |
top | integer | no | 10 | modules and resource types to rank (cap 100) |
Returns:
counts: per action, plusimportandmove.resources_changing.destructive: every delete, replace and forget, withreason,why,orderandforced_by.drift: resources changed or deleted outside OpenTofu/Terraform.affects_planis set when the plan lists which drift matters.outputs_changing: names, actions andsensitiveflags.checks: status counts, and failing checks with their messages.values_known_after_apply.by_moduleandby_type.variables: a count only.deferred_changes, when present.
tf_plan_changes
| arg | type | required | default | meaning |
|---|---|---|---|---|
path | string | yes | - | plan JSON file |
actions | string[] | no | all but no-op and read | only these actions/tags |
address | string[] | no | - | only addresses matching one of these patterns |
source | string | no | changes | drift lists changes made outside the tool instead |
max_attributes | integer | no | 50 | changed attributes per resource (cap 500) |
offset | integer | no | 0 | matching resources to skip |
limit | integer | no | 20 | resources to return (cap 200) |
Each change has address, action, type and the same fields as the summary,
plus moved_from, import_id and generated_config (for imports, first 2,000
chars) when present. It also has attributes: [{path, before, after, forces_replacement?}]. Deletes and forgets carry a note instead of an attribute
dump. Values longer than 300 characters are cut, with the remaining length
noted. next_offset is present when more results remain.
tf_plan_check
| arg | type | required | default | meaning |
|---|---|---|---|---|
path | string | yes | - | plan JSON file |
deny | string[] | no | ["delete","replace","forget"] | actions/tags that fail the gate ([] = none) |
only | string[] | no | all | apply deny only to matching addresses |
except | string[] | no | - | never apply deny to matching addresses |
max_changes | integer | no | no limit | fail when more resources would change |
fail_on_drift | boolean | no | false | fail on changes made outside the tool |
fail_on_failed_checks | boolean | no | true | fail on failed or errored checks and conditions |
Returns passed, violation_count, violations (the first 200; each has a
rule: denied_action, max_changes, drift, check_failed or
plan_errored), the rules applied and how many changes were evaluated.
An errored plan is always a violation.
Example: block any destroy or replacement in the database module, but allow
everything elsewhere:
{"path": "plan.json", "only": ["module.database.*"]}
Safety
- Read-only. It reads only the plan file you pass, and only if it is a regular
file of at most 128 MiB. - No network, no credentials, no subprocess (it never runs
tofuor
terraform), no background work, no self-update. Standard library only. - Honours Hermes' core read denylist (credential stores, project
.envfiles,
NT/device namespace paths). The path is checked as given and as an absolute
path before anything is opened. Device, fd and/procpaths are refused,
including through symlinks. - Sensitive values, text under secret-like names, the plan's
variablessection and
output values are not returned. Everything else is returned as the plan shows
it, just astofu showwould. That includes ordinary attributes with ordinary names,
YAML in strings (e.g. Helmvalues), check failure messages (which
OpenTofu/Terraform already refuse to build from sensitive values) and the
instance keys in addresses (aws_iam_user.u["alice"]). A secret a provider stores
in one of those will therefore be visible.
Compatibility
Plan JSON format_version 0.1 through 1.2, from Terraform 0.12 to 1.15 and
OpenTofu. A newer format_version is read on a best-effort basis and noted
in the result.
Install
hermes plugins install rodricksz4h5/plansift --enable
License
MIT
README from the reviewed commit efb8865; it updates when the author re-pins.

rodricksz4h5