Writing configurations with an agent
Ask your agent for infrastructure in plain words and it writes the configuration: ordinary .tf
files in a directory you name, edited with the agent’s own file tools. Turf™ has no authoring tools.
The files are the declaration. You can read them, check them into git, run them anywhere Terraform®
runs, and reopen them next session.
skill_authoringinit→okprovider_search→hashicorp/aws
I registered ~/infra/artifacts and pinned hashicorp/aws in versions.tf. Installing it
first, so I write against the schema of the version that will run.
init→lock_file createdprovider_describe→aws_s3_bucketprovider_describe→aws_s3_bucket_versioning
I wrote three files, all yours to keep in git:
versions.tf: the AWS provider, pinnedmain.tf: the bucket, with versioning onvariables.tf:bucket_name, with no default
Want me to plan it? I’ll need a bucket name.
illustrative · the shape of a session, not a transcript
The authoring skill
Section titled “The authoring skill”Before your agent writes or changes a .tf or *.turf.hcl file, it loads skill_authoring. That
is an MCP tool with no arguments, not a client-side skill; the server’s instructions tell the agent
to load it before it writes. It covers the loop around HCL and where Turf differs; the agent already knows
HCL. Its reference files cover providers,
variables, data sources,
lifecycle, actions and overlays
and what agent memory may hold.
skill_deployment comes first in any session: it runs what the agent writes. An agent with no file
tool can still run an existing configuration (plan, apply, destroy, import, refresh, invoke), but
writing one needs a file tool.
The loop
Section titled “The loop”init({ path: "/Users/you/infra/artifacts" }) # registers the directory; an absent one is created, with a .gitignore …write versions.tf, main.tf… # the agent's own file toolsinit({ path: "/Users/you/infra/artifacts" }) # again: installs providers and modules, writes the lock fileopen({}) # the backend comes from the filesup({}) # stops at round 1's plan gateplan({ convergence_id: "…" }) # the plan of the whole directory, at its approval point …edit, then up again # a new up supersedes the paused run- Every plan is the whole directory. To change a plan, the agent edits the files and runs
upagain. There is no per-resource planning call. - No edits while a plan waits for approval. The engine checks the files again before applying,
and a plan whose files changed is never applied: it ends
stale. initagain after a new provider ormoduleblock. It installs them and updates the lock file.- Errors name a file and a line. The agent fixes the file and runs
upagain. - No rewriting to force convergence. A value known only after an apply defers to the next round,
which
applyplans by itself; the agent does not hard-code it or split the work.
The files are yours
Section titled “The files are yours”The agent changes them only when you ask, and says what it changed: which files, and whether it added, changed or removed something.
- Files you wrote. The agent reads them first, makes the smallest edit that does the job, and keeps your layout, naming and comments. A new concern goes in a new file rather than a restructured one.
- The why, as a comment. The agent records the request, constraint or policy behind a block in a comment above it. Nothing else carries it across sessions.
- Declining keeps the edits. Declining a plan never reverts the files. Use git when you want the edits gone too.
- Memory holds pointers. Agent memory keeps the directory’s path, the backend and workspace, your
intent and the names of the credentials. Never the configuration, secrets, computed values or
plan digests: the directory is the record, and
initon its path rediscovers everything.
Setting values is deployment
Section titled “Setting values is deployment”Setting variable values (var, var_file, a .tfvars line) is deployment, not authoring. The
agent passes values to open and to each plan command; see
Variables and var files and
Variables and TF_VAR_.
Secrets never go in a file
Section titled “Secrets never go in a file”- Provider credentials go in the engine’s environment,
in a variable the server sends by name, or in a
sensitivevariable passed asvaron each plan command. - Backend credentials stay out of the
backendblock, inopen’sbackend_config. - A secret a resource needs goes only to a write-only argument, fed by an ephemeral variable or
an
ephemeralresource. Anything else keeps the secret in state forever.
A conventional layout
Section titled “A conventional layout”Turf does not require it, but it is the layout most readers expect:
| File | Holds |
|---|---|
versions.tf |
terraform { required_providers { … } backend "…" { … } }, each provider pinned ~> MAJOR.MINOR |
providers.tf |
provider blocks, one per aliased instance |
variables.tf |
variable blocks |
main.tf, or one file per concern |
resources, data sources, modules, locals |
outputs.tf |
output blocks |
*.turf.hcl |
Turf overlays: action and top-level action_trigger blocks, which tofu and terraform ignore |
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