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

# Workflow Composition

> Workflows can call other workflows.

# Workflow Composition

Workflows can call other workflows. This lets you build modular, reusable pipelines.

## Calling a sub-workflow as a step

```yaml theme={null}
steps:
  - name: setup
    workflow: workflows/setup-env
    with:
      project: "{spec.project}"
      target: staging
```

The sub-workflow's state is grafted into the parent under the step's namespace. Run-level metrics (cost, duration, tokens) are cumulated into the parent's run.

## Calling a sub-workflow as a gate (validator)

A workflow with `type: validate` (output = bool) is usable as a gate:

```yaml theme={null}
gate:
  - compile
  - test
  - validate: validators/arch-review
      diff: "{diff}"
      spec: "{spec}"
      agent: claude-opus
```

The validator executes its own GET → RUN → GATE cycle. Its comments are accessible via `{gate.review.comments}`.

## Calling a sub-workflow in GET

A workflow whose output feeds the prompt:

```yaml theme={null}
get:
  prompt: |
    Based on this research: {research.output}
  workflow: research
    query: "best practices for {task.description}"
    agent: claude-haiku
```

The workflow in `get:` executes before the RUN of the current step. Its output enters the state and the prompt can reference it.

## Inputs

Workflows don't declare an `inputs:` block. Required keywords are deduced by Gump by scanning variables. If a required keyword can't be resolved, `--dry-run` raises an error.

Resolution order: explicit values from caller → parent step state → parent workflow state → error.

A called workflow is autonomous — it can be run standalone: `gump run validators/arch-review --set diff=... --set agent=...`.

## State grafting

When a sub-workflow completes, its entire state is grafted under the calling step's namespace. No explicit return — the entire state is the interface.

The parent accesses sub-workflow outputs via:

```
{setup.state.<key>}
```

## Workflow resolution

Cascade: project `.gump/workflows/` → user `~/.gump/workflows/` → built-in `go:embed`.
