# Snippets and clipboard

> Reusable snippets with placeholders and keyword expansion, searchable clipboard history, the clipboard cycle and Pick color.

Flow keeps a library of text **snippets** you paste from the command palette or expand anywhere by typing a keyword, and a searchable **clipboard history** of what you copy. Both work system-wide: their hotkeys summon the palette over whichever app is in front, and ↩ pastes back into that app. Two smaller tools sit beside them: the **clipboard cycle**, which pastes history entries one after another without opening anything, and **Pick color**, which copies a color from anywhere on screen.

## At a glance

These hotkeys work from any app, not only when Flow is in front:

| Hotkey | What it does | Setting key |
|---|---|---|
| `⌥⌘V` | Open the palette at clipboard history | `keyboard.global_clipboard` |
| `⇧⌘,` | Open the palette at snippet search | `keyboard.global_snippets` |
| `⇧⌘1` | Paste the clipboard cycle's next entry | `keyboard.global_clipboard_cycle` |
| `⇧⌘2` | Start the clipboard cycle over | `keyboard.global_clipboard_cycle_reset` |

Rebind them in Settings › Keyboard, in the "Global hotkeys" rows. A stored value is a chord such as `ctrl+meta+Space` or `shift+meta+Comma`, and `none` turns a hotkey off. If macOS refuses a hotkey, or another app already owns it, Flow warns and Settings shows why. The in-app `⇧⌘P` palette keeps working either way.

The matching palette actions are unbound inside Flow. Bind any of them in Settings › Keyboard (see [Keybindings](https://flow.worldbreakstudios.com/docs/configuration/keybindings.md)):

| Palette label | Setting key |
|---|---|
| Clipboard history | `keyboard.clipboard_history` |
| Search snippets | `keyboard.search_snippets` |
| Create snippet | `keyboard.create_snippet` |
| Import snippets | `keyboard.import_snippets` |
| Export snippets | `keyboard.export_snippets` |
| Paste next from clipboard cycle | `keyboard.clipboard_cycle_next` |
| Reset clipboard cycle | `keyboard.clipboard_cycle_reset` |
| Pick color | `keyboard.pick_color` |

## Snippets

### The snippet library

Your snippets live in one file, `~/.flow/snippets.json`, on this Mac only. Each snippet has:

- **Name** (required).
- **Keyword** (optional). Whitespace is stripped; by convention it starts with `;`, as in `;uuid`.
- **Tag** (optional, one per snippet). The tag filter ignores case.
- **Body**: the text, with any [placeholders](#placeholders).
- Whether it is **pinned**, how many times it was used (pastes, copies and expansions) and when it was last used.

The file is a pretty-printed JSON array you can edit by hand; Flow notices outside changes. Only `name` is required:

```json
[
  {
    "id": "6f1c2a8e-3b4d-4f0a-9c1e-2d7b8a9f0e11",
    "name": "New UUID",
    "keyword": ";uuid",
    "tag": "",
    "body": "{uuid}",
    "pinned": false,
    "used": 0,
    "last_used": null
  }
]
```

Flow also reads the array wrapped in an object (`{"snippets": [...]}`). When it reads the file, an entry that doesn't parse or has a blank name is skipped, a missing or repeated `id` is replaced, and a keyword that repeats an earlier snippet's is cleared so keywords stay unique.

Flow writes each change on its own (a create, an edit, a pin, a use count) rather than rewriting the whole library, so the palette, a keyword expansion and a hand edit can't undo each other. A file that isn't a snippet list is never overwritten. If the file didn't read back whole, Flow first copies it to `snippets.json.bak`.

### Search and paste snippets

Press `⇧⌘,` (or run **Search snippets** from the palette). The list shows **Pinned**, then **All snippets**. Type to search by name; a keyword that contains what you typed matches too. The detail pane shows the raw body, a **Pastes as** preview and the snippet's information.

| Key | Action |
|---|---|
| `↑` `↓` (also `⌃P` `⌃N`, `⌃K` `⌃J`) | Move the highlight |
| `↩` | Paste |
| `⌘↩` | Copy to the clipboard |
| `⌘K` | Actions |
| `⌘E` | Edit |
| `⌘N` | New snippet |
| `⌃D` | Pin or unpin |
| `⌃X` | Delete (`⌘Z` undoes while the toast shows) |
| `⇥` / `⇧⇥` | Cycle the tag filter |

A double click pastes too. When you summoned the palette over another app, ↩ pastes there with the caret placed at `{cursor}`. Over Flow, the snippet goes into the focused pane; with no pane, it is copied.

The palette's top-level search also lists the three best-matching snippet names once you have typed two characters; ↩ there pastes as well.

If a snippet has `{argument}` placeholders, ↩ first opens a step with one field per argument (defaults filled in) beside a live **Pastes as** preview. ⎋ goes back.

### Create and edit snippets

Run **Create snippet**, or press `⌘N` in the list (`⌘E` edits the highlighted one). The form has:

- **Name**: a blank name refuses the save.
- **Snippet**: the body. Typing `{`, or the **{ } Placeholder** button, opens a picker of placeholders with live previews; its **Snippet…** row lists your snippets, to inline one.
- **Keyword**: a keyword another snippet already has refuses the save. Two cases only warn: a keyword that sits inside another snippet's keyword (such as `;u` and `;uuid`), and a keyword with no symbol in it.
- **Tag**: None, one of the tags in use, or a new one.

A preview beside the form shows what the snippet pastes and which arguments it asks for. In clipboard history, `⌘S` on a text entry opens this form with that text as the body.

### Import and export

- **Export snippets** writes your library to `~/Downloads/flow-snippets.json`, in the same format as `~/.flow/snippets.json`.
- **Import snippets** opens a file picker. It reads Flow's own format or a Raycast snippet export (an array of objects with `name`, `text` and `keyword`):

```json
[
  { "name": "Email sign-off", "text": "Thanks,\n{cursor}", "keyword": ";thx" }
]
```

Imported snippets are added to the end of your library. One with the same name and body as a snippet you already have is skipped, and an imported keyword that another snippet already uses is dropped. The footer reports how many were added and skipped.

### Keyword expansion

Typing a snippet's keyword in any app, Flow's own panes included, replaces it with the snippet.

1. Give a snippet a keyword, such as `;sig`.
2. Open Settings › Clipboard and, under **Snippets**, click **Grant Accessibility…**. Keyword expansion needs the macOS Accessibility permission to see what you type in other apps.
3. Type the keyword anywhere. It expands as soon as you type its last character; no space or other delimiter is needed.

How matching works:

- Flow watches only for keywords: it keeps the last few characters you typed (as many as your longest keyword) in memory, never on disk and never in a log. It only listens; it never blocks or changes a keystroke.
- When several keywords match, the longest one that the typed text ends with wins. If one keyword sits inside another (`;u` and `;uuid`), the shorter one fires first and the longer one can't be typed. The form warns about this.
- A click, an arrow or navigation key, Return, Tab, Escape, any `⌘` or `⌃` chord, or switching apps starts the typed text over. `⌫` removes the last character.
- A snippet with `{argument}` placeholders opens the palette's argument step over the app you were typing in (the keyword is already erased), and pastes on ↩.
- To insert the text, Flow briefly puts it on the clipboard, pastes it, and then restores what was there, unless you copied something new in the meantime. When the clipboard can't be borrowed safely (for example it holds a password manager's copy, or Flow isn't allowed to read it without asking), Flow leaves the clipboard alone and types the text instead. Expanded text never lands in clipboard history.

Keywords don't expand:

- in password fields (macOS keeps secure input from every app);
- while Flow's palette is open, or while a Settings row is recording a shortcut;
- while Flow is locked behind the paywall;
- when an argument snippet's keyword is typed into a Flow field that isn't a terminal (the keyword is typed back so nothing is lost).

Only one running copy of Flow expands keywords at a time. Settings › Clipboard › **Keyword expansion** shows the expander's state:

| Status | Meaning |
|---|---|
| Running — listening for keywords in every app. | Working |
| Idle — no snippet has a keyword yet. | Add a keyword to a snippet |
| Waiting for Accessibility — grant it to expand keywords in every app. | Click **Grant Accessibility…** |
| Another Flow is expanding snippets. | Another copy of Flow holds the expander; this one takes over when it quits |
| Paused while flow is locked. | The paywall is up |
| Off. | `snippets.expand` is off |
| Couldn't start: … | macOS refused; Flow retries |

### Placeholders

Placeholders are words in braces inside a snippet's body. Attribute values may be quoted or bare (`key=value` runs to the next space).

| Placeholder | Pastes |
|---|---|
| `{cursor}` | Nothing; the caret ends up here |
| `{clipboard}` | The clipboard's text now |
| `{clipboard offset=N}` | The Nth earlier text in clipboard history (`offset=1` is the one before the latest) |
| `{uuid}` | A new random UUID (v4, lowercase) |
| `{date}` | Today's date, `MMM d, yyyy` by default |
| `{time}` | The time, `h:mm a` by default |
| `{datetime}` | `MMM d, yyyy 'at' h:mm a` by default |
| `{day}` | The weekday name (`EEEE`) |
| `{branch}` `{repo}` `{cwd}` `{pr}` | The focused session's branch, repository, directory (home shortened to `~`) and pull request number (no `#`) |
| `{selection}` | The text selected in the app you summoned the palette over |
| `{argument name="X" default="Y" options="a,b"}` | A value you're asked for before pasting |
| `{snippet name="X"}` | Snippet X's body, inlined |

Details:

- **Dates and times** take `format="…"`, built from `yyyy yy MMMM MMM MM M dd d EEEE EEE HH H hh h mm m ss s a`, with literal text in single quotes. They also take `offset="+1d"`: signed counts of `m` (minutes), `h`, `d`, `w`, `M` (months) and `y`, several separated by spaces. Example: `{date format="yyyy-MM-dd" offset="+1w"}`.
- **Arguments**: a missing name is called `argument`. With no `default`, the first of `options` is the default. Arguments of inlined snippets are asked for too, once each.
- **Inlined snippets** are guarded against loops and nest at most 8 deep. An unknown name previews as `‹X›`.
- **Modifiers**: any placeholder except `{cursor}` takes `| modifier` pipes, applied in order: `uppercase`, `lowercase`, `trim`, `percent-encode`, `json-stringify`, `raw`. Example: `{clipboard | trim | uppercase}`.
- Anything else in braces, an unknown modifier included, stays as literal text.

## Clipboard history

### What gets recorded

Recording is on by default (`clipboard.enabled`). Flow keeps:

- plain text, up to 2 MB per copy;
- images (PNG, and TIFF converted to PNG);
- a copied file, as its path.

Each entry is classified as **Text**, **Link** (a single `http`, `https`, `ftp`, `mailto` or `file` URL), **Code** (shell commands and code-shaped text), **Image** or **Color** (`#rgb`, `#rrggbb` and their alpha forms, `rgb()`, `rgba()`, `hsl()`, `hsla()`). Copying the same thing again moves it back to the top instead of adding a duplicate.

Flow never records:

- whatever was on the clipboard when it started, or anything copied while recording is off or Flow is locked;
- copies an app marks as concealed, transient or auto-generated (password managers mark theirs this way). Flow checks the marks before reading any content;
- copies from known password managers, including 1Password, Bitwarden, Dashlane, KeePassXC, KeeWeb, Keychain Access, Apple Passwords, LastPass, Enpass, Strongbox, MacPass, Proton Pass and NordPass;
- copies from apps you list under **Ignored apps**;
- text over 2 MB;
- text Flow put on the clipboard itself while expanding a snippet.

**Secrets are masked.** Text that looks like a secret (API tokens, private keys, credentials in a URL, JWTs, high-entropy strings that aren't paths or identifiers, a Puddle join link or pairing token) is kept, but its preview shows only a known token prefix and a row of dots until you choose **Reveal**. A masked entry is never used for search by meaning and can't be saved as a snippet.

### Permissions

Settings › Clipboard › **Permissions** shows two macOS permissions:

- **Paste access.** On macOS 15.4 and later, reading what other apps copy is gated by System Settings › Privacy & Security › Paste from Other Apps. The row reads **Allowed**, **Will ask on first copy** (Flow's first read raises the system prompt), **Asks each time flow reads a copy** or **Denied — flow can't read copies**. While it is set to ask or deny, Flow reads nothing. **Open System Settings** goes to the pane.
- **Accessibility (paste into other apps).** Granted, ↩ in the palette pastes straight into the app you summoned it over. Not granted, ↩ copies and you paste with `⌘V` yourself.

### Browse and search history

Press `⌥⌘V` from any app, or choose **Clipboard history** in the palette (it sits in the "Clipboard & links" group, beside go links). Entries are grouped under **Pinned**, **Today**, **Yesterday**, **This week**, **Last week**, **This month**, **Last month**, then month names and years. Results are always pinned first, then newest first.

An entry matches your query when:

- the query appears anywhere in its text (case-insensitive), or every word of the query does;
- the query is a tight abbreviation of the start of its first line (`gst` finds `git status`);
- its meaning is close to the query (see [Search by meaning](#search-by-meaning)).

`⇥` / `⇧⇥`, or the filter pill, cycles the type filter: **All types**, **Text**, **Links**, **Code**, **Images**, **Colors**.

| Key | Action |
|---|---|
| `↑` `↓` (also `⌃P` `⌃N`) | Move the highlight |
| `↩` | Paste into the app or pane the palette was opened over (copy only when there is none) |
| `⌥↩` | Paste as plain text (not for images) |
| `⌘↩` | Copy to the clipboard and close |
| `⌃D` | Pin or unpin |
| `⌃X` | Delete the entry (asks first) |
| `⌘O` | Open a link in a webview tab |
| `⌘S` | Save a text entry as a snippet |
| `⌘K` | Actions |
| `⇥` / `⇧⇥` | Cycle the type filter |
| `⎋` | Clear the query, then go back |

The `⌘K` menu lists the actions that apply to the highlighted entry: **Paste**, **Paste as plain text**, **Copy to clipboard**, **Set clipboard head** (see [The clipboard cycle](#the-clipboard-cycle)), **Open in webview**, **Pin** / **Unpin**, **Reveal** / **Hide** for a masked entry, **Delete entry**, **Clear history…** and **Save as snippet**. **Open in webview** works only for links and only while [webview tabs](https://flow.worldbreakstudios.com/docs/workspace/webview-tabs.md) are on. **Save as snippet** works for text, code and links, never for images, colors or masked entries.

**As a side column.** With the palette already open on another step, pressing the clipboard hotkey opens history as a column beside it instead of replacing the step. There, ↩ and ⌥↩ insert the entry's text into the palette's current field (on one line for a single-line field); images and masked entries can't be inserted. ⎋ clears the column's query, then closes the column. Pressing the hotkey again closes it too.

### Search by meaning

Besides matching text, clipboard search can find entries by meaning, using Apple's built-in English sentence embeddings. It runs entirely on your Mac, with no model download. Only non-sensitive text is indexed (the first 2,000 characters of each entry), and search by meaning starts once at least 50 entries are indexed. If your Mac doesn't have the English sentence model, search stays text-only.

### Retention and clearing

History has no size limit. **Keep history** (`clipboard.ttl_days`) removes unpinned entries whose last copy is older than the chosen age; Flow prunes at launch and hourly. Pinned entries never expire.

| Keep history | Stored value |
|---|---|
| Forever (default) | `0` |
| 1 day | `1` |
| 7 days | `7` |
| 30 days | `30` |
| 90 days | `90` |
| 1 year | `365` |

**Clear history…**, in Settings › Clipboard › Storage or the `⌘K` menu, removes every unpinned entry after a confirmation. Pinned entries are kept.

### Read history from the command line

`flow-cli read clipboard` lists entries, pinned first, then newest first (50 unless you pass `--limit`):

```sh
flow-cli read clipboard --query "git status" --limit 5
```

Each entry has `id`, `kind`, the preview text (masked when sensitive), `pinned`, `times_copied`, `last_copied` and `source`; the reply also has `more` and `total`. A query never matches a sensitive entry. The command is read-only.

## The clipboard cycle

The clipboard cycle pastes history entries one after another from any app, without opening the palette.

1. Optionally open clipboard history and type a query or pick a type filter. The cycle walks the last query and filter you used there.
2. Press `⇧⌘1`. Flow pastes the newest matching entry, pinned entries first.
3. Press `⇧⌘1` again for the next older entry, and so on. After the last one, a toast says "End of clipboard cycle"; it doesn't wrap around.
4. Press `⇧⌘2` to start over from the top. The query and filter stay.

Where each press pastes is decided at the press: the app in front, or the app the palette was summoned over if the palette is showing; with Flow in front, the focused pane; otherwise the entry is only copied.

- In clipboard history, `⌘K` › **Set clipboard head** makes the next `⇧⌘1` start at that entry. While a cycle is active, the card marks the entry that pastes next.
- The cycle walks a snapshot of up to 5,000 entries taken at the first press, so an entry moving to the top as it's pasted doesn't change the order.
- Changing the query or filter in the card starts the cycle over from the top. After more than 5 minutes without a press, the next press forgets the query and filter as well.
- A press while a paste is still in progress does nothing.

## Pick color

**Pick color** (in the palette's "Clipboard & links" group) closes the palette and opens the system color sampler. Click anywhere on screen and Flow copies the color as uppercase hex, `#RRGGBB`. While history is recording, the copy lands there too, and the toast says so. On a macOS with no color sampler, Flow shows "This macOS has no color sampler".

## Settings

Settings › Clipboard. These are app-wide settings; they can't be set per repository.

| Key | Type | Default | Effect |
|---|---|---|---|
| `clipboard.enabled` | boolean | `true` | **Record clipboard history.** Off, nothing new is recorded |
| `clipboard.ttl_days` | number (days) | `0` (forever) | **Keep history.** Unpinned entries older than this are removed. A hand-edited number not in the list is kept as stored |
| `clipboard.ignore_apps` | array of bundle ids | none | **Ignored apps.** Copies from these apps are never recorded. The field takes comma-separated ids and saves on ↩ or when you leave it |
| `snippets.expand` | boolean | `true` | **Expand snippet keywords.** Needs Accessibility |

The page also has rows without a key: **Keyword expansion** (the expander's status and **Grant Accessibility…**), **Paste access** (**Open System Settings**), **Accessibility (paste into other apps)** (**Grant…**) and **Clear history…**.

Example `~/.flow/settings.json` entries:

```json
{
  "clipboard.ttl_days": 30,
  "clipboard.ignore_apps": ["com.example.app", "com.example.other"],
  "snippets.expand": true
}
```

## Limits

- Snippets and clipboard history are stored only on this Mac.
- Keyword expansion never works in password fields.
- Pasted from the palette into a Flow pane, `{clipboard offset=N}` uses the current clipboard, not an earlier history entry.
- Search by meaning is English only.
