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.
The loop
Section titled “The loop”init({ path: "/path/to/app" }) # tofu init: register, install modules + providers, report declarationsopen({ workspace_name: "default" }) # bind the backend + state slot; reports a convergence already holding itup({ var: { region: "eu-west-1" } }) # start: round 1 waits at its plan gate → awaiting_planplan({ convergence_id: "…" }) # plan the round → awaiting_approval, plan.uri + plan.digestapply({ convergence_id: "…", plan_digest: "…" }) # approve THAT plan: apply it → the next round's gate, or an end …output({}) # … until converged; then the root outputsEvery result carries outcome, ended and next — the call that continues it, with its arguments: act on it.
initreports what the configuration declares — backend, workspace, variables, outputs,readme— never resolved values.variables[]markedrequiredhave no default: the environment or a.tfvarsfile 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 firstup. Commit.terraform.lock.hcl: every plan honours it.openderives the backend from the configuration’s own block.backend_configsupplies only what the block leaves out (credentials, per-environment values). Workspaces, backends and locking:references/workspaces.md.- Variable values are
var(tofu -var) andvar_file.openkeeps 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.tfvarsand this server’sTF_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 toopen(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
planandapply. The engine re-reads the configuration before applying; a stale plan is never applied: the convergence endsstale(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_fileandTF_VAR_are pinned with the convergence and never make it stale. Runupagain with the samevarvalues, thenplan, 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).
Approving
Section titled “Approving”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 addremoved { from = … lifecycle { destroy = false } }(skill_authoring); aremovedblock 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) orplanfile.
Outcomes
Section titled “Outcomes”| 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.
Picking up a convergence
Section titled “Picking up a convergence”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 endsstale:upinstead. - 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. upagain 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 aconvergence_id: what is in flight finishes, nothing new starts.
Turf actions
Section titled “Turf actions”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 oneapply.progresssays what you did, a line each; a failure carries at least oneerrordiagnostic saying why; awarningrecords what did not fail the step.if_failedsays 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 inprogress, and report a “no” as a failure. Never answer for them, and never weaken or remove a trigger to get past it. Ahaltstops 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.invocationslisted at approval every action the round runs, per caller in run order; more turf actions on one caller come one pause each.- In a
destroyevery action failure is only a warning: the teardown goes on and endsconverged, the failure inrounds[].actionsand the warnings — so the user’s explicit yes at approval is what guards a destroy. Abefore_destroygate on a delete thatupplans is not downgraded.
Requests, results, invoke, examples: references/turf-actions.md. Declaring one is authoring (skill_authoring → references/actions.md).
Deferrals
Section titled “Deferrals”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.
Other commands
Section titled “Other commands”destroy, refresh, import and invoke are up in another mode: one round each, the same gates.
destroyplans 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-hocactionlaid over it in memory.taint/untaintmark an instance for replacement on the nextup, or clear the mark — immediate state edits.plan({ replace: ["aws_instance.web"] })replaces in that round without editing state.- Planfiles:
plan_only: trueon a start verb ends the roundplanned, its plan kept forapply({ planfile, plan_digest }), here or elsewhere:references/planfiles.md. - Reading:
show(a round’s plan, aplanfile, orwhat: "state"),output,state_list(include_valuesfor 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.
Divergences from Terraform
Section titled “Divergences from Terraform”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.
The /up runbook
Section titled “The /up runbook”Operate on the configuration directory the prompt names. One call at a time: each result before the next.
- init —
init({ path: "<dir>" }), the directory resolved to an absolute path. Readbackend,workspace,variables(note therequiredones),providersandreadme; read any*.turf.hcloverlays with your file tools; scanproviders[]if you have a scanner. - Open the workspace —
open({ workspace_name: "<init's workspace>" }), plusbackend_configonly for credentials the block leaves out. If it reports aconvergence, tell the user and follow Picking up a convergence. - Plan —
up({ var: { … } })with a value for every required variable nothing else supplies (ask the user); it stops at round 1’s plan gate. Thenplan({ convergence_id }). If the outcome isconvergedwith nothing applied, say “All resources up to date.” and stop. - Present — read the plan with
show(redacted) and show:Call out before→after for updates and replacements, never a sensitive value, and every invocation inPlan: 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)plan.invocations(aturf_actionstops the apply for you, and for the user when its prompt says so). Ifplan.deferredis non-zero, say another round follows. Handshow’s document to your policy tool, if any. - 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,applywithdecline. - Converge — at
awaiting_plan,planthe next round, then steps 4 and 5 again (the low-risk test applies afresh), printingRound k: applied N, deferred Mfromrounds[]. Atawaiting_actions, perform the steps and answer withaction_results. Any other outcome: read the Outcomes table and act on it. - 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;closenever undoes anything.
The /destroy runbook
Section titled “The /destroy runbook”- init and open, as in
/up. - Plan the teardown —
destroy({ var: { … } })with the values the configuration needs (a provider’s variable too), thenplan({ 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. - Present it —
Plan: X to destroy, one- <address>per line, forgets as. <address>— and name anything that holds data, and every invocation inplan.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 aremovedblock (skill_authoring), as in Approving; then plan the teardown again. - Ask verbatim: “Ready to destroy these resources? This cannot be undone.” Never approve a destroy plan yourself; proceed only on an explicit yes, and
applywithdeclineon a no. - apply —
apply({ convergence_id, plan_digest }). - Report — “Destroy complete! X resources destroyed.” List anything that failed.
Reference files
Section titled “Reference files”references/plans.md— the plan document and the change symbols.references/turf-actions.md— answering turf actions;invoke.references/deferrals.md— deferral reasons;stalledandexhausted.references/workspaces.md— aliases, backends, locking,list,statusand drift,delete.references/credentials.md— providers’, variables’ and backends’ credentials.references/imports.md— theimporttool and theimport {}block.references/planfiles.md—plan_only,planned,applywithplanfile; plan here, apply there.references/error-handling.md— recovery: plan and apply errors, the engine, locks.references/divergences.md— what is refused or differs from Terraform.references/architecture.md— the MCP server, the engine, the Turf CLI.
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