# How a flow is shaped

The simple rules behind branching, merging and looping, and why every flow keeps one clear trunk.

Source: https://support.rework.com/article/how-a-flow-is-shaped

A flow can fork, loop and wait, but not in just any shape you like. The app enforces a few rules about how paths open and close, and it checks them before it lets you publish. They're there so that a run always has one clear place it's up to. That's what makes a run easy to read after the fact, and a failure easy to find.

## One trunk, and only two ways to fork

Every step has one outgoing line. A step can't quietly split the flow in two. Only two steps are allowed to open more than one path:

- **Branches** sends the run down the arms whose conditions match.
  
- **Loop** has one path that runs once per item and one that continues after the loop.
  

Everything else, actions and filters alike, continues to exactly one next step. So at any moment you can read the flow as a single trunk with a couple of clearly marked forks.

![A branch with three arms coming back together at a merge](https://storage.googleapis.com/reworkv3-public/success/260923/Elg42Gdg00SnerIThaDKkrJFnnFnwokaN5QLpMqGjyl7RDcZedpUT1CcGqqlB3Mc/img.EstspW0BhCf9DnQyY1NXxRajpzw64Q2LMmbw3N8H5oAIyaQElYysVzuGf4GAMgii.png)

## Every branch comes back together

The arms a **Branches** step opens must meet again at one **Merge** step, or every arm must end the flow on its own. There's no way to leave two loose ends running side by side. When you add a branch, the builder adds the matching merge for you and keeps whatever came after the branch attached to that merge.

The **Merge** step decides when to carry on: **Wait for all branches** waits until every arm that ran has finished, while **Wait for any branch** continues as soon as the first one arrives.

Arms whose conditions didn't match are marked **Skipped** in the run, so the merge is never left waiting for a path that was never taken.

## A loop has a body and a continuation

A **Loop** step has two outgoing paths, and they mean different things:

| Path | Runs |
| --- | --- |
| **Loop body** | Once for each item in the list you gave it |
| After the loop | Once, after the last item, continuing the trunk |

Inside the body you refer to the item the loop is currently on, so the same steps do the same work with different data each time. See [Loop over a list of items](https://support.rework.com/article/loop-over-a-list-of-items).

![A loop with its body path and its continuation](https://storage.googleapis.com/reworkv3-public/success/260923/aiC3OpdXjtOMNkaAAx6snwbKO7OyCE3SqtWXoZCOgMWqbJqis9K4QZJrZoUmnBkY/img.wDAWKOY1nKzzdr0RAtRoBOpqhmA9O5gx3MATniELWnWMJX1rRFcHkT3QPScowwji.png)

## A filter ends a path without failing it

**Only continue if** keeps a single outgoing line, so it isn't a fork. When its condition doesn't hold, the run simply stops there, and it's still recorded as **Completed**. Nothing went wrong: there was just nothing further to do for this event. That's how an automation can ignore the events it doesn't care about without filling your history with failures. See [Stop a run with a filter](https://support.rework.com/article/stop-a-run-with-a-filter).

## What the app checks before publishing

| Rule | What it means in practice |
| --- | --- |
| One trigger | The flow starts at exactly one trigger step. |
| One line out | Only **Branches** and **Loop** may open more than one path. |
| Branches reconverge | Every arm meets at one **Merge**, or ends the flow. |
| Required fields filled | No step is left with an empty required field. |

A flow that breaks a rule can't be published. 💡 An already published flow keeps running exactly as it is until you fix the draft and publish again.
