# Claude Code in Flow

> How Flow works with Claude Code - the hooks it installs, unread dots and tab overlays, the agent column, the context card, and shell capture.

Flow is built to run coding agents, and Claude Code most of all. Every new session starts `claude` in its main pane by default. Flow installs Claude Code hooks so a tab shows when the agent is done, asking a question or waiting for permission, lists the files the agent read and wrote beside its pane, and can record every shell command it runs. Nothing here needs setting up: it works from the first launch.

## Start Claude Code in every session

`session.primary_command` (Settings › General › Sessions › Primary command) is the command the primary pane runs when a session opens. It defaults to `claude`; set it to another agent's command to start that instead. It can differ per repository: set it in your own `~/.flow/repo_config/REPO/flowspace.json` (a team's checked-in file can never choose it). See [Settings scopes](https://flow.worldbreakstudios.com/docs/configuration/settings-scopes.md).

```sh
flow-cli settings apply session.primary_command codex
flow-cli settings repo-set session.primary_command "claude --model opus" --repo app
```

## The hooks Flow installs

At every launch Flow writes a small script, `~/.flow/claude-hook.sh`, and merges hook entries for it into `~/.claude/settings.json`:

- the events `Notification`, `Stop`, `PermissionRequest`, `Elicitation`, `StopFailure`, `UserPromptSubmit` and `PreCompact`;
- `PreToolUse` for the `AskUserQuestion` and `Bash` tools (with a matcher, so it never runs on other tool calls);
- every event named by an overlay trigger in `~/.flow/icons/icons.json` (below).

The merge is additive: your own hook entries are never removed or reordered, and a `settings.json` that does not parse is left untouched. The script does nothing outside Flow's panes and always exits 0, so it never interferes with Claude Code run elsewhere.

## Unread dots and agent signals

When Claude Code finishes a turn (`Stop`, `StopFailure`), sends a notification, asks for permission or asks for input from an MCP server (`Elicitation`), the pane's tab gets an **unread dot**. Starting a turn, an automatic compaction and an `AskUserQuestion` don't mark anything unread.

The same hooks tell Flow what the agent is doing. Snooze uses these signals to wake a session:

| Signal | From |
|---|---|
| turn end | `Stop` |
| turn start | `UserPromptSubmit` |
| question | `AskUserQuestion` (through `PreToolUse`) and `Elicitation` |
| permission | `PermissionRequest` |
| error | `StopFailure` |
| context nearly full | an automatic `PreCompact` |

So "Snooze until next message" wakes on the agent's next finished turn, and the wake-early options (Claude asks a question, Needs permission, Errors or crashes, Context nearly full) fire on these. See [Notifications and snooze](https://flow.worldbreakstudios.com/docs/workspace/notifications-and-snooze.md).

## Overlays on tab icons

An overlay is a small badge on a tab's icon, with an optional ring, that says why a pane wants you. The built-in one is `question`: an amber `?` while an agent is asking something.

Overlays and the hook events that raise them are data in `~/.flow/icons/icons.json` (Settings › Icons › Open folder). The `triggers` map turns Claude Code hook events into overlays. Keys are `Event` or `Event:Tool`, values are an overlay id or `clear`:

```json
{
  "PreToolUse:AskUserQuestion": "question",
  "PermissionRequest": "question",
  "Elicitation": "question",
  "PostToolUse:AskUserQuestion": "clear",
  "UserPromptSubmit": "clear",
  "Stop": "clear"
}
```

- `PreToolUse` and `PostToolUse` need a tool (`Event:Tool`); a bare one is skipped, because it would run on every tool call.
- Event and tool names may only hold letters, digits, `_` and `-`, and a value must be `clear` or a defined overlay id; anything else is skipped.
- Trigger changes apply at the next launch, when Flow rewrites the hook script. Removing a trigger leaves its entry in `~/.claude/settings.json`, where it does nothing.

Define your own overlay in the `overlays` list:

```json
{ "id": "review", "glyph": "R", "color": "#58a6ff", "border": false, "label": "Review" }
```

| Field | Meaning |
|---|---|
| `id` | `[a-z0-9-]`, up to 32 characters. `clear` is reserved. |
| `glyph` | Up to 3 characters, or an image file in the same folder (`.svg`, `.png`, `.jpg`). |
| `color` | `#rrggbb`, for the badge and the ring. |
| `border` | `true` adds a ring around the card. |
| `label` | The name in Settings and tooltips. |

Any program can raise an overlay on its own pane, over ssh too, with an OSC 9 sequence:

```sh
printf '\033]9;flow:overlay:review\007'    # raise
printf '\033]9;flow:overlay:clear\007'     # clear
```

A pane holds one overlay; the last one set wins. It clears on `flow:overlay:clear`, when you press Enter, Esc, Ctrl-C or a digit in the pane, when the pane's program changes or exits, and when the session closes. Overlays never mark a tab unread and are never saved. They show on session tabs and sidebar rows (any pane's overlay, named in the tooltip) and on each tile tab. With tab icons turned off, the badge still shows. `flow-cli read icons` lists the definitions, the triggers and each pane's overlay. See [Tab icons](https://flow.worldbreakstudios.com/docs/features/tab-icons.md).

## The agent column

While a coding agent runs in a session's main pane, Flow centres its text in a column so long lines stay readable on a wide window:

| Setting | Default | Meaning |
|---|---|---|
| `agents.column` | `true` | Centre agent panes. |
| `agents.max_columns` | `120` | The column's width in terminal columns (60–300). |
| `agents.programs` | `"claude, codex, pi, gemini, opencode, aider, amp, cursor-agent"` | The programs that count as coding agents, comma-separated, matched as tab icons are (through `env`, `npx` and `node`). Empty restores the default list. |

## The context card

At the top right of a Claude Code pane, a card lists what the session has looked at and made, newest first:

- **Sources**: images and files you attached (pasted, dropped or `@`-mentioned), and images and documents Claude read, such as a screenshot it took while checking its work.
- **Outputs**: files Claude wrote.
- **Shells**: the shells the agent is running right now, when there are any.

Files that no longer exist drop off the card. Its `–` button minimizes it to a chip in the pane's header; `⤢` opens the session's **Details** tab with every source and output. Turn the card off with `agents.context_card` (Settings › General › Agents › Context card). The **Toggle context card** and **Open agent details** actions (`keyboard.toggle_context_card`, `keyboard.open_agent_details`, unbound by default) do the same from the keyboard or `flow-cli action`.

Flow reads this from Claude Code's own local session files under `~/.claude` (or `$CLAUDE_CONFIG_DIR` when set). `flow-cli read agent-context` prints the focused session's card as JSON.

### Image previews

With the **Claude image previews** experiment on (`features.claude_images`), the `[Image #N]` placeholders Claude Code prints become links: hover one to preview the pasted image, click it to open it in a Files tab.

## Shell capture

Flow can record every shell command Claude Code runs in a pane and show them in that session's **Shells** tab, with each run's output, state and exit code. Set `shells.capture` (Settings › General › Agents › Shell capture):

| Value | Records |
|---|---|
| `all` (default) | every shell the agent runs |
| `background` | only the shells it starts in the background |
| `off` | nothing |

Turning capture on applies to panes opened afterwards; turning it off, or switching between `all` and `background`, applies from the next shell in panes already open. The Shells tab opens by itself the first time an agent in the session runs a shell. Capture never touches the command's output and never makes a command fail. From a shell: `flow-cli read shells`, `flow-cli shells run`, `flow-cli shells kill`.

## Driving Flow from Claude Code

Every Flow pane has `FLOW_SOCKET` set, so `flow-cli` run by Claude Code inside Flow controls that app: it can open tabs, read other panes, change settings and post notifications with `flow-cli notify`. See [flow-cli](https://flow.worldbreakstudios.com/docs/cli/flow-cli.md) and [Agent skills](https://flow.worldbreakstudios.com/docs/cli/agent-skills.md).

## Limits

- Hooks only take effect in Flow's own panes. Claude Code started elsewhere ignores them.
- Changes to overlay triggers apply at the next launch.
- The context card shows only for a session's main pane on the Sessions page, not on the Dashboard or in a pop-out, and not for sessions on remote hosts.
- Image previews need the Claude image previews experiment.
