# Language Reference

FractalForm diagrams are plain-text scripts for animated system diagrams. A minimal diagram can be one edge:

```
client -> api: GET /users
api -> client: 200 OK
```

Edges and state updates create components automatically. Add declarations, phases, notes, overlays, artifacts, playback directives, and control blocks only when the diagram needs them.

## Quick reference

<div class="quick-ref-wrap">
<div class="quick-ref-grid">
<div class="quick-ref-head">Construct</div>
<div class="quick-ref-head">Minimal form</div>
<div class="quick-ref-head">Examples</div>
<div class="quick-ref-cell quick-ref-construct"><a href="#components">Component</a></div>
<div class="quick-ref-cell"><code># bare declaration
component api</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># with title
component api "API"</code><code># title, shape, icon, tags
component api "API" shape:hexagon icon:server [backend]</code><a href="#components">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#components">Component description</a></div>
<div class="quick-ref-cell"><code># trailing marker opens a body
# indented lines render as markdown
component api "API":
  Handles HTTP ingress.</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># guide bar marker
component api "API":
  Handles requests.
  - validates input</code><code># brace marker
component policy "Policy" }
  Never trusts metadata.</code><a href="#components">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#edges">Edge</a></div>
<div class="quick-ref-cell"><code># simple edge
api -> db</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># with label
api -> db: SELECT users</code><code># with modifier and color
api -> upstream: timeout edge:dropped,#ff4d4f</code><a href="#edges">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#edges">Chained edge</a></div>
<div class="quick-ref-cell"><code># expands to adjacent pairs
client -> api -> db</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># mixed arrow types
client -> api --> cache ->> queue</code><a href="#edges">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#edges">Arrow styles</a></div>
<div class="quick-ref-cell"><code># synchronous
-></code></div>
<div class="quick-ref-cell quick-ref-examples"><code># optional
--></code><code># weak
..></code><code># streaming
~></code><code># async fire-and-forget
->></code><code># bidirectional
&lt;-&gt;</code><a href="#edges">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#edges">Fan-out / fan-in</a></div>
<div class="quick-ref-cell"><code># one-to-many
api -> [worker-a, worker-b]</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># fan-out with label
api -> [worker-a, worker-b]: job</code><code># fan-in
[service-a, service-b] -> api: result</code><a href="#edges">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#groups">Group</a></div>
<div class="quick-ref-cell"><code># visual boundary
group
  ...
end</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># display name only
group "Backend"</code><code># key, name, shape, icon
group infra "Infra" shape:rect icon:cloud</code><a href="#groups">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#text">Text</a></div>
<div class="quick-ref-cell"><code># free-floating canvas annotation
text title "Request Flow"</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># with shape and color
text title "Request Flow" shape:rect,solid,xl,#info</code><code># markdown body
text:
  **Legend:** public request path</code><a href="#text">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#state">State</a></div>
<div class="quick-ref-cell"><code># component content update
api: Processing request</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># structured data
api: {status: ok}</code><code># markdown body
api:
  Handles **requests**</code><a href="#state">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#phases">Phase</a></div>
<div class="quick-ref-cell"><code># phase: Authentication</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># phase: Authentication
# Validates credentials and issues a token.</code><code># phase: Token refresh
# Exchanges a valid refresh token for a new access token.</code><a href="#phases">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#notes">Note</a></div>
<div class="quick-ref-cell"><code># note: Text</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># note pause: Text</code><code># auto-dismiss after 3s
# note 3s: Text</code><code># auto-numbered
# note n: Text</code><a href="#notes">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#overlays">Overlay</a></div>
<div class="quick-ref-cell"><code># canvas-level message
# overlay: Text</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># overlay: This is a basic overlay</code><code># overlay pause: &lt;icon:clock&gt; Wait for the viewer</code><a href="#overlays">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#artifacts">Artifact</a></div>
<div class="quick-ref-cell"><code># artifact travels with the message
api -> user: ... %jwt</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># full declaration
artifact jwt "JWT Token" icon:key-round</code><code># named instance
%jwt#admin</code><a href="#artifacts">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#visibility">Visibility</a></div>
<div class="quick-ref-cell"><code># dim a component
--dim api</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># restore
--show api</code><code># remove from canvas
--hide legacy</code><code># ghost outline
--outline future-service</code><a href="#visibility">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#clear">Clear</a></div>
<div class="quick-ref-cell"><code># clear all state
--clear</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># clear specific components
--clear api, cache</code><code># clear an artifact
--clear %jwt</code><a href="#clear">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#timing">Timing</a></div>
<div class="quick-ref-cell"><code># insert a delay
--wait 2s</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># change step duration
--step 750ms</code><code># set playback speed
--speed 5</code><code># reset to default
--speed</code><a href="#timing">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#autonumber">Autonumber</a></div>
<div class="quick-ref-cell"><code># enable from 1
--autonumber</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># start from 10
--autonumber 10</code><code># disable
--autonumber off</code><a href="#autonumber">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#repeat">Repeat</a></div>
<div class="quick-ref-cell"><code># loop N times
repeat 3
  ...
end</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># counted loop
repeat 3</code><code># inline detached repeat
*repeat heartbeat</code><a href="#repeat">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#parallel">Parallel</a></div>
<div class="quick-ref-cell"><code># concurrent commands
parallel
  ...
end</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># fetch from cache and database together
parallel
  api -> cache: read user
  api -> db: SELECT user
end</code><a href="#parallel">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#blocks-and-detach">Block / detach</a></div>
<div class="quick-ref-cell"><code># reusable block
block healthcheck
  ...
end</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># invoke
@healthcheck</code><code># run in background
--detach @healthcheck</code><code># wait for completion
--attach @healthcheck</code><a href="#blocks-and-detach">More…</a></div>
<div class="quick-ref-cell quick-ref-construct"><a href="#variables">Variable</a></div>
<div class="quick-ref-cell"><code># set a variable
$state: value</code></div>
<div class="quick-ref-cell quick-ref-examples"><code># set a field to 0
$state.count: 0</code><code># increment
$state.count++</code><a href="#variables">More…</a></div>
</div>
</div>

## Syntax families

| Family | Form | Purpose |
|--------|------|---------|
| Narration comments | `# phase:`, `# note:`, `# overlay:` | Visible timeline narration and navigation. |
| Visual directives | `shape:...`, `icon:...`, `edge:...`, `[tags]` | Typed visual metadata for components, groups, text, edges, and tags. |
| Playback directives | `--wait`, `--step`, `--speed`, `--clear`, `--dim`, `--show`, `--hide`, `--outline`, `--autonumber`, `--detach`, `--attach` | Timeline, visibility, timing, numbering, and background work control. |
| Control blocks | `repeat`, `parallel`, `block`, `*block`, `*repeat` | Group commands for loops, concurrency, reuse, and detached work. |

## Components

Declare named topology nodes. Edges and state updates auto-create components, so declarations are only needed for custom labels, shapes, icons, tiers, tags, descriptions, or hierarchy. Examples: [Components](/?example=fractalform_components), [Descriptions](/?example=fractalform_descriptions).

Syntax:

<div class="syntax-tmpl"><span class="kw">component</span> <span class="ph">key</span> <span class="ph">"Display Name"</span> <span class="kw">shape:</span><span class="ph">shape,tier,modifier</span> <span class="kw">icon:</span><span class="ph">name,modifier</span> <span class="kw">[</span><span class="ph">tags</span><span class="kw">]</span></div>

| Parameter | Description | Example |
|-----------|-------------|---------|
| `key` | Required identifier | `component api` |
| `"Display Name"` | Quoted label | `component api "API Gateway"` |
| `shape:shape,tier` | Shape and visual tier | `component api shape:hexagon,xl` |
| `shape:shape,many` | Stacked pool/replica rendering | `component workers shape:hexagon,many` |
| `icon:name,badge` | Icon with optional badge mode | `component api icon:server,badge` |
| `[tags]` | Comma-separated visual metadata | `component api [backend, gateway]` |

Aliases: `c`.

Shapes: `default`, `circle`, `database`, `hexagon`, `diamond`, `note`, `actor`, `icon`, `cloud`, `browser`, `server`, `funnel`, `code`.

Tiers: `xl`, `lg`, `md` (default), `sm`, `xs`.

```
# full declaration
component api "API Gateway" shape:hexagon,xl icon:server,badge [backend, gateway]
component db "PostgreSQL" shape:database,lg icon:postgresql,badge [storage]

# pools and replicas
component workers "Workers" shape:hexagon,many
component replicas "Read Replicas" shape:database,lg,many

# tier-only (default shape)
component important "Important" shape:lg
```

### Descriptions

Add a trailing `:`, `|`, `]`, or `}` and indented markdown for permanent descriptions. Descriptions render beside the node and are not cleared by `--clear`.

| Marker | Style |
|--------|-------|
| `:` or `|` | Guide bar |
| `]` | Bracket |
| `}` | Brace |

```
# guide bar (: marker)
component api "API Gateway" shape:hexagon,xl:
  Handles public HTTP ingress and authentication.

# bracket (] marker)
component policy "Policy" ]
  Never trusts tenant-provided ownership metadata.

# brace (} marker)
component worker "Worker" }
  - uses tools
  - runs in a loop
```

### Key hierarchy

Dots create child components inside a parent. Double dots create related components that render separately but stay visually attached. Examples: [Member](/?example=fractalform_member), [Related](/?example=fractalform_related).

```
# child components
component app "App"
component app.cpu "CPU"
component app.mem "Memory"

# related (renders separately, visually attached)
component app "App"
component app..logs "App Logs"
app -> app..logs: write logs
```

## Edges

Define connections between components. Edges auto-create undeclared components. Examples: [Edges](/?example=fractalform_edges), [Arrow styles](/?example=fractalform_arrow-styles), [Chained edges](/?example=fractalform_chained-edges), [Fan-out & Fan-in](/?example=fractalform_fan-out-fan-in), [Bidirectional edges](/?example=fractalform_bidirectional-edges).

Syntax:

<div class="syntax-tmpl"><span class="ph">source</span> <span class="kw">-></span> <span class="ph">target</span><span class="kw">:</span> <span class="ph">label</span></div>

| Arrow | Meaning |
|-------|---------|
| `->` | Synchronous call |
| `-->` | Optional or conditional |
| `..>` | Inferred or weak |
| `~>` | Streaming |
| `->>` | Async fire-and-forget |
| `-->>` | Async optional |
| `..>>` | Async weak |
| `<->` | Bidirectional |
| `<-->` | Bidirectional optional |
| `<..>` | Bidirectional weak |
| `<~>` | Bidirectional streaming |

```
# labeled edge
api -> db: SELECT users

# chained edges
client -> api -> db

# mixed arrow types
client -> api --> cache ->> queue

# fan-out
api -> [worker-a, worker-b, worker-c]: dispatch job

# fan-in
[service-a, service-b] -> aggregator: results

# bidirectional
client <-> server: WebSocket message
```

### Edge modifiers

Inline modifiers control edge appearance. Example: [Edge Icons & Modifiers](/?example=fractalform_edge-icons-modifiers).

| Modifier | Effect | Example |
|----------|--------|---------|
| `<icon:name>` | Icon on the edge | `api -> db <icon:zap>: fast query` |
| `<icon:name #color>` | Colored icon | `db -> api: rows <icon:check #success>` |
| `edge:dropped` | Particle drops at midpoint | `api -> upstream: timeout edge:dropped,#error` |
| `edge:#color` | Colors the edge | `api -> db: degraded edge:#warning` |

```
api -> db <icon:zap>: fast query
db -> api: rows <icon:check #success>
api -> upstream: timeout edge:dropped,#error
api -> db: degraded edge:#warning
```

## Icons and colors

Icons support [Lucide](https://lucide.dev), brand, and AWS icon names with optional color and size. Declarations use bare `icon:name`; inline narration uses `<icon:name #color size>`.

| Parameter | Values |
|-----------|--------|
| Sizes | `xs`, `sm`, `md`, `lg`, `xl` |
| Semantic colors | `#success`, `#error`, `#warning`, `#info` |
| Palette colors | `#red`, `#blue`, `#green`, `#yellow`, `#purple`, `#gray`, `#orange`, `#pink`, `#cyan`, `#primary`, `#secondary` |
| Hex colors | `#rgb`, `#rrggbb`, `#rrggbbaa` |

```
# in edge labels
api -> db: query <icon:database #info>
api -> client: failed <icon:x #error xl>

# in overlays
# overlay: <icon:clock #warning> Token expires

# in declarations
group aws icon:cloud,#info
component api icon:server,badge
```

## Tags

Visual metadata on components. Tags do not change behavior. Use them for role, ownership, environment, or status. Optionally colored.

Syntax:

<div class="syntax-tmpl"><span class="kw">component</span> <span class="ph">key</span> <span class="kw">[</span><span class="ph">tag1, tag2 #color</span><span class="kw">]</span></div>

```
component api "API" [backend, gateway]
component payments "Stripe" [external, payments #info]
component legacy "Legacy API" [deprecated #warning]
```

## Text

Canvas-level annotation (titles, labels, legends, callouts). Not topology. Example: [Text](/?example=fractalform_text).

Syntax:

<div class="syntax-tmpl"><span class="kw">text</span> <span class="ph">id</span> <span class="ph">"Display Text"</span> <span class="kw">shape:</span><span class="ph">shape,stroke,tier,color</span></div>

| Parameter | Description | Example |
|-----------|-------------|---------|
| `id` | Optional identifier | `text title "Request Flow"` |
| `"Display Text"` | Quoted label | `text title "Request Flow"` |
| `shape:shape,modifiers` | Shape, stroke, tier, color | `text title "Title" shape:rect,solid,xl,#info` |
| Markdown body | `text:` followed by indented lines | See below |

Aliases: `t`.

Shapes: `rect` (default), `circle`, `diamond`, `hex`, `ellipse`. Stroke modifiers: `solid`, `dashed`, `dotted`.

```
# inline text
text title "Request Flow" shape:rect,solid,xl,#info
text subtitle "One request through the backend"

# with markdown body
text warning "Dotted ellipse" shape:ellipse,dotted,#warning:
  Text bodies support **Markdown**.
  - headings
  - lists
  - inline `code`

# inside a group
group annotation-zone shape:rect,dashed,#blue
  text:
    Group-level annotation.
  title
end
```

## State

Set content on a component node. Examples: [State](/?example=fractalform_state), [Structured Data](/?example=fractalform_structured-data), [Markdown](/?example=fractalform_markdown).

Syntax:

<div class="syntax-tmpl"><span class="ph">component</span><span class="kw">:</span> <span class="ph">content</span></div>

| Form | Description | Example |
|------|-------------|---------|
| Text | Plain text state | `api: Processing request` |
| Literal | Backtick-wrapped raw string | See below |
| Structured | Curly brace object | `api: {status: ok, count: 42}` |
| Markdown body | Indented lines after `key:` | See below |
| Code block | Triple backticks with optional lang | See below |
| Adornment | `node:destroyed` modifier | `session: <icon:trash-2> destroyed node:destroyed` |

Common structured data shapes (see [Content formats](/?example=content-formats)):

| Shape | Structure |
|-------|-----------|
| Headline | `{text: "Processing"}` |
| Key-value rows | `{status: ok, queue_depth: 12}` |
| Bullet list | `{tasks: ["one", "two"]}` |
| Key/value entries | `{headers: [[Content-Type, application/json]]}` |
| Metrics | `{metrics: [{name: latency, value: 42, unit: ms}]}` |
| Table | `{users: [{name: alice, role: admin, active: true}]}` |
| Error panel | `{error: {code: 404, message: "Not found"}}` |
| Collapsible section | `{cache: {hits: 12, misses: 3}}` |

```
# text state
api: Processing request

# structured data
api: {
  status: "ok",
  count: 42
}

# markdown body
api:
  Handles **requests**.
  - validates input
  - emits events
```

````
# code block with language
api: ```json
{
  "status": "ok",
  "data": [1, 2, 3]
}
```
````

## Phases

Label sections of the timeline for navigation. Example: [Phases](/?example=fractalform_phases).

Syntax:

<div class="syntax-tmpl"><span class="kw"># phase:</span> <span class="ph">title</span>
<span class="kw">#</span> <span class="ph">description line</span></div>

| Feature | Syntax |
|---------|--------|
| Phase header | `# phase: Authentication` |
| Description | Comment lines immediately after the phase |

```
# phase: Authentication
# Validates credentials and issues a token.
client -> auth: POST /login
```

## Groups

Draw visual boundaries around components and canvas text. Examples: [Groups](/?example=fractalform_groups), [Nested Groups](/?example=fractalform_nested-groups).

Syntax:

<div class="syntax-tmpl"><span class="kw">group</span> <span class="ph">key</span> <span class="ph">"Display Name"</span> <span class="kw">shape:</span><span class="ph">shape,modifiers</span> <span class="kw">icon:</span><span class="ph">name,color</span>
  <span class="ph">members</span>
<span class="kw">end</span></div>

| Parameter | Description | Example |
|-----------|-------------|---------|
| `key` | Addressable identifier | `group infra` |
| `"Display Name"` | Quoted label | `group "Backend"` |
| Key and name | Both together | `group infra "Infrastructure"` |
| `shape:shape,modifiers` | Shape, stroke, tier, color | `group infra shape:rect,dashed,#blue` |
| `icon:name,color` | Icon with optional color | `group infra icon:cloud,#info` |

Aliases: `g`, `box`, `b`.

Shapes: `rect` (default), `circle`, `diamond`, `hex`, `ellipse`. Inside group bodies, the `component` keyword is optional.

```
# named group with members
group "Backend"
  api "API" shape:hexagon
  db "Database" shape:database
end

# with icon
group contact-center icon:aws-connect,#info
  text:
    Owned by support operations.
  api
end

# styled, no members yet
group agents shape:solid
```

## Notes

Attach explanation to the next timeline command. Examples: [Notes](/?example=fractalform_notes), [Numbered notes](/?example=fractalform_numbered-notes).

Syntax:

<div class="syntax-tmpl"><span class="kw"># note</span> <span class="ph">pause</span> <span class="ph">number</span> <span class="ph">duration</span><span class="kw">:</span> <span class="ph">text</span></div>

| Modifier | Effect | Example |
|----------|--------|---------|
| *(none)* | Basic note | `# note: Text` |
| `pause` | Manual advance required | `# note pause: Read this first.` |
| `3s` | Auto-dismiss after duration | `# note 3s: Stripe responds after fraud checks.` |
| `1` | Explicit action number | `# note 1: User makes request` |
| `n` | Next auto-number | `# note n: Server validates input` |
| Combined | Any order | `# note pause n 5s: Inspect the retry` |

```
# basic note
# note: Redis avoids a full Postgres round-trip here.
api -> cache: GET session

# timed note
# note 3s: Stripe responds after fraud checks.
api -> payments: charge card

# manual advance
# note pause: Read this before the next step.
api -> db: SELECT users
```

## Overlays

Canvas-level messages for scenario transitions, time skips, or major status changes. Example: [Overlays](/?example=fractalform_overlays).

Syntax:

<div class="syntax-tmpl"><span class="kw"># overlay</span> <span class="ph">pause</span><span class="kw">:</span> <span class="ph">text</span></div>

| Feature | Syntax |
|---------|--------|
| Basic | `# overlay: 5 hours later` |
| With pause | `# overlay pause: Database unreachable` |
| With icon | `# overlay: <icon:clock> 5 hours later` |
| With icon and color | `# overlay: <icon:alert-triangle #warning> Database unreachable` |
| Description | Comment lines immediately after the overlay |

```
# overlay: <icon:clock> 5 hours later
# overlay pause: <icon:alert-triangle #warning> Database unreachable
```

## Comments

Plain `#` comments do not render. Special forms `# phase:`, `# note:`, and `# overlay:` create visible timeline content.

```
# This is a source comment.
# It does not render by itself.
```

## Artifacts

Data objects with identity that travel between components. Declarations are optional; using `%key` in an edge label creates the artifact automatically. Example: [Artifacts](/?example=fractalform_artifacts).

Syntax:

<div class="syntax-tmpl"><span class="kw">artifact</span> <span class="ph">key</span> <span class="ph">"Display Name"</span> <span class="kw">icon:</span><span class="ph">name</span></div>

| Feature | Syntax | Example |
|---------|--------|---------|
| Declaration | `artifact key "Name"` | `artifact jwt "JWT Token" icon:key-round` |
| Attach to edge | `%key` in label | `user -> api: GET /profile %jwt` |
| Instance | `%key#id` | `%order#123` |
| Set state | `%key: { ... }` | `%jwt: {sub: "user123", exp: 3600}` |
| Clear | `--clear %key` | `--clear %jwt` |

```
# declare and use
artifact jwt "JWT Token" icon:key-round
auth -> user: issue %jwt
%jwt: {sub: "user123", exp: 3600}
user -> api: GET /profile %jwt

# instances
%order#123: {status: "paid"}
%order#456: {status: "pending"}
api -> queue: publish %order#123
```

## Playback directives

### Clear

Reset component state, artifact state, or everything. Example: [Clear](/?example=fractalform_clear).

| Form | Effect |
|------|--------|
| `--clear` | Clear all component state |
| `--clear api, cache` | Clear specific components |
| `--clear %jwt` | Clear an artifact |

```
--clear
--clear api, cache
--clear %jwt
```

### Visibility

Control component visibility. Example: [Visibility](/?example=fractalform_visibility).

| Form | Effect |
|------|--------|
| `--dim targets` | Dim components |
| `--show targets` | Restore full visibility |
| `--hide targets` | Remove from canvas |
| `--outline targets` | Ghost outline |
| `--dim` | Dim all (no targets) |
| `--show` | Show all (no targets) |

```
--dim cache
--show cache
--hide legacy
--outline future-service

# apply to all
--dim
--show
```

### Timing

Control playback speed and delays. Example: [Timing controls](/?example=fractalform_repeat-speed).

| Form | Effect |
|------|--------|
| `--wait duration` | Insert a delay |
| `--step duration` | Change default step duration |
| `--step` | Reset step to default |
| `--speed multiplier` | Set playback speed |
| `--speed` | Reset speed to default |

```
--wait 500ms
--wait 2s
--step 750ms
--speed 5
--speed
```

### Autonumber

Add sequential action badges to sends, receives, and state updates. Example: [Autonumbering](/?example=fractalform_autonumbering).

| Form | Effect |
|------|--------|
| `--autonumber` | Enable from 1 |
| `--autonumber 10` | Start from 10 |
| `--autonumber off` | Disable |

```
--autonumber
--autonumber 10
--autonumber off
```

<span id="blocks-and-detach"></span>

### Detach and attach

Run blocks in the background. Example: [Blocks](/?example=fractalform_blocks).

| Form | Effect |
|------|--------|
| `--detach @block` | Start block in background |
| `--attach @block` | Wait for background block |

```
--detach @healthcheck
api -> db: query
--attach @healthcheck
```

## Control blocks

### Repeat

Loop a set of commands. Example: [Repeat & Speed](/?example=fractalform_repeat-speed).

| Form | Effect |
|------|--------|
| `repeat n ... end` | Loop N times |
| `*repeat name ... end` | Inline detached repeat (runs until attached or timeline ends) |

```
repeat 3
  client -> api: retry
  api -> client: 503
end

*repeat heartbeat
  monitor -> api: GET /health
end
```

### Parallel

Run commands concurrently. Example: [Parallel](/?example=fractalform_parallel).

```
parallel
  api -> db: write record
  api -> cache: invalidate
  api -> logger: audit entry
end
```

### Blocks

Reusable named command groups. Invoked with `@name`. Example: [Blocks](/?example=fractalform_blocks).

| Form | Effect |
|------|--------|
| `block name ... end` | Define a reusable block |
| `@name` | Invoke a block |
| `*block name ... end` | Inline detached block (starts immediately) |

```
block healthcheck
  api -> db: SELECT 1
  db -> api: OK
end

@healthcheck

*block poll
  monitor -> api: GET /health
end
```

## Variables

Hold structured state that can be updated and rendered on components. Example: [References](/?example=fractalform_references).

| Form | Effect |
|------|--------|
| `$name: value` | Set a variable |
| `$name.field: value` | Set a field |
| `$name.field++` | Increment |
| `$name.field--` | Decrement |
| `component: $name` | Render variable as component state |

```
$state: {
  text: "CLOSED",
  failures: 0
}
breaker: $state
$state.failures++
$state.text: "OPEN"
breaker: $state
```

## Full examples

For larger diagrams, use the built-in examples from the editor dropdown:

- [Basic topology](/?example=basic)
- [Content formats](/?example=content-formats)
- [Circuit breaker](/?example=circuit-breaker)
- [Health check](/?example=health-check)
- [JWT revocation](/?example=jwt-auth)
- [Parallel deployment](/?example=parallel-deploy)
