Get started

Reference Workflows 06 / 06

Codegen step

Run a self-contained generated script against the page. A step a recorded Writ workflow can run, with its fields and an example.

Runs on Writ CloudWrit Desktop

Open in Claude Open in ChatGPT

The codegen step executes a self-contained script that manipulates the page — the output of the code-generation path, saved as a replayable step. Where evaluate reads a value back, codegen acts.

In a workflow, this step is a JSON object with "type": "codegen". Steps run in order, and each step can read the outputs of the steps before it.

Fields

Set these inside the step’s config object.

script string required
The generated, self-contained script to execute on the page.

Example

One codegen step, as it appears in the steps list of a workflow.

Step
{
  "type": "codegen",
  "config": { "script": "document.querySelector('#load-more').click()" }
}

How it behaves

  • The step fails cleanly if the script is empty or throws.
  • Prefer recorded steps where possible — they are easier to read and repair.

Where it runs

The step runs wherever its workflow runs. On Writ Desktop, runs are free and can reach systems that only your own network can reach.

On Writ Cloud, each call costs credits: 20 when the run needs a browser, 2 when it does not. A call that fails because of the site or Writ costs nothing.

Next