CLI commands
Optional: hand this page to your coding agentThe steps work by hand too.Show the whole prompt
Read https://intentius.io/terragucci/reference/cli/.
Run `npx terragucci config check` and `npx terragucci init --dry-run --json` in this repo and tell me the roots, binary and forge it found, and any config problem, with the exit code of each.
Read only. Never apply, approve (a pull request review or `terragucci approve`), override a policy denial (`terragucci override`), use `--mode apply`, or merge; never touch `.chant/allowed_signers` or `chant/lifecycle`.Run npx terragucci <command> from a repo’s root; a generated pipeline calls the same commands.
| Command | Does |
|---|---|
init |
finds roots, binary and forge, and writes the pipeline and terragucci.components.json; under approval: sealed, also chant.workspace.json |
import |
writes terragucci.yml from an atlantis.yaml, a digger.yml or a Terragrunt Scale .gruntwork, or from the workspaces of HCP Terraform, OTF or Scalr, and prints what became of each setting |
reconcile |
from a control repo, opens a pull request in each project that needs a change |
generate |
writes each root’s backend, provider and version files from the generate key, and in a Terragrunt repo terragucci.hcl, which each unit includes; --check refuses one that differs, and the generated tf-check job runs it |
estate |
writes one page for every project, estate.html, estate.json, dora.json and policy-metrics.json, to the reports bucket, and prints a link to it: presigned on S3, a signed URL on GCS, a SAS on Azure Blob |
audit |
appends every approval, apply, policy override and refused wave across the projects to the audit trail, audit.jsonl in the reports bucket, with its page and a link to it, and every state version no wave or migration wrote; --check reports what the record lacks |
plan |
plans every root and prints the result |
stage tf-plan |
plans the roots a change reaches, groups them, and writes the report |
run wave |
one job of a chant Op waves pipeline: chant’s run wave in terragucci’s words, with the root hooks, the report and the spec’s hooks in the job’s process |
waves-spec |
prints the tf-apply waves spec at a commit, its rules read from terragucci.yml there |
ci |
writes .chant/pipeline.ts from promotion, environments and waves in terragucci.yml, and the environments’ config and secret sets into chant.workspace.json; --check exits 1 while either differs |
reject |
turns down the release a stage’s gate waits on: chant’s reject |
pause, resume |
stop releases entering a stage, and let them in again: chant’s stage pause and stage resume |
publish |
publishes each changed module at a new version |
verify-release |
checks one published version of a module: its signature, provenance and SBOM, and its record in the release ledger |
modules |
lists the modules in a registry’s release catalog, and with show one module’s versions, status and consumers; deprecate, yank and restore mark a version on the release ledger |
templates |
lists the templates in the release catalog: each with the versions a request may name, their attestation, kind and form fields; with apps, the apps made from them; read only |
request |
opens a pull request that adds an app’s root from a template (the module call, and the files generate writes for it), or with --app one add-on’s module call in an app’s root |
rollout |
moves a module’s or provider’s pin one wave at a time |
pin |
rewrites each module call’s (modules) or provider entry’s (providers) version constraint to the exact version its root runs, as a rollout |
respond |
runs the response to a pipeline event |
comment |
reads a /terragucci plan [root] or /terragucci agent <ask> pull request comment, polls GitLab merge request notes, and pushes an agent’s change; the generated pipeline runs it |
pr-lock |
takes or releases a pull request’s plan locks under locks: plan; the generated pipeline runs it |
approve |
approves a waiting wave: finds it on chant/lifecycle, prints what it does and records an approval of its digest, with --sign under approval: sealed; also approves a migration, a state export, a lock release and a pull request environment; a person runs it |
override |
overrides a policy denial of one root’s plan: finds the denial a tf-apply wave recorded, checks the rules named are the ones that denied it, and records the override with the reason; a person policy.override lists runs it |
approval-status |
with approval: pr-review, posts terragucci/approval on a pull request’s head: pending while a wave the gate will hold has no approving review of that head; the generated pipeline runs it |
post |
sets a commit status, posts or edits the plan note, replies, or marks plan notes stale; the generated pipeline’s jobs run it |
plan-note |
on GitHub and Forgejo, posts the plan job’s note and terragucci/plan from its report, read as data; the generated plan-note and replan-note jobs run it |
notify |
posts a wave that waits, is refused or fails to the Slack, Teams and generic webhooks notify names, and drift to Slack and Teams; the generated drift job runs it |
relay |
serves the Approve and Decline buttons of Slack and Teams messages, in your own cloud |
query |
runs one SQL statement over the inventory, versions, changes, history, audit trail and state edges in the reports bucket, on your machine, and prints the rows |
mcp |
an MCP server on stdio over what terragucci wrote to the reports bucket and the repo, for a coding agent; read-only, and with --propose it also pushes a branch, opens a pull request, requests an app from a template and reads the plan |
guard |
writes wrappers for the binaries and a Claude Code hook that refuse an apply in a root of the pipeline, for a coding agent’s shell |
view |
runs behold on your machine over the repo and its reports bucket: the roots as one graph, each resource marked with what the newest runs found; --export writes a static copy |
drift-agent |
writes the drift agent’s prompt and opens a pull request with its change, with agent.drift |
config check |
validates the config file and lists every problem, then prints the approval mode in force and where it comes from; with oidc.roles, the state each role reaches, and a warning for each role that reaches another environment’s state; config check tips after ok |
config identities |
per environment and stage, prints the roots, the runner, the forge environment, the cloud identities, the OIDC subject and audience each job presents, and the trust each cloud needs to accept that job |
forge check |
compares what config identities expects with the live forge environments, runners, protections and variables and each cloud’s trust, reading only, and exits 1 on a mismatch; a person or a scheduled job of the team’s own runs it |
state export |
asks for one version of a root’s state and, once someone else approved the request, downloads it to your machine and records who exported what on chant/lifecycle; a person runs it |
check-root, check-pins, check-policy, check-sources, check-mirror |
the steps of tf-check beyond the format check; the generated pipeline runs them |
image recipe |
writes a Dockerfile, CLI config and build script for an image FROM terragucci’s that carries every provider the lock files pin; you build and push it |
registry edge |
writes the edge function for modules.registry, with its deploy config, so Terraform installs from a bucket-hosted registry; you deploy it |
check-job |
the first line of an environment’s apply job: stops the job unless it runs in the environment’s forge environment, on a branch it applies from and on its runner; the generated pipeline runs it |
ephemeral |
applies a pull request’s copy of the ephemeral roots, destroys it on close, and sweeps the copies whose TTL passed; the generated pipeline runs it |
unlock-state |
releases a root’s state lock a killed job left, once no run that may hold it is alive and an approval of its lock ID stands, and records the release; a person runs it |
auth-provider |
internal: Terragrunt’s auth-provider-cmd, which the generated Terragrunt pipeline runs |
terramate generate |
internal: fails on stale Terramate generated code (terramate generate --detailed-exit-code), then writes each stack’s order and inputs beside it; every job of the generated Terramate pipeline runs it first |
atmos write |
internal: writes each Atmos instance to <stack>/<component> from atmos describe stacks; every job of the generated Atmos pipeline runs it first |
profiles |
internal: prints the local stack profiles a config needs, aws and each project’s forge |
install |
fetches a release of OpenTofu, Terraform, Terragrunt, Atmos, choudoufu or Infracost, verified against its checksums |
terragucci init [--forge github|gitlab|forgejo] [--binary tofu|terraform|choudoufu] [--gate never|on-destructive|always] [--approval ledger|pr-review|sealed] [--signer <principal>] [--force] [--dry-run]| Flag | Meaning |
|---|---|
--forge |
the forge, when the remote cannot tell |
--binary |
the binary, when detection picks the wrong one: tofu, terraform or choudoufu |
--gate |
when a wave waits for an approval: never, on-destructive (the default) or always; on-destroy reads as on-destructive. init writes gate: into terragucci.yml and renders the pipeline with it |
--approval |
ledger, pr-review or sealed, when the config names no mode; see Approval modes |
--signer |
under approval: sealed, write the first line of .chant/allowed_signers for this principal from git config user.signingkey, when the file does not exist |
--dry-run |
compute everything and write nothing |
--force |
overwrite a pipeline file or terragucci.components.json terragucci did not write; on GitLab that is .gitlab/terragucci.yml, never your .gitlab-ci.yml. With --gate, replace a different gate: in the config |
A flag detection would not reach goes into a new terragucci.yml. For --forge, --binary and --approval, an existing config file is never edited: init exits 1 and names the line to add, such as binary: terraform. A key already set there wins.
--gate is written even when it names the default, and it is the one flag init writes into an existing config:
terragucci.yml |
init --gate never |
|---|---|
| none | writes one with gate: never |
no gate key |
adds gate: never at the end and keeps the rest of the file |
gate: never |
leaves it as it is |
another gate, such as gate: always |
exits 1: --gate never differs from terragucci.yml, which sets gate: always; pass --force to write gate: never into it, or drop --gate |
another gate, with --force |
replaces the gate: line |
With --dry-run the config shows as would write terragucci.yml or would update terragucci.yml, and --json carries its new content. A terragucci.ts config is code, so init exits 1 and names the gate to set in it.
The approval mode decides what else init writes.
| Mode | init also |
|---|---|
ledger (the default) |
writes no chant.workspace.json; with approval: ledger set, drops the wave gates an earlier init listed under identity.gates |
pr-review |
the same as ledger; on GitHub and Forgejo adds the approval job and the terragucci/approval status (the pipeline) |
sealed |
writes chant.workspace.json with each wave’s gate (wave-1, wave-2) under identity.gates, so a wave counts only an approval sealed with terragucci approve --sign; an existing file gains missing gates |
Approve a waiting wave sets up the signers file.
chant.config.ts and the waves’ spec
Section titled “chant.config.ts and the waves’ spec”init also writes .chant/op-waves/tf-apply.spec.json in every repo, Terragrunt, Atmos and Terramate repos too. Each wave job renders its rules with waves-spec from that file and terragucci.yml at base, and takes the runs from the commit it applies. In a repo of plain roots, init also writes chant.config.ts at the repo’s root, which names each root under terraform.roots, keyed by its path. Commit these with the pipeline. init replaces a chant.config.ts only when terragucci wrote it; it leaves your own and says so. Run init again after you add or move a root. A wave job runs the binary terraform.binary names there; when a root plans with another one, the wave plans and applies it through terragucci’s own calls and the job says why.
The promotion components
Section titled “The promotion components”With promotion set, init also writes terragucci.component.ts at the repo’s root and lists the environments in that order under environments in chant.config.ts, with lexicons: ["terraform"]. The file holds each root of those environments as a chant component that applies the root of the environment chant deploys. init writes .chant/pipeline.ts beside it, as ci does, and each environment whose gate is not never is approved once, at its stage’s gate there. When .chant/pipeline.ts is the repo’s own, init keeps it and gives the components a gate named after each such environment. init replaces the components file only when terragucci wrote it, and removes it when promotion is taken out. Promote a release through environments says how components are named.
The components file
Section titled “The components file”init also writes terragucci.components.json at the repo’s root, beside the pipeline. It lists the repo’s roots as chant components, with their waves and the pipeline’s jobs that apply them. The pipeline does not read it, and the workflow is the same with or without it. init writes it again on every run and replaces it only when generated_by names terragucci, unless you pass --force.
| Field | Holds |
|---|---|
schema |
terragucci.components/v1 |
generated_by |
terragucci and the release that wrote it |
roots |
each root by name, as reports and waves name it, with dir, its directory in the repo; an Atmos instance’s dir is its component’s |
components |
one per root: name, dependsOn, and deploy, one Apply phase with a terraform-apply step for the root. The step’s noRollback says why it has no rollback: the pipeline applies the root, a failed wave leaves what applied, and a re-run finishes it |
pipeline.path, pipeline.forge |
the pipeline file and its forge |
pipeline.jobs |
each job that applies roots, named as in the pipeline, with its needs, its wave, and applies, the roots it applies |
A root’s dependsOn is the roots it must follow: those whose state it reads, those waves.after puts before it, or in a Terragrunt, Atmos or Terramate repo the order that tool gives. When that order alone would group the roots into other waves than the pipeline’s, as waves.canary does, each root also depends on every root of the wave before its own. Grouping the components by dependsOn then gives the pipeline’s waves.
In pipeline.jobs, a wave split by waves.jobs or by environment has a job that decides the wave and applies no root, and a job per share or group that lists its own roots. apply-done and apply-rest apply none. In a Terragrunt repo, the share jobs’ roots are the layer’s units as init found them; the stage cuts them again when it runs. With apply.when: pull-request, the list holds each wave’s applying job, apply-wave-<k>, which applies the wave of the decided head.
The agent jobs refuse a change to the file.
import
Section titled “import”terragucci import atlantis [<file>] [--forge github|gitlab|forgejo] [--apply-when merge|pull-request] [--force] [--dry-run]
terragucci import digger [<file>] [--forge github|gitlab|forgejo] [--apply-when merge|pull-request] [--force] [--dry-run]
terragucci import spacelift [<file>] [--forge github|gitlab|forgejo] [--apply-when merge|pull-request] [--force] [--dry-run]
terragucci import env0 [<file>] [--forge github|gitlab|forgejo] [--apply-when merge|pull-request] [--force] [--dry-run]
terragucci import terragrunt-scale [<dir>] [--force] [--dry-run]Reads the file named, else atlantis.yaml (or atlantis.yml), or OpenTaco’s digger.yml (or digger.yaml), and writes terragucci.yml by the tables of Use terragucci with Atlantis or OpenTaco. Each setting the file carries is printed under one of four headings, quoting the guide’s row:
| Heading | The setting |
|---|---|
| Written to terragucci.yml | became a key, such as a project’s dir in roots |
| Done by terragucci with no key | needs no key, such as autoplan.when_modified |
| Not mapped | has no key here, with the guide’s reason; so does a setting the guide has no row for |
| Left out on purpose | is something terragucci never does, such as an import workflow, with the guide’s rule and what to do instead |
| Flag | Meaning |
|---|---|
--apply-when |
pull-request (the default, as Atlantis and OpenTaco apply before merge) or merge; a digger.yml whose on_commit_to_default runs digger apply already means merge |
--forge |
the forge, when the remote cannot tell; on GitLab the import keeps apply.when: merge and writes no locks: plan, and on Forgejo no apply.merge: auto, since those need a schedule or a token it cannot name |
--dry-run |
print what would be written, and write nothing |
--force |
replace an existing terragucci.yml |
It exits 1 when the file is missing or not YAML, or when terragucci.yml exists and --force is not given. A project dir that matches no directory with Terraform files is written and named.
Run init next to write the pipeline.
import terragrunt-scale reads .gruntwork (or the directory named) and each unit’s gruntwork.hcl, and writes each environment’s plan and apply roles as terragrunt.credentials (Terragrunt Scale). It exits 1 on a repo with no Terragrunt or a legacy config.yml.
import spacelift reads .spacelift/config.yml (or the file named) and every spacelift_* resource in the repo’s .tf files; import env0 reads env0-discovery.yml (or the file named), each env0.yml custom flow and every env0_* resource. Either runs on the admin code alone when the file is missing. They map by the concepts table of Use terragucci with Spacelift or env zero, keep apply.when: merge unless --apply-when says otherwise, since both platforms apply a tracked branch after a push, and name each stack or environment whose state the platform manages.
From a platform’s workspaces
Section titled “From a platform’s workspaces”terragucci import hcp [--hostname <host>] --organization <org> [--repo owner/name] [--forge github|gitlab|forgejo] [--force] [--dry-run]
terragucci import otf --hostname <host> --organization <org> [--repo owner/name] [--forge github|gitlab|forgejo] [--force] [--dry-run]
terragucci import scalr --hostname <account>.scalr.io [--environment <name or ID>] [--repo owner/name] [--forge github|gitlab|forgejo] [--force] [--dry-run]Reads the workspaces over the platform’s API, with the token in TF_TOKEN_<host> or credentials.tfrc.json (for Scalr, also SCALR_TOKEN), and writes terragucci.yml and a terraform.tfvars in each root that has none, by Use terragucci with HCP Terraform, Scalr or OTF. It only reads: no workspace, variable or run changes. A sensitive variable’s value is never read; its name goes under pass.secrets.
| Flag | Meaning |
|---|---|
--hostname |
the platform’s host; app.terraform.io for hcp when not given |
--organization |
the organization whose workspaces are read (hcp, otf) |
--environment |
one Scalr environment, by name or ID; every one the token sees when not given |
--repo |
this repo as the platform’s VCS connection names it; the origin remote’s owner/name when not given |
--forge |
the forge, when the remote cannot tell; on GitLab the secrets are listed as masked CI/CD variables to create, with no pass |
--dry-run, --force |
as above |
It exits 1 when the host refuses the token or names no TFE API, and, before it reads anything, when terragucci.yml exists and --force is not given.
reconcile
Section titled “reconcile”terragucci reconcile [--config <file>] [--mode dry-run|apply] [--project <host/path>]--config defaults to the config file in the working directory and --mode to dry-run. --mode apply opens a pull request per changed project and never runs terraform apply (glossary). --project limits the run to one project.
generate
Section titled “generate”terragucci generate [--check] [--dry-run] [--config <file>]From terragucci.yml’s generate key it writes backend.tf, providers.tf and versions.tf in each root and removes generated files the key no longer asks for. It never overwrites a file it did not write, and refuses a Terragrunt repo. --dry-run prints what it would write. --check writes nothing and fails on each generated file that differs from what it would write, is missing, or is no longer asked for, with the lines that differ. See Generate backend and provider files.
estate
Section titled “estate”terragucci estate [--config <file>] [--out <dir>] [--link-hours <n>]
[--bucket <url>] [--bucket-endpoint <url>] [--bucket-prefix <p>]| Flag | Meaning |
|---|---|
--config |
the config file; default the one in the working directory |
--out |
where the page is written locally; default terragucci-estate |
--link-hours |
how long the link lives; default 24, at most 168 |
--bucket, --bucket-endpoint, --bucket-prefix |
the bucket to read and write (s3://<bucket>, gs://<bucket> or az://<account>/<container>), in place of reports in a repo’s config |
estate |
|
|---|---|
| Reads | each project’s index.json, inventory.json, versions.json, changes.json and states.json; audit.jsonl and audit.json when the audit trail is there, for the approvers and each root’s unrecorded writes |
| Writes | estate.html, estate.json, dora.json and policy-metrics.json at the top of the prefix; history.html and history.json once an apply changed a resource, with each apply’s approver from audit.jsonl |
| Projects | in a control repo, its projects:, each read from its own reports, the page written to defaults.reports; in a repo of its own, the ones the top index.json lists |
| Also | links the audit trail when audit.json is beside the page; computes the delivery metrics and sends them as gauges when an OTLP endpoint is set |
| Exit 1 | a project’s index could not be read; the page names it |
terragucci audit [--check] [--config <file>] [--out <dir>] [--link-hours <n>]
[--bucket <url>] [--bucket-endpoint <url>] [--bucket-prefix <p>]| Flag | Meaning |
|---|---|
--check |
build the entries again and compare them with the record; write nothing; exit code 1 naming each entry the record lacks |
--config |
the config file; default the one in the working directory |
--out |
where the record, page and summary are written locally; default terragucci-audit |
--link-hours |
how long the link to audit.html lives; default 24, at most 168 |
--bucket, --bucket-endpoint, --bucket-prefix |
the bucket to read and write, in place of reports in a repo’s config |
audit |
|
|---|---|
| Reads | each project’s chant/lifecycle history, its tf-apply wave reports and its states.json; the list of versions each root’s state store keeps (ids and times, never a state); with audit_log_group, the CloudWatch Logs group that names who wrote a version |
| Writes | the entries audit.jsonl lacks, appended, and audit.html and audit.json beside it at the top of the prefix |
| Projects | in a control repo, its projects:, each ledger fetched from the project’s repo and its reports read from its own reports, the record written to defaults.reports; in a repo of its own, the checkout’s, its ledger read from origin |
| Exit 1 | a project’s ledger, index or states.json could not be read, or with --check the record lacks an entry. A root whose state’s versions could not be listed is named in the log and on the page, and does not fail the run |
The audit trail describes every entry.
plan and stage
Section titled “plan and stage”terragucci plan [--root <glob>] [--project <host/path>] [--config <file>]
terragucci stage tf-plan [--root <glob>] [--project <host/path>] [--config <file>] [--out <dir>]
[--report-url <url>] [--layers <a,b;c>] [--binary <b>] [--canary <globs>] [--bucket <url>]
[--bucket-endpoint <url>] [--bucket-prefix <p>] [--bucket-url <url>] [--terragrunt] [--base <ref>] [--forge github|forgejo|gitlab] [--parallelism <n>] [--no-cost]
terragucci stage tf-drift [the same flags as tf-plan]
terragucci stage tf-apply --wave <n> --layers <a,b;c> [--canary <globs>] [--binary <b>]
[--gate always|on-destructive|never] [--approval ledger|pr-review|sealed] [--config <file>] [--parallelism <n>] [--terragrunt [--rest]] [--base <ref>]
[--shares <n> [--share <s>] [--decided <file>]] [--branches <branch>=<globs>[;...] [--branch <name>]]
[--groups <group>=<globs>[;...] [--group <name>]] [--on-held wait|refuse] [--stand-down] [--after <dir>]| Flag | Environment | Meaning |
|---|---|---|
--root |
plan only the roots matching this glob | |
--project |
the project, as <host>/<path>, for a run from a control repo |
|
--config |
the config file, when it is not at the repo root | |
--out |
where stage writes the report; default terragucci-report/ |
|
--report-url |
where the note links the HTML report; a URL that is not an .html file is read as the run’s page |
|
--layers, --binary, --canary, --bucket |
roots in apply order (layers split by ;), binary, canary wave and bucket; each overrides terragucci.yml |
|
--bucket-endpoint, --bucket-prefix, --bucket-url |
the store’s endpoint, the key prefix, and the address that serves the bucket to a browser | |
--terragrunt |
run Terragrunt units, one run --all per wave; tf-apply applies each unit’s saved plan |
|
--no-cost |
leave out the cost estimate cost asks for; the confirm job passes it |
|
--rest |
tf-apply --terragrunt only: run this wave, then each wave after it, stopping at the first that does not apply |
|
--base |
TG_BASE |
the ref a change is measured against, such as origin/main; default is the pull request’s target branch |
--forge |
github, forgejo or gitlab, when the environment cannot tell; the plan note keeps to its comment limit, and tf-drift files its issue there |
|
--parallelism |
roots run at once per dependency layer (tf-plan, tf-drift) or wave (tf-apply); overrides parallelism in terragucci.yml; 1 is serial. The roots’ inits take turns on the provider cache |
Both stage tf-plan and stage tf-drift write the report even when a root refuses to plan. The plan report lists the files.
stage tf-apply applies one wave. The generated apply-wave-<n> jobs no longer run it: they run run wave, which hands chant what this command runs a wave with. Wave 1 first runs each state migration that has not applied, behind its own gate, and stage tf-plan proves them. It refuses --json with exit 1. With TG_OUTCOME_JSON set it writes the wave’s outcome to that file as JSON.
| Flag | Environment | Meaning |
|---|---|---|
--wave |
the wave to apply | |
--gate |
always, on-destructive (the default) or never; a wave takes the stricter of it and the top-level gate in the config at base, and under never refuses to apply when that config cannot be read |
|
--approval |
the mode when the config at base names none and chant.workspace.json there lists no gate; a control repo’s pipeline passes it |
|
--base |
TG_BASE, for the policy ref only |
the ref that holds the wave’s policy, approval mode, gate rule, signers file and other config; an open pull request’s job passes origin/<default branch>. Without it the gate rule comes from the commit before the one applied |
--shares |
waves.jobs: split the wave’s roots into up to this many shares. Without --share the stage plans every root, decides the gate, writes each root’s plan digest to terragucci-wave/wave-<n>.json and applies nothing |
|
--share |
with --shares: plan this share’s roots and apply each one whose plan has the digest in the decision file; exit 4 when one moved, which is not applied |
|
--decided |
the decision file, when it is not terragucci-wave/wave-<n>.json |
|
--groups |
one apply job per identity, as prod=envs/prod/**;dev=envs/dev/**: each group’s root globs or roots, and default for the roots none matches. Without --group the stage plans every root with the job’s identities, decides the gate, writes the decision file and applies nothing. Plain roots only |
|
--group |
with --groups: plan this group’s roots of the wave (with --shares, its --share) and apply each one whose plan has the digest in the decision file; a group with no root in the wave applies nothing |
|
--branches |
apply.branches as release=envs/prod/*,envs/dr/*;staging=envs/staging/*: the stage applies only the roots (in a Terragrunt repo, the units) of --branch when the map names it, and otherwise every root no branch’s glob matches |
|
--branch |
with --branches: the branch the push applies; unset means the default branch |
|
--on-held |
TG_LOCK_POLL |
with binary: choudoufu, when another run’s apply holds a resource the wave changes: wait (the default) polls every TG_LOCK_POLL seconds (10) for up to an hour, then plans again; refuse exits 5 naming that run, as the apply a comment starts does |
--stand-down |
a push’s wave: once it may apply, it applies nothing and exits 6 if a newer push is on its branch, which applies the whole tree | |
--after |
plain roots: the directory holding the earlier waves’ report artifacts (terragucci-earlier in a pipeline). The stage writes each root’s outcome beside its report, plans none of the roots an upstream that did not apply holds, applies the rest, and exits 1, or 3 when every root held waits for an approval |
publish
Section titled “publish”terragucci publish [--dry-run] [--config <file>]--dry-run lists what would be published and pushes nothing. A git tag that exists with the same content is unchanged and exits 0.
verify-release
Section titled “verify-release”terragucci verify-release <module> <version> [--config <file>]Run in the repo that publishes, with modules.attest set. For each target in modules.publish it reads the tag as it stands now and checks that the release ledger on origin records those bytes from the tag’s commit. The public key must verify the release’s signature, provenance and SBOM. It prints one line per target and exits 1 when any is refused.
modules
Section titled “modules”terragucci modules [list | show <module>] [--registry <url>] [--json] [--config <file>]Reads the release catalog publish writes under catalog/ beside modules.registry, or with --registry another registry’s. A registry in a dir is read from the directory; any other through its URL, with the token Terraform would send the host (TF_TOKEN_<host> or a credentials block), so a registry behind auth: token answers. list, the default, prints one line per module: its address and newest active version, then a count of its deprecated and yanked versions. show <module> takes the module’s path, its last path segment or its registry address, and prints each version newest first with its status and reason, date, commit, attestation and consumers. --json prints the catalog, or the one module, as the envelope’s results.
terragucci modules deprecate|yank|restore <module> <version> [--reason <text>] [--use <version>] [--config <file>]Run in the repo that publishes. The status record for the version goes on chant/lifecycle, and the release catalog is written again after the push. deprecate and yank need --reason; --use names a recorded version to move to. Roots on a deprecated version get a tip. modules.require: attested refuses a yanked one, though it stays installable until restore clears the mark. See Deprecate or yank a version.
terragucci modules adopt <dir> [--source <address>] [--version <v>] [--root <dir>] [--dry-run] [--mode dry-run|apply] [--config <file>]Moves a module kept in the repository and called by relative path to the source it is published at, as a rollout from (local) to the published version. Each wave rewrites the source of its roots’ calls of <dir>, and the plan of each shows no changes. The module has to be published already: --source names where (git::<url>//<dir>, oci://<host>/<repository> or a registry address, with no pin) and defaults to modules.publish or modules.registry, and --version defaults to the newest release. --dry-run lists the callers and the waves and asks no forge. The guide has the rest.
terragucci modules consumers [--check] [--config <file>]Writes consumers.json at the repo’s top: each registry module version the roots pin, and where, in chant’s consumers document. A publishing repo across the control repo joins it into its catalog. --check writes nothing and exits 1 when the file is missing or no longer matches the roots. The check job of a repo with control runs it, and it passes with a note on a chant that has no consumer scan.
templates
Section titled “templates”terragucci templates [list | show <template>] [--registry <url>] [--json] [--config <file>]
terragucci templates apps [--template <t>] [--ref <ref>] [--registry <url>] [--json] [--config <file>]Reads the release catalog of templates.registry, else of modules.registry, or with --registry another registry’s, as modules does. A template is a module whose release has a template.yml beside its code, which publish copies into the version’s catalog entry. list, the default, prints each template with a version a request may name: active, and signed or verified, or with templates.require: any unsigned too. show <template> takes its address without the host (acme/bucket/aws), its full address, its path or its last path segment, and prints its versions and its form fields: each input’s name, kind, label, default, whether it is required and whether it is sensitive. --json prints the list, or the one template, as the envelope’s results.
apps lists the apps under templates.apps: each directory there whose root has a module "app" call. It reads the checkout, or with --ref that commit’s files, so --ref origin/main reads the default branch. Each app has its root, the template and version its module "app" calls, its addons (each module "<name>" in an addon-<name>.tf file, with its name, template and version) and its actions: each action block the app’s module and its add-ons’ modules declare, with its module, type, name and its address in the app’s root, such as module.app.action.aws_lambda_invoke.rotate. publish lists a module’s action blocks in the version’s catalog entry; with no catalog, or a version published without the list, actions is empty. --template keeps the apps on that template, as their own or an add-on’s.
From the catalog, an app or add-on also has upgrade, the newest active version above its version that templates.require lets a request name, so never an unsigned one under signed (null when there is none), which rollout moves it to. yanked is true when the catalog marks its version as yanked.
{"app":"orders","root":"apps/orders","template":"acme/bucket/aws","version":"1.2.0","upgrade":"1.3.0","yanked":false,"addons":[{"name":"cache","template":"acme/cache/aws","version":"0.3.0","upgrade":null,"yanked":false}],"actions":[{"module":"app","type":"aws_lambda_invoke","name":"rotate","address":"module.app.action.aws_lambda_invoke.rotate"}]}request
Section titled “request”terragucci request <template> --name <app> [--app <app>] [--version <v>] [--input <k>=<v>]... [--inputs-file <f.json>] [--via form|mcp|cli] [--requested-by <who>] [--claimed-by <who>] [--registry <url>] [--dry-run] [--json] [--config <file>]Builds a template request for the app --name, checks it against the catalog and the version’s template.yml, and opens one pull request on request/<template>/<app> from the default branch. The branch adds the app’s root at templates.apps with {name} filled in: main.tf with one module "app" call pinned to the version, and the backend, provider and version files generate writes for the root. The branch is pushed without force, and a branch that already has an open pull request returns that one with existing: true. The pull request’s title is Request: <app> from <template> <version>, and its body holds the request as a fenced json block.
With --app <app>, the template must be an add-on template (kind: addon in its template.yml) and --name names the add-on. The branch is request/<template>/<app>/<addon>, and it adds one file to the app’s root on the default branch: addon-<addon>.tf, with one module "<addon>" call pinned to the version. An input given as app.<output> becomes module.app.<output>, a reference to an output of the app’s own module, as the catalog lists them for the version the app calls. The app and its add-ons are one root, so they plan and apply together. The title is Request: <addon> for <app> from <template> <version>.
--version defaults to the newest version templates list shows. --inputs-file holds the inputs as one JSON object; each --input <k>=<v> goes over it, its value read as JSON unless the input is a string. A sensitive input is never given: the root declares it as a sensitive variable, which the app sets from its own secret store. --via says where the request came from (default cli; the request workflow passes form), and --requested-by who asked (default the CI run’s actor, else git config user.email). --claimed-by names the person a client says asked, such as the person signed in to a form; the forge does not vouch for it, so the request carries it as claimedBy beside requestedBy, and the audit entry as claimed_by. --dry-run prints the branch and the files and pushes nothing. The pull request is opened with TG_TOKEN, else token_env’s variable.
A refusal exits 1, pushes nothing, and with --json puts its code and every refusal in results: unknown-version, not-active (deprecated or yanked), unsigned (below templates.require), unknown-input, missing-input, sensitive-input, input-type, bad-name, not-a-template (the version has no template.yml), not-a-root (the app’s path matches none of roots), app-exists (the app’s directory is on the default branch), wrong-kind (an add-on template without --app, or an app template with it), not-an-app (--app names no root with a module "app" call on the default branch), unknown-output (an app.<output> the app’s module does not have) and addon-exists (the app’s root already has addon-<addon>.tf or a module of that name). Each opened pull request is a request entry in the audit trail. The command needs a chant with template requests, and on an older one it exits 1 and names it.
With templates set, init writes the request workflow, .github/workflows/terragucci-request.yml (.forgejo/workflows/ on Forgejo). It runs on workflow_dispatch with the inputs template, version (empty for the newest), name, inputs (a JSON object, default {}), app (for an add-on, the app it goes into) and claimed_by (optional), and runs terragucci request --via form with the actor who dispatched it as the requester and claimed_by as --claimed-by. A form dispatches it by that file name. It pushes and opens with token_env’s secret when the config names one, since GitHub starts no workflow for a pull request the job’s own token opens.
rollout
Section titled “rollout”terragucci rollout <module> [<version>] [--from <version>] [--mode dry-run|apply] [--config <file>]
terragucci rollout --provider <address> <version> [--from <version>] [--mode dry-run|apply]--mode defaults to dry-run, and neither mode runs terraform apply. See Rolling out a module version.
A template is named by its address without the host, such as acme/bucket/aws. With templates set, a template’s rollout names apps. Wave 1’s pull request is titled like Upgrade bucket to 1.3.0: orders (wave 1 of 2), and its body adds the catalog’s changelog entries after the old pin. Under templates.require: signed a rollout to a version the catalog lists unsigned exits 1, and with no version named the rollout takes the newest signed active one. An app on a yanked version below the new one moves from that version, in the first wave after the canaries.
terragucci pin modules [--providers] [--root <dir>] [--dry-run] [--mode dry-run|apply] [--no-init] [--lookup] [--config <file>]
terragucci pin providers [--root <dir>] [--dry-run] [--mode dry-run|apply] [--no-init] [--lookup] [--config <file>]A rollout moves an exact pin and refuses a constraint such as version = "~> 5.0". pin is the step before it: it reads each root’s module calls (modules) and required_providers entries (providers, or modules --providers for both) whose version is a constraint or is missing, finds the version the root runs, and opens the change as a rollout whose from is the constraint ((none) when there is no version) and whose to is that version. A pin that equals the version already in use changes nothing, so each wave’s plan shows no changes.
The version comes from what init left in the root: .terraform/modules/modules.json for a module call, .terraform.lock.hcl for a provider. Without it, init -backend=false runs in the root (--no-init skips it), and then, with --lookup, the newest release the constraint allows in the module or provider registry. The version has to satisfy the constraint it replaces, or the entry is listed as unresolved. Roots that run different versions under one constraint become separate rollouts, each limited to its own roots, and terragucci respond rollout continues each one.
The edit rewrites only the version literal, or adds a version = "..." line after the source line, and re-reads the file to confirm nothing else changed. An entry it cannot edit that way is listed as unpinned with the reason: a version written as an expression, or a source that shares its line with other text such as tls = { source = "hashicorp/tls" }. A root with any such call of a module or provider is left out of that module’s or provider’s rollout.
--dry-run prints the table (root, call, module or provider, constraint, resolved version) and plans no waves. Without it the command also plans the waves, as rollout does in --mode dry-run, and --mode apply opens the next wave’s pull requests. Only roots are read, so a constraint in a reusable module stays as written, and a control repository is refused, since the versions come from one checkout’s init state.
The rollout workflow that init writes for rollouts is .github/workflows/terragucci-rollout.yml, or the same name under .forgejo/workflows/. Its workflow_dispatch takes the optional inputs module and version. Dispatched with module, it runs terragucci rollout <module> [<version>] --mode apply, where exit 3 does not fail the job. On its schedule it runs terragucci respond rollout --mode apply.
terragucci fmt [--binary <b>] [--terragrunt]Formats the working tree and commits nothing: the binary’s fmt -recursive ., and with --terragrunt also terragrunt hcl fmt. The pipeline’s fmt job is chant’s commit job, which runs this after a check finds formatting, then commits and pushes the change (respond.fmt). The job’s steps run as terragucci commit prepare|run|land, which chant answers.
respond
Section titled “respond”terragucci respond plan|wave-refused|apply-failed|drift|tips|publish|rollout|version-bump|description [--mode dry-run|apply] [flags]
terragucci respond rollout [--mode dry-run|apply]respond rollout with a module runs that rollout’s next step; without one it continues every rollout in flight and exits 1 only when one could not run.
| Flag | Used by | Meaning |
|---|---|---|
--mode |
all | dry-run (the default) or apply, which opens the pull request or pushes the commit and never runs terraform apply |
--report |
plan, description, tips |
the report directory; for tips, a stage tf-plan report whose plans’ renames get a moved block, and only those |
--approved, --current, --wave |
wave-refused |
the approved report, the current report directory and the wave number |
--log |
apply-failed |
the apply log; - reads standard input |
--root, --import |
drift |
one root, and <address>=<id> for a resource the state does not hold |
--platform |
tips |
lock file platforms, comma separated |
--branch |
tips |
with --report: the branch the moved blocks’ pull request goes into; default the default branch |
--module, --version |
publish |
the module, and the release |
--module, --since |
version-bump |
one module, and the ref to count changes from for a module with no release tag |
--title, --description |
description |
the pull request’s title and description; by default read from the job’s event |
--attributions |
drift |
the attributions tf-drift wrote, as a file; default terragucci-report/attributions.json |
--base |
wave-refused, apply-failed |
read settings from the config at this ref (such as origin/main), not the checkout; an unreadable base gives no response and a logged reason |
--out, --binary, --config, --project |
all | as above |
Responses to pipeline events explains each event. respond exits 0 once the event was handled, even when the response is off. The outcome is in the text, or in results with --json (the JSON output).
comment
Section titled “comment”terragucci comment --layers <a,b;c> --out <file> [--forge github|forgejo] [--agent off|on]
terragucci comment --agent run --out <file> --prompt <file> [--policy-dir <dir>] [--forge github|forgejo]
terragucci comment --agent push --change <dir> [--policy-dir <dir>]
terragucci comment --forge gitlab --poll --layers <a,b;c> [--when merge|pull-request] [--requires <list>|none] [--waves <n>]Reads the pull request comment in the event file (GITHUB_EVENT_PATH) and writes a decision to --out: plan, or stop with a reason. A refused command is answered on the pull request. --forge github (the default) asks the API for the commenter’s permission and --forge forgejo reads it from the event. The generated replan job is chant’s and decides with chant’s re-plan step, not this command; see Re-plan a pull request from a comment. /terragucci apply is read by apply-comment, chant’s comment job. Each --agent mode runs in its own job.
--agent |
Run by job | Does |
|---|---|---|
off (the default) |
none | replies with how to turn the agent comment on |
on |
none | leaves agent comments to the agent jobs |
run |
agent |
decides on a /terragucci agent <ask> comment with the same checks and writes the prompt to --prompt; a fork or default-branch pull request gets no agent |
push |
agent-push |
refuses the patch in --change when it touches a path an agent may not change, --policy-dir (default policy) among them, and commits a passing patch to the pull request’s head branch with the TG_* variables in Environment variables |
On GitLab, --forge gitlab --poll reads no event file; the generated comments job runs it on the comments schedule (comments). --waves is how many waves the pipeline has, the canary wave included; without it, one per layer. init writes it when the two differ.
| Poll | Does |
|---|---|
| Which notes | those of the merge requests updated in the last day |
Each /terragucci note |
answered once: the reply carries a <!-- terragucci:note=<id> --> marker, and a note with one is never answered again |
| Exit 1 | GitLab answered with an error |
| Note | Checked | Does |
|---|---|---|
| any | the author is a Developer or above; anyone else gets no reply | |
/terragucci plan [root] |
the merge request is open and from this project; a named root is a root of the pipeline | starts a merge request pipeline, which plans the whole merge request |
/terragucci apply |
the merge request merged into the default branch from this project; no later commit there has an apply of its own; no wave-<n> |
retries the merge commit’s first apply job that did not succeed; its gate decides again |
/terragucci apply [wave-<n>], with --when pull-request |
the merge request is open, from this project, into the default branch; then chant’s decision checks --requires (all four by default), terragucci/plan and the pipeline files at the head |
chant’s decision takes the locks of what the merge request reaches and records the decision on chant/lifecycle; then the poll starts the waves’ pipeline on the default branch with TG_MERGE_TOKEN and the variables CHANT_BEFORE_MERGE_PR, CHANT_BEFORE_MERGE_HEAD and CHANT_BEFORE_MERGE_DIGEST |
/terragucci lock, unlock, agent |
replies that the verb does not run here; with --when pull-request, that /terragucci apply takes the locks |
The generated pipeline lists the guarded paths, and When a comment runs nothing lists the checks every comment passes before a job uses a credential.
review
Section titled “review”terragucci review prompt --report <dir> [--instructions <path>]
terragucci review post --dir <dir>The review and review-note jobs of the generated review workflow run the two halves of the review.
| Command | Does |
|---|---|
review prompt |
reads the pull request from the event file (on a workflow_run event, the one pull request of the run’s head, with its title, description and base from the API); fetches the plan job’s report from the pipeline’s run of the head into --report, on a pull_request_target event waiting up to 30 minutes for the plan job; reads the diff of the base and head from git, and the plan note and policy results from the report; reads the instructions (--instructions, default .terragucci/review.md) from origin/<default branch> with git show, never from the checkout; writes the prompt to /tmp/terragucci-review/prompt.md, the pull request, head and base to /tmp/terragucci-review/out/reviewed.json, and unpacks the default branch’s files into /tmp/terragucci-review/work |
review post |
reads the review and its command’s exit code from --dir and posts them as one note on the pull request TG_PR names, with the head TG_SHA names; edits the note the pipeline posted before |
review prompt needs TG_TOKEN, a token that reads the repository’s runs and artifacts. Exit 2 means the event names no pull request, a workflow_run event was not started by a pull_request run or names no one pull request of its head, or the checkout has no default branch ref. review post always exits 0 and says why when the forge refuses the note.
pr-lock
Section titled “pr-lock”terragucci pr-lock --layers <a,b;c> [--forge github|forgejo] [--when merge|pull-request] [--terragrunt]Reads the event file (a pull_request_target event, or a /terragucci plan, lock or unlock comment) and takes or releases the pull request’s plan locks on chant/lifecycle. It posts terragucci/lock on the head and replies when another pull request holds a root. The generated pr-lock job runs it under locks: plan. With --when pull-request it answers no lock or unlock comment, since /terragucci apply takes the locks then; --terragrunt locks units.
terragucci post status <context> pending|success|failure <description>
terragucci post note <file>
terragucci post reply <text>
terragucci post stale <roots> <branch>| Command | What it does |
|---|---|
status |
sets a commit status on the job’s commit, linked to the run; on GitLab a pending status shows as running |
note |
posts the file as the plan note on TG_PR, or edits the plan note already there |
reply |
adds a comment terragucci: <text> on TG_PR |
stale |
adds a line to the plan note of every open pull request into <branch> that covers one of <roots> (comma-separated), saying the plan is stale |
It posts on the forge --forge or TG_FORGE names (default github), with TG_TOKEN when the job sets it, else GITHUB_TOKEN (on GitLab GITLAB_TOKEN, then CHANT_FORGE_TOKEN). The job’s commit is TG_SHA, else CHANT_CONTROL_SHA, GITHUB_SHA or CI_COMMIT_SHA. The generated pipeline’s jobs run it, and so does chant’s control step, which has only GITHUB_TOKEN and CHANT_CONTROL_SHA. terragucci post sent <context> prints 1 when the job’s commit already carries a successful status of that context, else 0. With no token it posts nothing. A post the forge refuses is printed, and the command still exits 0.
plan-handoff
Section titled “plan-handoff”terragucci plan-handoff --report <dir> [--env <env>] [--exit <code>]The plan job’s last line. It writes chant’s plan note hand-off, pr-plan-note.json, from the report stage tf-plan wrote in --report (default terragucci-report): the note, the counts as the terragucci/plan description, and the roots it covers as the note’s <!-- terragucci:plan roots=... --> line. --exit is the plan’s exit code: 0 hands off a success, any other a failure. It exits 1 when the report was not written, and writes nothing outside a pull request (TG_PR). chant’s plan-note job posts the hand-off.
plan-note
Section titled “plan-note”terragucci plan-note --forge github|forgejo --report <dir> --notices <file> [--agent-login <login>]| Flag | Meaning |
|---|---|
--forge |
github (the default) or forgejo |
--report |
the plan job’s report directory, read as data; default terragucci-report |
--notices |
the file chant’s note job adds under the note’s counts, one line each |
--agent-login |
the agent’s account, whose review never counts |
chant’s plan-note and replan-note jobs run it before they post: when a wave will wait for an approval, it writes the line naming whose review would not count. It always exits 0.
components
Section titled “components”terragucci components pr-post ...chant’s components commands in terragucci’s words. chant’s plan-note job runs pr-post, which posts the plan note and terragucci/plan from the plan job’s hand-off.
terragucci ci [--check] [--config <file>]Writes .chant/pipeline.ts with chant’s pipelineSource, one stage per environment of promotion (Stages). Each stage’s waves are the committed waves spec’s, cut to the environment’s roots, so run terragucci init first; init writes the same file. With --check it writes nothing and exits 1 when the committed file is missing or differs, printing the lines that differ. The environments’ config, secrets and imports, and config_sets, go to ci.environmentSets in chant.workspace.json the same way. With no promotion there is no pipeline file, and the command says so and exits 0.
terragucci ci check and terragucci ci evidence are the check job’s and the evidence jobs’ steps.
reject, pause and resume
Section titled “reject, pause and resume”terragucci reject <op> <gate> --plan <digest> --reason <text> [--sign [<key>]]
terragucci pause <env> --reason <text>
terragucci resume <env> --reason <text>reject turns down the release a stage’s gate waits on; --reason is one line, and --sign seals it. A /terragucci reject [--stage <stage>] <reason> comment does the same under the commenter’s forge identity where the stage’s approval mode takes one. pause stops releases entering the stage: a promote into it exits 3, and its release waits. resume lets releases in again, and the newest release that waited is the one that enters.
run wave
Section titled “run wave”terragucci run wave --spec <file> --wave <k> [--render-spec] [--base <ref>] [--phase plan|gate|apply|record]
[--decide | --share <i> | --group <name> [--share <i>]]
terragucci run wave <any other line of chant's run wave>chant’s run wave, run in terragucci’s process with terragucci’s words. It is the line each job of a chant Op waves pipeline runs when the pipeline names terragucci as its bin. The flags are chant’s, passed on as they are.
A wave job’s line, one with --spec and --wave, also hands chant what stage tf-apply runs a wave with: each root’s binary, environment, sources check and ci.hooks, the report rows, the cost, the policy and the holds, and the spec’s own hooks (migrations, migration gate and report), which run in the job’s own process. With --phase, the job is one of a split wave’s four:
--phase |
What terragucci adds | Report in terragucci-report/ |
|---|---|---|
| none | everything, in one job | the wave’s plans and what applied |
plan |
the root hooks, the after-plan hook and wave 1’s state migrations | the wave’s plans, with the wave’s state applying |
gate |
the gate’s report hook: the approve command of a waiting wave, a policy override that does not count |
none |
apply |
the root hooks around each apply | the plans chant applied, what applied, and the gate from chant’s decision file (.chant/op-waves/tf-apply/wave-<k>.json) |
record |
nothing: chant writes the run records | none |
With --render-spec, chant reads the spec that waves-spec prints at --base. With CHANT_WAVES_SPEC_RUNS=head as well, the job’s runs come from the spec waves-spec prints at HEAD with the base beside it, and the rules still from the one at --base: the wave then runs a composed run under waves.compose, and a wave whose every root an estate migration plans applies nothing. The spec’s hooks run in the job’s own process, by name; no hook calls back over a socket. Neither run wave nor stage tf-apply reads TG_TOKEN or TG_SHA in a wave job: the token is GITHUB_TOKEN (on GitLab GITLAB_TOKEN, then CHANT_FORGE_TOKEN) and the commit GITHUB_SHA or CI_COMMIT_SHA, else the checkout’s HEAD. The lines that run no wave job (--merge, --apply-status, --waves-outcome, --record-plans and --approval-status) take terragucci’s words alone. The exit code is chant’s, except that a wave terragucci’s own hooks stopped exits with their code, as in stage tf-apply. --json prints chant’s result.
waves-spec
Section titled “waves-spec”terragucci waves-spec [--at <rev>] [--spec <file>] [--config <file>] [--own-run-jobs <name,...>]| Flag | Environment | Meaning |
|---|---|---|
--at |
CHANT_WAVES_SPEC_AT |
the commit to read the spec at; default HEAD |
--spec |
CHANT_WAVES_SPEC_FILE |
the spec file; default .chant/op-waves/tf-apply.spec.json |
--config |
the config file, when it is not at the repo root | |
--own-run-jobs |
the jobs of the wave’s own run that the merge’s release cut counts, comma-separated; the workflow init writes names them |
Prints the tf-apply Op waves spec at a commit, which chant’s wave jobs read their rules from. Everything in it comes from that commit, never from the working tree. The waves, their roots, shares and job groups are the spec file init commits there. The rules are terragucci.yml there:
- each wave’s gate, the stricter of the spec’s and the top-level
gate, or withenvironmentsthe strictest of its roots’; - the approval mode,
approval_rulesand the agent’s account; apply.point,apply.branches(the job’s branch applies only its roots),apply.resumeandnotify.
With promotion, the last wave cuts the release after its apply, inside the run that applied it. Under release.green: forge-checks that cut counts the merge commit’s checks from other workflows and the jobs --own-run-jobs names: the workflow init writes names the check job and every wave job the last wave waits for, each of which must have passed.
Each root’s workspace and Atmos reads come from the checkout. Wave 1 always carries the state migration hooks, which find no migration and do nothing when the change has none. The spec carries chant’s spend rules (approvals.spend, remainder and spendStanding), so the rest of a stopped apply applies under its approval at the same commit.
chant sets CHANT_WAVES_SPEC_BASE to the base commit only when it renders a job’s own spec at the applied commit. With it, the runs are what the change reaches: under waves.compose, the roots it reaches run as one composed run in the earliest wave they are in, and a root a pending estate migration plans is left out of its wave until the migration applies. Without it the spec is as above.
A commit with no spec file prints nothing and exits 0. A commit the checkout lacks, or a config there that cannot be read, exits 1.
approval-status
Section titled “approval-status”terragucci approval-status [--forge github|forgejo] [--report <dir>]Sets terragucci/approval on the head TG_SHA and TG_PR name. The status stays pending while a wave the gate will hold has no approving review of that head. When an approval of the head did not count, the description gives each reason, such as wave 1 waits: carol asked for abc1234; another writer approves. With --report it reads the waves from that plan report; without it, from the head’s plan note. Under approval: pr-review the generated approval job runs it on each review; it always exits 0.
notify
Section titled “notify”terragucci notify waiting|refused|failed --wave <n> [--outcome <file>] [--outcome-json <file>] [--report <dir>]Sends one wave’s outcome to whichever of TERRAGUCCI_SLACK_WEBHOOK, TERRAGUCCI_TEAMS_WEBHOOK and TERRAGUCCI_WEBHOOK are set. The generic webhook gets a chant.notify/v1 event signed with TERRAGUCCI_WEBHOOK_KEY over <timestamp>.<body>, and nothing when the key is empty. The generated wave jobs do not run it: with notify set, run wave sends a wave’s outcome from the spec’s notify, which names the secrets as terragucci.yml gives them.
| Read from | For |
|---|---|
--outcome-json, the stage’s outcome (TG_OUTCOME_JSON) |
the wave’s roots, the digest and approve command of a waiting wave, the pull request to review under approval: pr-review, and the roots a refused or denied wave names |
--outcome, the stage’s TG_OUTCOME line |
the outcome line the message quotes |
--report (default terragucci-report) |
the project, the report’s link, and the wave’s roots when there is no outcome |
GITHUB_SERVER_URL, GITHUB_REPOSITORY and GITHUB_RUN_ID, or CI_JOB_URL |
the run’s link |
TERRAGUCCI_RELAY |
the relay a waiting wave’s Approve and Decline buttons (Slack) and reply (Teams) reach |
terragucci notify drift [--report <dir>]Posts to TERRAGUCCI_SLACK_WEBHOOK and TERRAGUCCI_TEAMS_WEBHOOK the drift job’s findings in --report (default terragucci-report): the roots found drifted and the roots that could not be refreshed. Its Re-plan button opens the page where a person reruns the drift check with their own login (the workflow’s Run workflow page on GitHub and Forgejo; the pipeline schedules on GitLab). With no drift and every root refreshed it posts nothing. The generic webhook gets no drift event. The generated drift job runs it when notify names slack or teams.
terragucci notify unrecorded [--audit <dir>]Posts to TERRAGUCCI_SLACK_WEBHOOK and TERRAGUCCI_TEAMS_WEBHOOK the unrecorded writes the last terragucci audit run added: each project, root, version, time and writer. It reads the files that run wrote in --audit (default terragucci-audit, the audit’s own --out), so run it after terragucci audit in the same job. A run that added none posts nothing. The generic webhook gets no event.
A webhook that answers a 5xx or does not answer within 10 seconds is tried twice more. One that still fails leaves a line in the log, and the command, which never prints a webhook’s address, exits 0.
terragucci relay [--port <n>]Serves POST /slack, POST /teams and GET /healthz, with its settings from the environment. On start it checks the token, and refuses one that can do more than approve. Approve from Slack and Teams sets it up.
| A request | The relay |
|---|---|
| whose signature does not verify, or a Slack one more than five minutes old | answers 401 and records nothing |
| from a chat user no line of the signers file on the default branch lists | answers in the thread that it refused, and records nothing |
Approve, for the digest a wave waits for, under approval: ledger or pr-review |
records the approval of that digest on chant/lifecycle as the person’s principal, relayedBy the relay, and says so in the thread |
| Approve, for a digest no wave waits for | records nothing, and names the digest waiting |
Approve, under approval: sealed |
records nothing: only the approver’s own key seals an approval |
| Decline | records nothing, and says in the thread who declined; the wave keeps waiting |
The relay runs until stopped, whatever error a request hits.
terragucci query <table> [--where <field><op><value>]... [--since <time>] [--at <rev>]
[--config <file>] [--json] [--bucket <url>] [--bucket-endpoint <url>] [--bucket-prefix <p>]Reads one table and prints the rows its filters keep. resources, snapshots, runs, gates, deploys, releases and cuts are read from the local chant/lifecycle branch, as chant ledger reads them. inventory, versions, changes, history, audit and edges are read from the reports bucket. Query the estate lists the tables and the filters.
terragucci query "<statement>", an SQL statement over the bucket’s tables, is deprecated. It still runs, on Node.js 22.13 or later, and prints a notice naming the table read to use.
| Flag | Meaning |
|---|---|
--where |
a clause <field><op><value>, with =, !=, <, <=, >, >= or ~; give it more than once and every clause must hold |
--since |
the rows from an ISO date or time on, or from a span back from now such as 7d |
--at |
a commit of chant/lifecycle to read the ledger tables at; the bucket’s tables refuse it |
--config |
the config file; default the one in the working directory |
--bucket, --bucket-endpoint, --bucket-prefix |
the bucket to read, in place of reports in a repo’s config |
--json |
the envelope, with the table read in results (JSON output) |
query |
|
|---|---|
| Reads | each project’s inventory.json, versions.json, changes.json and edges.json, and audit.jsonl |
| Projects | as estate: a control repo’s projects:, with audit.jsonl from defaults.reports; otherwise the ones the top index.json lists |
| Refuses | a statement that does not begin with SELECT, WITH or VALUES, and any write |
terragucci mcp [--config <file>] [--bucket <url>] [--bucket-endpoint <url>] [--bucket-prefix <p>] [--propose]Serves the Model Context Protocol on stdin and stdout until the client closes them, for an agent that reads the estate while it works. It reads the reports bucket that reports names (or --bucket in a single repo) with credentials from its own environment (Reports lists the variables). Read the estate over MCP connects a client.
| Tool | Reads | Arguments |
|---|---|---|
estate |
estate.json, as terragucci estate last wrote it |
none |
index |
the report index rows, newest first, each with its report path |
project, stage, limit |
report |
a run’s report.json, or one root of it |
path, root |
last_apply |
a root’s newest tf-apply wave: its commit, wave, gate, whether it applied, its changes and the state version it left |
root, project |
run_view |
the run view of one applied commit | commit, project |
state_versions |
states.json, the state versions each root’s applies left |
root, project |
audit |
the audit trail, audit.jsonl, newest first, with audit.json |
project, kind, limit |
dora |
dora.json |
none |
waiting |
the waves waiting on chant/lifecycle in the repo it runs in, each with the terragucci approve command a person runs |
none |
templates |
the templates in the release catalog, as templates list --json prints them: each one’s kind, the versions a request may name and the newest one’s form fields |
template |
With --propose it serves four tools more, for an agent that gets a change planned without leaving its client (Have an agent propose a change over MCP). They use the forge token in the variable token_env names (by default GITHUB_TOKEN, GITLAB_TOKEN or FORGEJO_TOKEN) and git’s own credentials, from the server’s environment. A control repo has none of them.
| Tool | Does | Arguments |
|---|---|---|
propose |
pushes a local branch to origin without force and opens a pull request from it, or returns the one already open; refuses the default branch, chant/lifecycle and every apply.branches branch |
branch, title, body, base |
request_plan |
comments /terragucci plan [root] on an open pull request |
pull_request, root |
plan_result |
the pull request’s head and plan note, and the tf-plan report of that head from the bucket: each root’s status and policy verdict, the policy check, and whether each wave’s gate will hold it; waits up to wait seconds (default 120, at most 600) for the head’s plan |
pull_request, wait, project |
request_from_template |
runs request with --via mcp: the same request, branch and pull request, with the propose footer after the request; returns branch, pull_request, url, existing and next. The requester is the user the forge says the token acts as, and claimed_by goes in the request as claimedBy. A sensitive input is refused, and so is every refusal of request, with nothing pushed. It needs a chant with template requests, and on an older one it answers with an error naming it |
template, name, version, app, inputs, claimed_by |
Every other tool is marked read-only, and the server refuses these calls.
| A call | The answer |
|---|---|
to a tool it does not list, such as approve, apply, override or merge |
an error: the server never approves, applies, overrides or merges, approvals belong to a person at a shell, and an approval made over MCP is refused |
| with an argument the tool does not list | an error naming the argument; one named like a credential (token, secret, key) says credentials come from the server’s environment |
with a path outside the reports prefix |
an error |
Without --propose the server writes nothing, and with it only the branches, the pull requests and the comment above, and a request’s line on chant/lifecycle. Its bucket client refuses writes and signed links, and the server does not start with a tool whose name says it would write (approve, apply, override, lock, merge).
terragucci guard [--config <file>] [--dir <dir>] [--no-hook]Writes a local guard for a coding agent in this checkout, so that the agent’s shell cannot apply a root the pipeline owns. It writes, under the checkout’s git directory (.git/terragucci/guard, or --dir), so that nothing of it is committed:
| File | Does |
|---|---|
bin/tofu, bin/terraform, bin/terragrunt, bin/choudoufu |
wrappers to put ahead of the binaries on the agent’s PATH; each runs the next binary of its name on PATH unless the guard refuses the command |
guard.mjs |
the rule, with the repo and its roots as they were when it was written |
It also adds a PreToolUse hook to .claude/settings.local.json, which Claude Code reads, keeping the rest of the file, and lists that file in .git/info/exclude unless git already ignores it. --no-hook leaves it alone. It prints the export PATH=... line for the agent’s shell.
| In a root of the pipeline (a Terragrunt unit in a Terragrunt repo) | |
|---|---|
| refused | apply, destroy, import, taint, untaint, force-unlock, state rm, state mv, state push, state replace-provider, and any command with -auto-approve; -chdir and --working-dir name the directory |
| refused from a directory that holds a root | Terragrunt’s run --all, run-all and stack run with any of the above |
| run | everything else, such as init, validate, fmt, plan, show and state list |
Outside the roots, the wrappers run every command. The hook applies the same rule to the agent’s Bash commands, following cd and sh -c, and refuses terragucci approve, override, stage tf-apply, unlock-state, pr-merge, promote, rollback and --mode apply anywhere in the repo. A refusal exits non-zero (3 from a wrapper, 2 from the hook) with a message that names propose on terragucci mcp --propose. Run it again after the roots change. The guard does not stop an agent that runs a binary another way; the threat model says what does.
terragucci view [--reports <dir|s3://<bucket>/<prefix>|https://...>] [--project <host/path>]
[--port <n>] [--no-open] [--export <dir> [--publish]] [--config <file>]Starts behold with npx, at the version this terragucci pins, on the repo’s checkout and its reports bucket. It waits until behold answers on http://127.0.0.1:<port>, opens the browser, and runs until Ctrl-C. Each root is drawn as a box of its resources, and a resource a run flagged carries a mark with that run’s finish time.
npx --yes -p @intentius/behold@0.34.3 -p @intentius/chant-lexicon-terraform@^0.124.0 -p @cdktn/hcl2json@^0.24.0 \
behold serve <repo> --terragucci <reports> --terragucci-project <project> --port 4600| Flag | Meaning |
|---|---|
--reports |
where to read the reports, in place of reports in the config: a directory, s3://<bucket>/<prefix> or an https address |
--project |
the project’s name in the index; default the one a run in this checkout writes, from the git remote |
--port |
the port behold serves on; default 4600 |
--no-open |
serve without opening the browser |
--export |
write a static view to the directory instead of serving, without each root’s source text |
--publish |
with --export, also upload the view to <prefix>/views/behold/<commit>/ in the reports bucket, where no run writes; <prefix>/views/behold/index.html opens the newest commit, and the 30 newest are kept |
--config |
the config file; default the one in the working directory or at the repo’s root |
| Reports in | behold reads |
|---|---|
| S3 | s3://<bucket>/<prefix>, with your shell’s AWS credentials; reports.endpoint is passed as AWS_ENDPOINT_URL_S3 |
| GCS or Azure Blob | reports.url with the prefix; with no reports.url, the command stops and asks for --reports <dir> with a copy made by gcloud storage rsync or azcopy |
--publish writes to S3 only. A read-only identity needs s3:GetObject on the prefix; --publish also needs s3:PutObject, s3:GetObject and s3:DeleteObject on <prefix>/views/behold/*: it reads the list of published commits and removes the files of a commit past the newest 30.
When behold stops, the command prints one line and exits 1:
| Cause | The line says |
|---|---|
no npx |
npx is not on the path |
the repo’s chant.workspace.json asks for a newer minReader than behold 0.34.3 reads |
the repo asks for a newer reader than the pinned behold reads |
| the Terraform reader did not install | the package behold could not load |
| AWS refused or found no credentials | the source, and which error AWS gave |
| behold refused a report as malformed | behold’s own error and what to fix |
The command writes nothing to the repo. behold refuses to deploy, approve or start a run on a terragucci repo, and a waiting wave shows the terragucci approve line to run in your shell.
drift-agent
Section titled “drift-agent”terragucci drift-agent prompt --report <dir> --out <file> [--policy-dir <dir>]
terragucci drift-agent show --report <dir>
terragucci drift-agent push --change <dir> [--forge github|forgejo] [--policy-dir <dir>]The drift agent’s jobs are chant’s terragucci-drift-agent and terragucci-drift-agent-push, in terragucci-drift.yml. The drift script runs drift-agent show; prompt and push run in a job you write.
| Command | Does |
|---|---|
drift-agent prompt |
reads report.json and issue.json from the drift job’s report in --report, and writes the prompt to --out: each drifted resource with the state’s value and the live one, never a sensitive one; exits 1 when the run opened no drift issue |
drift-agent show |
reads report.json from the drift job’s report in --report and prints each drifted resource with the state’s value and the live one, never a sensitive one. With agent.drift the drift script runs it when the run opened the drift issue, so chant’s drift agent reads the values in the run’s output |
drift-agent push |
refuses the patch in --change when it touches a path an agent may not change, --policy-dir (default policy) among them; commits a passing patch on top of TG_SHA to terragucci/drift-agent-<issue>, pushes it without force with TG_TOKEN, opens the pull request and comments its link on the issue TG_ISSUE names |
config check
Section titled “config check”terragucci config check [--config <file>]Lists every problem. The config keys names the files it reads. A repo with migration files is also a problem when its generated GitHub pipeline has an apply job that may not write chant/lifecycle; the message names the jobs and terragucci init, which writes the pipeline again.
terragucci.yml: ok
approval: ledger (the default)With oidc.roles in a repo of plain roots, it reads each root’s backend and terraform_remote_state blocks and prints a line per role and stage with the state that role reaches. Every glob in oidc.roles is an environment, and the unmatched roots form one more under plan_role and apply_role. oidc.gcp.roles and oidc.azure.roles get the same lines and warnings, marked gcp or azure, for the gcs or azurerm states their roots keep. Each warning goes to stderr.
| Warning | When |
|---|---|
| a role is the role of two environments | the same role ARN in two globs, or a glob and the pair; it reaches the state of each |
| a root reads the state of another environment’s root | its terraform_remote_state names that root’s state key, so its roles must reach that state |
a root matches no glob and oidc names no pair |
the root plans and applies with no AWS role |
Under terragrunt.credentials it warns when one role serves two unit globs.
In a repo of plain roots it warns for each terraform_remote_state block whose state address is not plain strings in the code, and, when any root reads state, for each root whose own backend’s address is not. No edge orders those roots.
terragucci.yml: 1 warning(s)
state: app reads state through terraform_remote_state "net" where the code does not say (its pg conn_str is an expression, not a plain string), so it is not ordered after the root that writes itWarnings leave the exit code 0.
terragucci.yml: ok
approval: ledger (the default)
state access:
arn:aws:iam::444455556666:role/dev-plan (plan, envs/dev/**): s3://acme-state/dev/app.tfstate
arn:aws:iam::444455556666:role/dev-apply (apply, envs/dev/**): s3://acme-state/dev/app.tfstate
arn:aws:iam::111122223333:role/prod-plan (plan, envs/prod/**): s3://acme-state/prod/app.tfstate; reads s3://acme-state/dev/app.tfstate
arn:aws:iam::111122223333:role/prod-apply (apply, envs/prod/**): s3://acme-state/prod/app.tfstate; reads s3://acme-state/dev/app.tfstate
terragucci.yml: 1 warning(s)
oidc: envs/prod/app (envs/prod/**) reads the state of envs/dev/app (envs/dev/**) through terraform_remote_state, so arn:aws:iam::111122223333:role/prod-plan and arn:aws:iam::111122223333:role/prod-apply reach s3://acme-state/dev/app.tfstate, another environment's stateconfig identities
Section titled “config identities”terragucci config identities [--config <file>] [--project <host/path>] [--forge github|gitlab|forgejo] [--repo <owner/name>] [--default-branch <branch>] [--owner-id <id>] [--repo-id <id>] [--no-roots]Prints, for each environment in environments and for the roots in none, what each kind of job presents to a cloud: the plan job of a pull request, each wave’s deciding job, the apply jobs on the default branch, and the drift job. Use it to write each role’s trust, or read it with the Terraform provider. --json prints the contract.
| Flag | Meaning |
|---|---|
--project |
a control repo’s project, by its key; its roots are elsewhere, so none are listed |
--forge |
the forge, when neither the config, the project key nor the origin remote names it |
--repo |
the repository the jobs run in, as owner/name or a GitLab project’s full path; default: the project key’s, or the origin remote’s |
--default-branch |
the branch the apply and drift jobs run on; default main |
--owner-id, --repo-id |
Forgejo: the owner’s and the repository’s numeric ids, which Forgejo puts in the subject; without them the subject holds <owner-id> and <repo-id> |
--no-roots |
does not read the repo’s roots, for a config read away from its repo |
terragucci.yml: github github.com/acme/infra (default branch main)
environment prod: envs/prod/app, envs/prod/net
plan: sub repo:acme/infra:pull_request
runner ubuntu-latest
aws arn:aws:iam::222222222222:role/prod-plan aud terragucci-plan
decide: sub repo:acme/infra:ref:refs/heads/main
runner group deployers self-hosted, linux
aws arn:aws:iam::222222222222:role/prod-plan aud terragucci-plan
apply: sub repo:acme/infra:environment:prod
forge environment prod
runner group deployers self-hosted, linux
aws arn:aws:iam::222222222222:role/prod-apply aud terragucci-applyforge check
Section titled “forge check”terragucci forge check [--config <file>] [--project <host/path>] [--forge github|gitlab|forgejo] [--repo <owner/name>] [--default-branch <branch>] [--owner-id <id>] [--repo-id <id>] [--no-roots] [--require-clouds]Compares what config identities expects with the forge’s and the clouds’ live setup, and prints a row for each setting: what it expects, what it found, and whether they match. It reads the repository’s default branch from the forge, and on Forgejo the owner’s and repository’s numeric ids, so the subjects it expects are the ones the jobs present. A person runs it, or a team adds it as a scheduled job of its own; no generated job runs it. --json prints the rows.
The flags are those of config identities, and:
| Flag | Meaning |
|---|---|
--require-clouds |
a cloud the config configures but no credentials reach fails the check too |
| Where | Checks |
|---|---|
| GitHub | each forge environment of the apply jobs exists, and its deployment branch rule lets only the default branch deploy: protected branches, or custom policies that name the default branch alone; each runner group an apply runner names is limited to selected workflows |
| GitLab | each forge environment is protected; every runner of the project that carries an apply runner’s tags runs on protected refs only (ref_protected); each variable the apply jobs read (pass.secrets, pass.vars, the cost key, the notify secrets) has a definition scoped to the environment and protected |
| Forgejo | the default branch and each apply.branches branch is protected |
| AWS | each role’s trust admits each job the contract names, and no other: a sub or aud the contract does not name, a wildcard wider than its pattern, a statement with no sub or aud condition, another OIDC provider or account is a mismatch |
| GCP | the workload identity provider’s attribute_condition is the contract’s or narrower: each of its || terms holds every && part of a term of the contract’s |
| Azure | each app’s federated credentials are the contract’s issuer, subject (or expression) and audiences; a credential the contract does not name is a mismatch |
Each row’s status is one of these.
| Status | MATCH column |
Means |
|---|---|---|
match |
yes |
as expected |
mismatch |
no |
different, missing or wider |
unknown |
unknown |
could not be read: the row names the scope it needs, or that the edition has no such setting (GitLab protected environments are Premium) |
not-checked |
not checked |
no credentials for that cloud |
Only a mismatch exits 1, and with --require-clouds a cloud row that is not-checked. A GitLab variable defined only at the group or instance is unknown, since the check reads the project’s variables.
terragucci.yml: github github.com/acme/infra (default branch main)
WHERE CHECK SUBJECT EXPECTED FOUND MATCH
github environment prod exists exists yes
github deployment-branches prod deploys from main only custom: main, release/* no
github runner-group deployers limited to selected workflows could not read (403); the token needs Self-hosted runners: read on the organization (classic: admin:org) unknown
aws trust arn:aws:iam::222222222222:role/prod-apply sub repo:acme/infra:environment:prod aud terragucci-apply not checked: no AWS credentials (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, or a profile with static keys) not checked
1 match, 1 mismatch, 1 could not be read, 1 not checkedRead-only credentials
Section titled “Read-only credentials”The command reads the forge with GET requests only, and sends AWS one action, GetRole, as a signed form POST, the way the AWS SDKs send it; it refuses any other request before sending it. Give it read-only credentials.
| Where | Read from | Needs |
|---|---|---|
| GitHub | the variable token_env names, or GITHUB_TOKEN |
a fine-grained token with Metadata: read and Actions: read on the repository, and Self-hosted runners: read on the organization for runner groups; a classic token needs repo, and admin:org for runner groups |
| GitLab | the variable token_env names, or GITLAB_TOKEN |
the read_api scope, held by a user or token with the Maintainer role, which protected environments, runners and variables need |
| Forgejo | the variable token_env names, or FORGEJO_TOKEN |
the read:repository scope, held by a user with admin on the repository, which branch protections need |
| AWS | AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN, or static keys under AWS_PROFILE (or default) in the shared credentials file |
iam:GetRole on each role; for SSO or a role profile, export its keys first with aws configure export-credentials --format env |
| GCP | GOOGLE_OAUTH_ACCESS_TOKEN, such as from gcloud auth print-access-token |
iam.workloadIdentityPoolProviders.get on the provider |
| Azure | AZURE_GRAPH_TOKEN, such as from az account get-access-token --resource-type ms-graph --query accessToken -o tsv |
Application.Read.All on Microsoft Graph |
approve
Section titled “approve”terragucci approve [wave-<k> | <migration>] [--plan <digest>] [--actor <name>] [--sign [<key>]] [--dry-run] [--no-resume]
terragucci approve export <root> --plan <digest> [--sign]
terragucci approve unlock <root> --plan <digest> [--sign]
terragucci approve ephemeral <pr> --plan <digest> [--sign]
terragucci approve release <env> [--plan <digest>] [--sign]| Flag | Meaning |
|---|---|
wave-<k> |
the wave to approve; needed only when several wait and no --plan picks one |
<migration> |
a state migration wave 1 waits on, by name: it approves the migration’s digest and resumes wave 1; needed only when another gate waits too and no --plan picks one |
--plan |
the digest you read, from a chat message, a plan note or a report: approve only a wave waiting for exactly that digest. When none does, it approves nothing, prints the digest waiting and exits 1 |
--actor |
the name the approval records; under approval: sealed, your principal in the signers file |
--sign |
seal the approval with this key, or with git’s user.signingkey when no key is given; the default under approval: sealed |
export <root> |
a state export request for <root>; it counts only from someone other than the person who asked |
unlock <root> |
the release of the lock unlock-state found on <root> |
ephemeral <pr> |
the plans of pull request <pr>’s ephemeral environment: it approves gate pr-env of op pr-<pr> for the digest the job printed |
ephemeral <pr> |
pull request <pr>’s ephemeral environment |
release <env> |
the gate a promote or rollback into <env> waits at: the stage’s gate in .chant/pipeline.ts, for that release in <env>, or the components’ release gate beside a pipeline the repo wrote itself. With --plan, only that digest |
--dry-run |
print what it would approve and record nothing |
--no-resume |
record the approval only; by default it then starts the wave again with your forge token (Resume after an approval) |
Run it in a checkout whose origin you can push to.
wave-2 waits for an approval of jcs1-sha256:2e7a63f3... (wave 2 of 2: app), since 2026-10-07T18:04:11.000Z
roots: app
destroys app: aws_s3_bucket.logsWith a digest that no longer waits, because the plans moved after you read them, terragucci approve wave-2 --plan jcs1-sha256:9f2c... prints:
not approved: wave-2 waits for jcs1-sha256:9f2c...; waiting: wave-2 for jcs1-sha256:2e7a63f3.... The plans moved since that digest, or were approved and applied; read the waiting plans, then approve their digestpromote and rollback
Section titled “promote and rollback”terragucci promote --to <env> [--release <label>] [--from <env>] [--allow-skip] [--urgent --reason <text>] [--dry-run] [--json]
terragucci rollback <env> --release <label> [--dry-run] [--json]Deploy a release to one environment of promotion, on chant’s components promote and components rollback. Promote a release through environments walks through cutting a release and moving it.
| Flag | Meaning |
|---|---|
--to |
the environment the release goes to |
--release |
the release’s label or digest; the deploy reads the files the release recorded for that environment |
--from |
the environment whose record of each component is promoted; default: the one before --to in promotion |
--allow-skip |
promote past an environment of promotion that has not run the release, which is refused otherwise |
--urgent |
pass the stage’s gate on its urgent rule: one proven approval from environments.<env>.urgent.role lets the named release in. Takes --release and --reason, a line the stage’s ledger keeps with the promote |
<env> (rollback) |
the environment that goes back; --release names the earlier release it goes back to |
--dry-run |
print each component, the release and where it was deployed from, and change nothing |
--json |
chant’s plan and result as JSON |
An environment whose gate is not never stops once, at its stage’s gate, before it applies and exits 3, naming terragucci approve release <env>; run the same command again once it is approved. Each command first reads .chant/pipeline.ts on the default branch and exits 1 unless it gates that environment. A rollback into such an environment deploys the earlier release through the stage’s gate, and pauses the stage afterwards when it sets pause_after_rollback. Each deploy records the release the environment runs on chant/lifecycle. Both commands need terragucci.component.ts, which init writes from promotion, and @intentius/chant-lexicon-terraform installed beside terragucci; without either they exit 1 and say what to do.
migrate
Section titled “migrate”terragucci migrate revert <migration>Writes migrations/<migration>-revert.yml, the revert of a migration that applied, from its record on chant/lifecycle as origin holds it. Nothing else is written; the plan job proves the change that carries the file, which waits at wave 1 for its approval like any migration. Exit code 1 when the migration never applied, moved states to a new backend, or left a root with no version to put back.
state export
Section titled “state export”terragucci state export <root> [--version <id>] [--out <file>] [--actor <name>]| Flag | Meaning |
|---|---|
<root> |
the root whose state to export, with a backend that keeps versions (an s3 bucket with versioning, a gcs bucket with object versioning, an azurerm account with blob versioning or a backend with snapshot = true), or on GitLab-managed state: a plain root, or a Terragrunt unit, which Terragrunt prepares through its remote_state block |
--version |
the version id, as the estate page’s State versions section lists it (GitLab’s serial on GitLab-managed state); the current version by default |
--out |
where to write the file, outside every git working tree; a new private directory under the system’s temp directory by default |
--actor |
who asks; git’s user.name by default |
Run it twice in a checkout whose origin you can push to, signed in to the cloud as yourself. Export a state version has the steps.
| Run | Does | Exits |
|---|---|---|
| first | reads the version’s metadata, records a request on chant/lifecycle and prints terragucci approve export <root> --plan <digest> for someone else to run |
3 |
| second, once that approval stands | downloads the version, records the export in _gates/tf-state-export/done.jsonl, then writes the file, readable by you alone. With a chant that has gated requests, the approval is spent in _gates/tf-state-export/applied.jsonl before the download and the finished line after it names the digest of the bytes written |
0 |
state export: wrote /tmp/terragucci-export-Xb3k/envs_dev_app.3HL4kqtJlcpXroDTDmJ.rmSpXd3dIbrHY.tfstate: envs/dev/app's state, s3://acme-state/dev/app.tfstate version 3HL4kqtJlcpXroDTDmJ.rmSpXd3dIbrHY, approved by bobAn approval by the person who asked does not count. A request exports once; another export asks again. It never writes a state to the reports bucket or a job artifact.
unlock-state
Section titled “unlock-state”terragucci unlock-state <root> [--actor <name>] [--binary <b>] [--config <file>]Releases the state lock a job killed mid-apply left on <root>: the lock file an s3 backend with use_lockfile = true takes, a gcs backend’s lock object, an azurerm backend’s lease on the state blob, or the lock of GitLab-managed state. A comment never runs it. Run it at a shell with:
- the backend’s credentials;
- the forge token in the variable
token_envnames (by defaultFORGEJO_TOKEN,GITHUB_TOKENorGITLAB_TOKEN); - push access to the checkout’s
origin.
| Step | Does |
|---|---|
| read the lock | inits the root and reads the lock file, the gcs lock object or the azurerm lease and metadata, or asks GitLab’s lock endpoint: its ID, who took it and when |
| check no holder is alive | reads the forge’s runs still running or waiting; while one that began before the lock was taken is alive, it may hold the lock, so nothing is released and it exits 1 naming the runs. A forge it cannot read is a refusal too |
| wait at the gate | records a pending fact for gate <root> of op tf-unlock on chant/lifecycle, bound to a digest of the root, the lock’s location and its ID, prints terragucci approve unlock <root> --plan <digest> and exits 3. Under approval: sealed, only a sealed approval counts |
| release | approved, it checks the runs again, runs the binary’s force-unlock of that ID (on GitLab, a DELETE of that ID on the lock endpoint), and appends who released which lock, and under whose approval, to _gates/tf-unlock/done.jsonl, which the audit trail reads. With a chant that has gated requests, the approval is spent in _gates/tf-unlock/applied.jsonl first and the release is its finished line |
| Flag | Meaning |
|---|---|
--actor |
the name the record gives the person who released it; default git’s user.name |
--binary, --config |
as above |
terragucci unlock-state: slow: s3://acme-state/slow.tfstate.tflock holds lock 1f0c..., OperationTypeApply by root@runner-7 at 2026-10-09T18:02:11.420Z
terragucci unlock-state: slow: no run that began before the lock is alive
terragucci unlock-state: slow: releasing lock 1f0c..., OperationTypeApply by root@runner-7 at 2026-10-09T18:02:11.420Z waits for an approval of digest jcs1-sha256:6d2b.... Approve it with:
terragucci unlock-state: terragucci approve unlock slow --plan jcs1-sha256:6d2b...An approval names one lock. If that lock was released some other way and a new one taken, the approval does not release the new one and the command exits 4.
ephemeral
Section titled “ephemeral”terragucci ephemeral up --pr <n> [--head <sha>] [--base <ref>] [--binary <b>] [--config <file>]
terragucci ephemeral down --pr <n> --reason closed|expired [--base <ref>] [--binary <b>] [--config <file>]
terragucci ephemeral sweep [--base <ref>] [--binary <b>] [--config <file>]The generated pipeline runs it for ephemeral. It reads ephemeral from the checkout’s terragucci.yml (the default branch, or --base) and checks out the pull request’s code separately from the forge’s pull request ref.
| Subcommand | What it does |
|---|---|
up |
inits each root the globs match at --head with -backend-config naming its key with -pr-<n> added, and plans it. A plan that changes something waits at gate pr-env of op pr-<n> for an approval of the set digest, printing terragucci approve ephemeral <n> --plan <digest> and exiting 3. Once approved, or with nothing to change, it applies and appends the copy, each root’s state key, its expiry and who approved it to _pr-envs/records.jsonl |
down |
plans the destroy of each root of the live copy and applies it, in reverse order, from the commit the copy applied, and appends the destroy with --reason and how many roots it destroyed; with no live copy it does nothing |
sweep |
destroys each live copy whose TTL passed (expired), and each whose pull request the forge says is closed or merged (closed), reading it with TG_TOKEN |
These are config errors (exit 1):
- a root on a backend other than
s3,azurerm,gcsorlocal; - a backend block that names no key;
- an
httpbackend that is not GitLab-managed state; - a Terragrunt unit whose
remote_statekey does not readTERRAGUCCI_EPHEMERAL_SUFFIX.
A destroy that fails is tried once more. If it still fails, the copy stays live, and the next sweep tries again. up, down and sweep also read the copies recorded in _gates/tf-ephemeral/done.jsonl by terragucci 0.4.42 and earlier.
override
Section titled “override”terragucci override <root> --rule <id> [--rule <id>] --reason <text> [--actor <name>] [--sign [<key>]] [--dry-run]| Flag | Meaning |
|---|---|
<root> |
the root the policy denied |
--rule |
a rule that denied it, such as main.deny_public_bucket; name every one, or give them comma-separated |
--reason |
required: why this plan goes out, kept on the ledger and shown in the report |
--actor |
the name the override records; it counts only when policy.override at base lists it |
--sign |
as for approve; the default under approval: sealed |
--dry-run |
print what it would override and record nothing |
envs/prod/app: its plan jcs1-sha256:4c1e09d2... was denied by main.deny_public_bucket, since 2026-10-07T18:04:11.000Z
the override binds the root, that plan and those rules: sha256:9b0f2a71...check-root, check-pins, check-policy and check-sources
Section titled “check-root, check-pins, check-policy and check-sources”terragucci check-root <dir> [--binary <b>] [--config <file>] [--base <ref>]
terragucci check-pins [--config <file>] [--base <ref>]
terragucci check-policy [--config <file>] [--base <ref>]
terragucci check-sources <dir>|--units [--config <file>] [--base <ref>]| Command | Does |
|---|---|
check-root |
runs validate -json in an initialised root and prints each diagnostic with its file and range; with --binary choudoufu, also choudoufu live-check -json. Under modules.require: attested (read at --base) it first checks the root’s module pins |
check-pins |
the same pin check on each Terragrunt unit’s terraform { source }; prints nothing without modules.require: attested |
check-policy |
runs the policy’s tests when policy is set |
check-sources |
checks a root’s module sources and providers against sources, read at --base, before its init; --units checks every Terragrunt unit instead; prints nothing without the key |
Each appends to terragucci-check/report.md, and the generated tf-check job runs them, check-sources only when sources is set. See Stages.
image recipe and check-mirror
Section titled “image recipe and check-mirror”terragucci image recipe [--out <dir>] [--from <image>] [--binary <b>] [--platform <os/arch>[,...]] [--config <file>]
terragucci check-mirror [--config <file>] [--platform <os_arch>]| Command | Does |
|---|---|
image recipe |
reads every .terraform.lock.hcl in the repo and writes, under --out (default image), a Dockerfile FROM the terragucci image for the binary in the set image.base names (or --from), whose steps run as root and which ends as the user that image runs as, a terragucci.tfrc whose only installation method is a filesystem_mirror, one module per distinct lock file that requires each provider at its locked version, and build.sh, which builds for --platform (default linux/amd64) and pushes to $IMAGE. It builds and pushes nothing itself |
check-mirror |
with image.mirror set, checks the image’s mirror holds every provider each lock file pins, for the job’s platform (or --platform, such as linux_arm64). A gap new at this commit warns; a gap the lock file already had at the commit’s first parent fails, naming the provider and the rebuild. Prints nothing without the key |
The generated tf-check job runs check-mirror before any root’s init when image.mirror is set.
registry edge
Section titled “registry edge”terragucci registry edge [--out <dir>] [--origin <url>] [--config <file>]Writes, under --out (default registry-edge), the function modules.registry.edge names: for cloudflare, worker.mjs and a wrangler.toml that binds an R2 bucket or reads the bucket’s address; for cloudfront, index.mjs and registry-edge.json for one Lambda@Edge function. --origin names the bucket’s HTTP address in place of the one it derives from bucket and endpoint. With auth: token it prints the steps that make and rotate the token; on CloudFront it reads the tokens from TERRAGUCCI_REGISTRY_TOKENS. For pages and none it writes nothing and says why. It deploys nothing itself. See Put an edge function in front of the bucket.
check-job
Section titled “check-job”terragucci check-job --forge github|gitlab|forgejo --environment <name> --branches <b>[,<b>...] [--forge-environment <name>] [--runner-tags <t>[,<t>...]] [--self-hosted]The first line of each environment’s apply job, before any token is fetched or traded. init writes the expected values into the job: the forge environment, the branches the job applies from (the default branch from the forge, and those of apply.branches), GitLab’s runner tags, and --self-hosted when the runner’s labels include self-hosted. It prints what it checked, or one line per value that differs, naming the expected and the found value, and exits 9 (misplaced). The job line passes that code on (|| exit $?), so on GitLab, where the op-wave jobs allow exit 1 alone, a refused job fails and the waves after it stop. What it reads on each forge: The apply job’s own check.
install
Section titled “install”terragucci install tofu|terraform|terragrunt|choudoufu|infracost|cosign|atmos|terramate <version>Prints the directory it unpacked the release to, after checking it against its SHA256SUMS. For the release an image carries it also checks the sha256 terragucci or chant records for it, so a changed SHA256SUMS fails the install. The releases are Linux builds. Under modules.attest the publish job installs cosign this way before it publishes; in an Atmos repo every job installs Atmos this way.
init, reconcile, plan, stage, rollout, respond, config check, config identities, forge check, query, modules, templates and request take --json, which makes the command print only one envelope on stdout. The CLI’s JSON output lists the fields.
Exit codes
Section titled “Exit codes”The codes are the same with or without --json, and they are chant’s: a pipeline that reads chant’s exit codes reads terragucci’s the same way. A usage or config error has no code of its own and exits 1.
| Code | Meaning |
|---|---|
| 0 | done |
| 1 | one or more projects or roots failed, or a usage or config error |
| 3 | waiting on an approval, or on a rollout’s pull request |
| 4 | a wave’s plans changed after an approval or a policy override no run applied, so stage tf-apply applied nothing; or a share’s plans changed after its wave decided, and the roots that moved were not applied |
| 5 | stage tf-apply --on-held refuse: another run’s apply holds a resource the wave changes; unlock-state: a run that may hold the lock is alive, so nothing was asked or released |
| 6 | stage tf-apply --stand-down: a newer push applies instead |
| 7 | stage tf-apply: chant’s policy denied the plan and no override counts |
| 8 | stage tf-apply: a decision point was answered with an answer the gate does not pass on, so nothing applied |
| 9 | check-job: the job runs where its environment’s apply is not set to run, so it stopped before any token was fetched |
| Command | 0 | 1 | 3 | 4 |
|---|---|---|---|---|
init |
done | an existing config file needs a line added, or sets another gate than --gate |
||
reconcile |
done | a project failed | ||
generate |
written, or with --check every generated file matches |
with --check, a generated file out of line; a file it did not write is in the way, or a root’s own files declare what it would write |
||
plan, stage tf-plan, stage tf-drift |
done | a root refused to plan | ||
stage tf-apply |
wave applied, or with --shares decided for its shares |
a root failed, or the policy denied one; --json, or a share with no decision file |
waits for an approval | plans changed after an approval or a policy override no run applied, or after a share’s wave decided |
publish |
done | OCI tag exists already; git tag exists with different content | ||
rollout |
complete | stopped | waiting | |
request |
pull request opened or already open, or with --dry-run its files listed |
a refusal, or a chant without template requests | ||
respond |
event handled, even when the response is off |
unknown event or missing flag | ||
comment |
decision written, or every note answered | forge error, unreadable event file | ||
pr-lock |
locks taken, refused or released | the locks could not be read or pushed, unreadable event file | ||
config check |
ok, with or without warnings |
problems found | ||
config identities |
printed | no config, an unknown project, or no forge to name | ||
forge check |
no mismatch | a mismatch, or with --require-clouds a cloud not checked; no config, an unknown project, or no forge to name |
||
state export |
the version written and recorded | a root, backend or version it does not export, a file inside a git working tree, a CI job, a request exported already, or nobody named | waits for an approval by someone else | |
check-root, check-pins, check-policy, check-sources |
passed | failed | ||
check-job |
the job runs where its environment’s apply is set to run | a flag missing | ||
install |
done | not a Linux host | ||
estate |
page written | a project’s index could not be read | ||
audit |
record written, or with --check nothing missing |
a ledger or index could not be read; with --check, an entry the record lacks |
||
verify-release |
every target verified | a target refused | ||
modules |
printed, the status recorded, or consumers.json written or matching |
the catalog could not be read, the token was refused, the status record could not be pushed, or with consumers --check the file is out of line; no catalog yet, no registry to read, a module the catalog does not list, a version with no release record, or no --reason |
||
ephemeral |
applied, destroyed, or nothing to do | a root failed to plan, apply or destroy; no ephemeral roots, a backend no key suffix fits, a Terragrunt unit whose remote_state key does not read TERRAGUCCI_EPHEMERAL_SUFFIX |
the copy waits for an approval | an approval stands for other plans of the copy |
unlock-state |
released, or no lock held | no forge token, a forge it cannot read, a backend with no lock file, or a request that released already | waits for an approval of the lock | |
approve, override |
approved | approve --plan names a digest no wave waits for; no wave waiting, several waiting and none named, no recorded denial, or the rules differ |
||
notify, plan-note, approval-status |
always, once the flags parse | a bad flag | ||
relay |
never: it serves until stopped | a missing setting, a token that can do more than approve, or a repo it cannot read | ||
query |
rows printed | a bad flag or config, a statement that does not run or writes | ||
mcp |
the client closed stdin | a bad flag or config | ||
guard |
the guard written | a bad flag or config, a control repo, no git checkout, or a Claude Code settings file that is not JSON | ||
view |
stopped with Ctrl-C, or the view exported | behold stopped or refused the reports; a bad flag or config, or a source behold cannot read | ||
drift-agent |
prompt written; pull request opened, or the change refused with a comment on the issue | git or the forge failed; a bad flag, or a run that opened no drift issue |
Code 4 comes from stage tf-apply and ephemeral, which have no --json.
terragucciHelp setting it up: Intentius
These docs count page views and clicks with PostHog. They set no cookies, store nothing in your browser, and send nothing when your browser asks not to be tracked.