Scripting with exec
turf exec runs a single plain-language request without the TUI and streams the run to stdout. It is
how you drive Turf™ from a script, a CI job or another agent: the same model and tools as
turf chat, headless.
# A message argument: quoting is optional, the words are joined into one requestturf exec create a random_pet named demoturf exec "create a random_pet named demo"
# Use -- for a message that begins with a dashturf exec -- --dry-run first, then apply
# Read the request from stdinecho "what workspaces exist?" | turf execturf exec - < request.txtWith a terminal and no message, turf exec starts a plain readline prompt loop instead. Set the model
with --model (Model providers), and the directory with -C.
Exit status
Section titled “Exit status”The process exits non-zero if the run fails, so exec composes with ordinary shell error handling:
set -e, &&, CI steps.
–json: a machine-readable event stream
Section titled “–json: a machine-readable event stream”With --json, turf prints one JSON object per line for every runtime event (agent text, tool calls,
tool results, warnings, errors) instead of formatted text. Model prose changes from run to run; match
on structure instead, such as which tools ran and whether an error occurred.
# Which Turf tools did the run call?turf exec --json "create a random_pet" | jq -r 'select(.type=="tool_call") | .tool_call.function.name'
# A failed run exits non-zero; its error goes to stderr, not into the event streamturf exec --json "reconcile the stack" > events.jsonl || echo "run failed" >&2--hide-tool-calls goes the other way: it prints only the agent’s prose.
–yes: unattended runs
Section titled “–yes: unattended runs”exec is non-interactive, so nobody can answer the agent’s approval questions. Without --yes they
are declined: anything that needs your yes, such as a destroy, a replace, an import or an invoke, is
not applied and stays waiting at its approval point, where a later interactive turf can pick it up.
The agent still approves a low-risk plan itself (creates and in-place updates only), as it does at a
terminal.
--yes (alias --auto-approve) answers those questions yes, and approves any other tool call that
would ask on stdin, so the run goes ahead with no one at the keyboard. Nothing is approved up front on
the server’s side: the agent still plans each round and approves each plan by its digest, so a --yes
destroy is one the agent saw the plan of. Turf’s own tools never ask for permission.
The same rule holds for turf up and turf destroy run without a terminal
(Up and destroy).
Resume a session
Section titled “Resume a session”exec takes --session <id|-N> and --continue (-c), as turf chat does, so a script can carry
one conversation across several requests (Sessions).
Runs with no cloud
Section titled “Runs with no cloud”exec still launches turf-mcp-server, so the server must be on PATH
(Overview). For repeatable runs with no cloud credentials or cost, point
it at HCL that uses OpenTofu® providers that need no credentials: null, local, random, tls.
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