Skip to content

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.

✦Your agentin Claude Code
You
Write a configuration in ~/infra/artifacts for a versioned S3 bucket for our build artifacts.
Agent
  • skill_authoring
  • init→ok
  • provider_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.

Agent
  • init→lock_file created
  • provider_describe→aws_s3_bucket
  • provider_describe→aws_s3_bucket_versioning

I wrote three files, all yours to keep in git:

  • versions.tf: the AWS provider, pinned
  • main.tf: the bucket, with versioning on
  • variables.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

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.

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 tools
init({ path: "/Users/you/infra/artifacts" }) # again: installs providers and modules, writes the lock file
open({}) # the backend comes from the files
up({}) # stops at round 1's plan gate
plan({ 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 up again. 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.
  • init again after a new provider or module block. It installs them and updates the lock file.
  • Errors name a file and a line. The agent fixes the file and runs up again.
  • No rewriting to force convergence. A value known only after an apply defers to the next round, which apply plans by itself; the agent does not hard-code it or split the work.

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 init on its path rediscovers everything.

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_.

  • Provider credentials go in the engine’s environment, in a variable the server sends by name, or in a sensitive variable passed as var on each plan command.
  • Backend credentials stay out of the backend block, in open’s backend_config.
  • A secret a resource needs goes only to a write-only argument, fed by an ephemeral variable or an ephemeral resource. Anything else keeps the secret in state forever.

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