file:write

Writes or appends content to a file, optionally deleting it first

Options

NameTypeDescription
pathstringDestination file path
appendboolWhen true, content is appended to the existing file instead of overwriting
contentanyThe content to write; must be a string or []byte
deleteboolWhen true, deletes the file before writing (ignored when Append is true)

Outputs

NameTypeDescription
pathstringThe path of the written file

Examples

name: Write a model's answer to disk
actions:
  - name: answer
    component: inference
    vars:
      provider: openai
      model: gpt-5
      prompt: "{{ var.prompt }}"

  - name: saved
    component: file:write
    vars:
      path: ./out/answer.md
      content: "{{ answer.content }}"

outputs:
  path: "{{ saved.path }}"

Append

Appends to a file instead of replacing it. With append: true the existing content stays and the new content lands after it, which suits run logs and growing exports.

name: Append to a run log
actions:
  - name: log_line
    component: file:write
    vars:
      path: ./runs.log
      append: true
      content: "{{ var.run_id }} finished\n"

outputs:
  path: "{{ log_line.path }}"