> ## Documentation Index
> Fetch the complete documentation index at: https://gump.build/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# State Variables

> Complete list of all variables available in prompt templates.

# State Variables

Complete list of all variables available in prompt templates.

## Spec variable

| Variable | Available | Description                   |
| -------- | --------- | ----------------------------- |
| `{spec}` | Always    | Full content of the spec file |

## Step output variables

Available after the referenced step has executed. No `steps.` prefix.

| Variable                        | Description                                                   |
| ------------------------------- | ------------------------------------------------------------- |
| `{<step>.output}`               | Main output: diff (code), tasks JSON (split), bool (validate) |
| `{<step>.diff}`                 | Git diff (code steps)                                         |
| `{<step>.agent}`                | Agent that actually executed (reflects escalation)            |
| `{<step>.session_id}`           | Agent session ID                                              |
| `{<step>.status}`               | `pass`, `fail`, or `fatal`                                    |
| `{<step>.attempt}`              | Final attempt number                                          |
| `{<step>.cost}`                 | Estimated cost in USD                                         |
| `{<step>.duration}`             | Duration in milliseconds                                      |
| `{<step>.turns}`                | Number of cognitive turns                                     |
| `{<step>.tokens_in}`            | Input tokens consumed                                         |
| `{<step>.tokens_out}`           | Output tokens produced                                        |
| `{<step>.gate.<name>}`          | Bool result of a specific gate                                |
| `{<step>.gate.<name>.comments}` | Validator comments                                            |
| `{<step>.gate.<name>.error}`    | Stderr from a deterministic gate                              |

## Task variables (each block)

| Variable             | Description                   |
| -------------------- | ----------------------------- |
| `{task.name}`        | Task name from the split JSON |
| `{task.description}` | Task description              |
| `{task.files}`       | Task blast radius             |

## Retry variables

| Variable                      | Description                                   |
| ----------------------------- | --------------------------------------------- |
| `{error}`                     | Gate stderr (truncated to 2000 chars)         |
| `{diff}`                      | Failed attempt diff (truncated to 3000 chars) |
| `{attempt}`                   | Current attempt number                        |
| `{gate.<name>}`               | Bool result of a gate                         |
| `{gate.<name>.comments}`      | Validator comments                            |
| `{gate.<name>.error}`         | Gate stderr                                   |
| `{prev.output}`               | Output from previous retry iteration          |
| `{prev.gate.<name>.comments}` | Previous iteration validator comments         |

## Sub-workflow variables

| Variable               | Description                       |
| ---------------------- | --------------------------------- |
| `{<step>.state.<key>}` | Value from a sub-workflow's state |

## Scope resolution

Strict: step local → each scope → workflow scope. Ambiguity = dry-run error.

## Template escaping

| Syntax       | Result                  |
| ------------ | ----------------------- |
| `{variable}` | Resolved from the state |
| `{{`         | Literal `{`             |
| `}}`         | Literal `}`             |

Empty variables on a line alone → line removed.
