Skip to content

Deployment skill

Load this first in any session that uses Turf, and again whenever it leaves your context.

The files are the user’s. Edit a .tf or *.turf.hcl file only when the user asks, and load skill_authoring before the first edit. Setting variable values — var, var_file, a line in a .tfvars file — is deployment: the configuration does not change.

What Turf is and how it is built: references/architecture.md.

init({ path: "/path/to/app" }) # tofu init: register, install modules + providers, report declarations
open({ workspace_name: "default" }) # bind the backend + state slot; reports a convergence already holding it
up({ var: { region: "eu-west-1" } }) # start: round 1 waits at its plan gate → awaiting_plan
plan({ convergence_id: "…" }) # plan the round → awaiting_approval, plan.uri + plan.digest
apply({ convergence_id: "…", plan_digest: "…" }) # approve THAT plan: apply it → the next round's gate, or an end …
output({}) # … until converged; then the root outputs

Every result carries outcome, ended and next — the call that continues it, with its arguments: act on it.

  • init reports what the configuration declares — backend, workspace, variables, outputs, readme — never resolved values. variables[] marked required have no default: the environment or a .tfvars file may still supply one. providers[] lists each provider as the lock file records it, with its package directory: scan them with a provider-scanning tool, if you have one, before the first up. Commit .terraform.lock.hcl: every plan honours it.
  • open derives the backend from the configuration’s own block. backend_config supplies only what the block leaves out (credentials, per-environment values). Workspaces, backends and locking: references/workspaces.md.
  • Variable values are var (tofu -var) and var_file. open keeps its own for the workspace: every tool on it reads the state with them. Each start verb lays its own over them, for that convergence. terraform.tfvars, *.auto.tfvars and this server’s TF_VAR_ environment load on their own. Ask the user for a required value nothing supplies. What the backend block or a state-encryption passphrase reads goes to open (references/credentials.md).
  • Provider credentials are the engine’s environment and TURF_PROVIDER_ENV: references/credentials.md.

up starts the convergence and stops at round 1’s plan gate (awaiting_plan), nothing planned yet. plan({ convergence_id }) plans the round and stops at its approval point:

→ { convergence_id, outcome: "awaiting_approval", round: 1,
plan: { uri, digest, add, change, destroy, replace, import, forget, read, deferred, drift, outputs,
invocations: [{ address, type, caller, event, on_failure }] },
rounds, expires_at, next, console_url }

console_url, when present, is the round’s page in the Turf console, for the user: give it to them verbatim every time, above all at an approval point; never open it yourself. open and status carry the workspace’s page.

refresh: false and replace: ["<address>"] are that round’s options (tofu plan -refresh=false, -replace); the next round plans with the defaults. replace is refused outside an up, the round still waiting.

plan.uri is the round’s plan resource: the tofu show -json document, sensitive values redacted. show({ convergence_id: "…" }) reads it; hand the document to a policy tool (OPA/conftest, Checkov) as input.tfplan, show_sensitive: true only if a policy reads a secret (it enters the conversation). A zero count is left out of plan. Fields and change symbols: references/plans.md.

  • Never edit between plan and apply. The engine re-reads the configuration before applying; a stale plan is never applied: the convergence ends stale (rounds[].stale_reason). A plan goes stale when any file it parsed changes — .tf, on-disk overlays, installed modules, an auto-loaded .tfvars, the lock file. var, var_file and TF_VAR_ are pinned with the convergence and never make it stale. Run up again with the same var values, then plan, and review the new plan.
  • A pause lasts 24 hours (expires_at), at either gate or at turf actions. Past it this server detaches and the convergence waits in the engine (Picking up a convergence).

apply({ convergence_id, plan_digest }) is the approval — of that plan and no other. It applies the round and stops at the next round’s plan gate (awaiting_plan: call plan), or ends the convergence. When the user says no, apply({ convergence_id, decline: true, reason }) declines it: nothing is applied, the convergence ends declined, the workspace is free. Calling neither leaves the paused convergence holding the state lock.

  • Approve a plan yourself only when it is low-risk as the instructions define it. Present every other plan — always a destroy plan — and wait for the user’s explicit yes. Every round is its own decision.
  • Before a non-trivial plan, hand show’s document to your policy tools. A deny means do not apply: report the finding.
  • A delete of something that holds data — a database, a bucket, a volume, a cluster — is the user’s call: ask before removing its block or running destroy, and never approve a plan deleting or replacing one without them, whichever round planned it. Offer a backup first, or to stop managing it and leave it running: delete its resource block and add removed { from = … lifecycle { destroy = false } } (skill_authoring); a removed block beside a block still declaring the address does nothing; drop references to the deleted block; what the kept object depends on is still destroyed unless kept the same way.
  • rounds[].approval: asked, unneeded (nothing to consent to) or planfile.
Outcome Meaning Next
awaiting_plan The round waits at its plan gate: nothing planned yet. plan with convergence_id (and the round’s refresh/replace).
awaiting_approval Paused at an approval point. Review plan; apply with its digest, or decline; or edit and up again.
awaiting_actions The apply waits on turf actions (action_requests). Perform them; apply with action_results.
planning / applying Returned at the server’s deadline (ended false); it goes on in the engine. plan / apply with convergence_id; cancel stops it.
converged Done: nothing left deferred. output; report.
failed A change or an action failed, or the round ended before applying. Read rounds[].failures, .actions, .error; fix the cause; up again.
stalled A round applied nothing and still defers: another round would plan the same thing. Read the deferrals; change the configuration or the values; up again.
exhausted max_rounds reached (default 5) with work still deferred. up again continues, or a larger max_rounds.
stale The configuration changed, or no longer loads, after the plan: nothing applied. Not stalled. up again; review the new plan.
declined The plan was declined (apply with decline): nothing applied. up to plan again.
cancelled Ended by cancel, or superseded at a gate. What was in flight finished. up to plan again.
planned A plan_only run sealed its plan as a planfile (planfile); nothing applied. apply with planfile + plan_digest: references/planfiles.md.
detached This server stopped following it; it waits in the engine. Picking up a convergence.
error The engine raised (error). Read it, fix what it names, up again.

Each rounds[] entry counts planned (no-ops and deferrals included), deferred, applied, drift (what a refresh wrote into state), failed, skipped (left unstarted by a failure or a halt), cancelled and invoked. failures name each failed change in the provider’s words; actions only the actions that did not simply succeed; warnings and diagnostics the rest.

Nothing is retried. A failed change settles; the round finishes everything independent of it and ends failed. Fix the cause and run up again: it plans over what was left. Recovery: references/error-handling.md.

A convergence lives in the engine, not in this server or conversation. open (and status) reports one holding the workspace — stage, round, followed and next — and plan or apply with its convergence_id takes it up: at awaiting_plan, plan; otherwise apply:

  • A digest approves only the plan it names. If the convergence now waits on another plan, nothing is applied: a refusal names the plan’s resource, or the plan the engine holds comes back with a note. Read that plan and approve its digest only as Approving allows — never resend the old one.
  • No digest, no decline, no results: the gate the convergence waits at is handed back, nothing answered; one planning or applying is followed — how to take up one you hold no plan for. Review that plan as new, check its kind (a destroy always needs the user’s yes); if the files changed since it was made, it ends stale: up instead.
  • The same arguments again re-follow a call of yours that ended early (cancelled, or the client dropped).
  • Send one of plan_digest, decline, action_results.
  • A takeover from a server that went away may wait out its lease: up to a minute, refused past two.
  • “…is being followed by another call”: usually one of yours still running — wait for it. With none in flight another client follows it: tell the user; ask before you cancel.
  • up again supersedes a convergence waiting at its plan gate or its approval point and is refused while one is planning or applying. cancel({ cause: "…" }) ends the workspace’s convergence in any stage — named by the workspace (workspace_alias), never a convergence_id: what is in flight finishes, nothing new starts.

A turf_action is a step the configuration asks you to carry out during apply: a check, a notification, a question for the user. The apply stops for it — awaiting_actions, with every open request:

→ { outcome: "awaiting_actions", action_requests: [{ key, action, invocation, caller, event,
on_failure, if_failed, prompt, inputs, asked_at }], rounds, next }
apply({ convergence_id: "…", action_results: {
"<key>": { succeeded: true, progress: ["GET https://… → 200 in 40 ms"] },
"<key>": { succeeded: false, progress: ["asked the user: \"not until Monday\""],
diagnostics: [{ severity: "error", summary: "the user declined", detail: "…" }] } } })
  • Do each step with your own tools, using its inputs, and answer every open request in one apply. progress says what you did, a line each; a failure carries at least one error diagnostic saying why; a warning records what did not fail the step. if_failed says in words what a failure does.
  • Report honestly: a step you could not perform failed — say why.
  • A decision is the user’s. When a prompt asks for one, ask the user — every such question at once, an answer each, with what a “no” does (if_failed) — quote their words in progress, and report a “no” as a failure. Never answer for them, and never weaken or remove a trigger to get past it. A halt stops the gated change and what depends on it; independent changes in the round still apply.
  • A result the engine cannot take comes back under refused, and only that request stays open: fix it and send it again.
  • plan.invocations listed at approval every action the round runs, per caller in run order; more turf actions on one caller come one pause each.
  • In a destroy every action failure is only a warning: the teardown goes on and ends converged, the failure in rounds[].actions and the warnings — so the user’s explicit yes at approval is what guards a destroy. A before_destroy gate on a delete that up plans is not downgraded.

Requests, results, invoke, examples: references/turf-actions.md. Declaring one is authoring (skill_authoring → references/actions.md).

A value known only after an apply defers what needs it to the next round, and apply stops at that round’s plan gate. The plan lists each deferred change in deferred_changes[] with its reason and counts it in plan.deferred; a module call whose count or for_each is unknown defers whole, counted there but absent from deferred_changes.

Converge the configuration as it stands: never rewrite it to stage an apply. At stalled or exhausted, and for what each reason means: references/deferrals.md.

destroy, refresh, import and invoke are up in another mode: one round each, the same gates.

  • destroy plans tearing down everything the state holds, dependents first; it never touches the files (runbook below).
  • refresh (tofu apply -refresh-only) reads every managed object and writes what it found into state, changing nothing in the world.
  • import (tofu import) adopts existing objects into state for resources the configuration declares: references/imports.md.
  • invoke (terraform apply -invoke) runs one action now: one the configuration declares (action_addr), or an ad-hoc action laid over it in memory.
  • taint / untaint mark an instance for replacement on the next up, or clear the mark — immediate state edits. plan({ replace: ["aws_instance.web"] }) replaces in that round without editing state.
  • Planfiles: plan_only: true on a start verb ends the round planned, its plan kept for apply({ planfile, plan_digest }), here or elsewhere: references/planfiles.md.
  • Reading: show (a round’s plan, a planfile, or what: "state"), output, state_list (include_values for attributes). None of them plans.

On a configuration already applied, the plan is the drift report: with refresh (the default) plan reads every object first, and the document’s resource_drift lists what changed outside Terraform. Between convergences, watch waits for drift notices; turning detection on (drift, or up with drift: { … }) is the user’s choice: references/drift.md.

Plan Meaning Default action
converged at once, nothing applied State matches the files Tell the user “no drift”
update / replace Reality diverged from the files Present the diff; ask whether to reconcile reality (apply) or the files (edit them to match, then up)
orphan delete In state, no longer in the files Ask: restore the block, forget it with a removed block, or let the delete proceed
create In the files, not in state Deleted out of band, or never applied: apply re-creates it

Remove and destroy are different requests. Removing a resource is an edit — delete its block and up plans its delete, or add a removed block to forget it. destroy tears down everything in the workspace and leaves the files. Ask which the user means when unclear.

A plan that prevent_destroy refuses is the configuration doing its job. It fails naming the instance and applies nothing. Tell the user what it wanted to destroy; never disable the flag or remove its block without their say-so.

No -target/-exclude, and some constructs (check blocks, provisioners, among others) are refused by name: tell the user when one matters, and never strip one out to get past a refusal without their say-so. The list, with remedies: references/divergences.md.

Operate on the configuration directory the prompt names. One call at a time: each result before the next.

  1. init — init({ path: "<dir>" }), the directory resolved to an absolute path. Read backend, workspace, variables (note the required ones), providers and readme; read any *.turf.hcl overlays with your file tools; scan providers[] if you have a scanner.
  2. Open the workspace — open({ workspace_name: "<init's workspace>" }), plus backend_config only for credentials the block leaves out. If it reports a convergence, tell the user and follow Picking up a convergence.
  3. Plan — up({ var: { … } }) with a value for every required variable nothing else supplies (ask the user); it stops at round 1’s plan gate. Then plan({ convergence_id }). If the outcome is converged with nothing applied, say “All resources up to date.” and stop.
  4. Present — read the plan with show (redacted) and show:
    Plan: X to add, Y to change, Z to destroy (R replaced), D deferred to a later round
    + <address>
    <key>: <value>
    ~ <address>
    <key>: <old> → <new>
    ∓ <address> (must be replaced: <replace_paths>)
    ± <address> (replaced, create before destroy)
    - <address> (will be destroyed)
    . <address> (forget — removed from state, left running)
    Call out before→after for updates and replacements, never a sensitive value, and every invocation in plan.invocations (a turf_action stops the apply for you, and for the user when its prompt says so). If plan.deferred is non-zero, say another round follows. Hand show’s document to your policy tool, if any.
  5. Approve — approve a low-risk plan yourself; otherwise ask verbatim: “Ready to apply these changes?” and wait for an explicit yes. Then apply({ convergence_id, plan_digest }). On a no, apply with decline.
  6. Converge — at awaiting_plan, plan the next round, then steps 4 and 5 again (the low-risk test applies afresh), printing Round k: applied N, deferred M from rounds[]. At awaiting_actions, perform the steps and answer with action_results. Any other outcome: read the Outcomes table and act on it.
  7. Report — “Apply complete! Resources: X added, Y changed, Z destroyed.”, then output({}). List anything that failed. Leave the workspace open unless the user is done; close never undoes anything.
  1. init and open, as in /up.
  2. Plan the teardown — destroy({ var: { … } }) with the values the configuration needs (a provider’s variable too), then plan({ convergence_id }). One round plans everything in state, dependents first; removed { lifecycle { destroy = false } } addresses plan as forgets. If nothing is planned, say there is nothing to destroy and stop.
  3. Present it — Plan: X to destroy, one - <address> per line, forgets as . <address> — and name anything that holds data, and every invocation in plan.invocations: in a destroy a failing gate only warns, so say that the user’s yes now is the guard. If the user wants something kept, stop and offer a backup first, or to delete its resource block and add a removed block (skill_authoring), as in Approving; then plan the teardown again.
  4. Ask verbatim: “Ready to destroy these resources? This cannot be undone.” Never approve a destroy plan yourself; proceed only on an explicit yes, and apply with decline on a no.
  5. apply — apply({ convergence_id, plan_digest }).
  6. Report — “Destroy complete! X resources destroyed.” List anything that failed.

Turf™ is a trademark of Turf LLC. Terraform® is a trademark of HashiCorp. Ansible® is a trademark of Red Hat, LLC, registered in the United States and other countries. Helm®, Kubernetes®, Prometheus® and OpenTelemetry® are registered trademarks, and Jaeger™ is a trademark, of the Linux Foundation. OpenTofu® and Model Context Protocol® are registered trademarks of LF Projects, LLC. All other trademarks are the property of their respective owners. Turf is not affiliated with, endorsed by, or sponsored by HashiCorp, IBM, Red Hat, the Linux Foundation, LF Projects or the OpenTofu project.

© 2026 Turf LLC. Free for individuals, education and small businesses within the Community limits, under the Turf Community Edition License 1.0. Government and larger organizations need a commerciallicense.turf.build · Discord ·GitHub