# Settings scopes

> How Flow picks a setting's value per repository, from a subdirectory, your own per-repo file, the team's checked-in file and your global settings.

Most settings have one value for the whole app. A few mean something different per repository: the team may want a say, you may want your own value, or both. Settings scopes are how Flow decides which value wins in a given directory. Overrides are sparse: no file is created until you set a value, and a repository with no overrides behaves exactly like your global settings.

## The scopes

From highest to lowest, by default:

| Scope | Where | Who owns it |
|---|---|---|
| Directory | `SUBDIR/.flowspace.json` (a real subdirectory of a checkout) | the team, or you, for one part of a repository |
| User repo | `~/.flow/repo_config/REPO/flowspace.json` and `…/drop.json` | you, for one repository, in every worktree |
| Repo | `.flowspace.json` and `.drop.json` at the checkout top | the team, checked in |
| User | `~/.flow/flowspace.json`, `~/.flow/settings.json`, `~/.config/drop/config.json` | you, everywhere |
| Built-in default | Flow itself | Flow |

The top of a checkout, whether the primary checkout or a linked worktree, always counts as **Repo**, never Directory: that file is the team's, and it must not beat your own per-repo file.

Each setting honours only some of these scopes, listed in its **Order** below. A scope missing from a setting's order is ignored for that setting. For example, a team file can never choose your `session.primary_command`, and no `snooze.*` setting reads the team's file.

## Which files Flow reads

For a session in a directory, Flow reads these files in order:

1. `DIR/.flowspace.json`, when the session is in a subdirectory of its checkout (or outside any repository)
2. `~/.flow/repo_config/REPO/flowspace.json`
3. `WORKTREE_TOP/.flowspace.json`
4. `PRIMARY_CHECKOUT/.flowspace.json`, when that is a different directory
5. `~/.flow/flowspace.json`

Outside a git repository, only the directory's file and the user file are read. A session on a remote host reads only your User value and `~/.flow/flowspace.json`: its paths never reach your local disk.

## Your per-repository files

`~/.flow/repo_config/REPO/` is keyed by the folder name of the repository's **primary** checkout, so every worktree of a repository shares it. Two different checkouts with the same folder name share one config; Settings › Repos says so when it happens. For a bare repository, `REPO` is the bare directory's name without `.git`.

The directory holds two files, named after their checked-in counterparts so you can move one across:

- `flowspace.json` has the same shape as `.flowspace.json`, plus an optional top-level `settings` object for setting values.
- `drop.json` has the same shape as `.drop.json`.

```json
{
  "run": [{ "label": "Dev", "command": "make dev", "cwd": "web" }],
  "settings": {
    "session.primary_command": "zellij",
    "git.merge_method": "rebase"
  }
}
```

A relative `cwd` in this file is relative to the worktree top, as if the file were checked in there. A checked-in `.flowspace.json` may carry a `settings` object too; a key whose order has no Repo scope is ignored there.

A corrupt file is skipped and never stops a launch or a `drop` command (a corrupt checked-in `.drop.json` is still an error for `drop`). Flow refuses to write over a corrupt file. When an override is removed and its file is left empty, Flow deletes the file and its directory.

## Merge and single settings

Each scoped setting is one of two kinds:

- **Merge**: every scope contributes entries and they combine. Your run commands sit beside the team's; when two files use the same label (or name), the nearest file wins.
- **Single**: one scope wins, the highest one in the setting's order that holds a usable value.

A value of the wrong shape counts as unset, whichever scope holds it. `git.merge_method` and `tabs.new_tab` only take their listed choices, so a typo in a team file falls through to the next valid value instead of winning.

## The scoped settings

Every setting that can vary per repository. **Order** lists the scopes it honours, highest first. Every other setting is app-wide.

| Setting | Label | Kind | Home | Value | Order |
|---|---|---|---|---|---|
| `profiles` | Workspace profiles | merge | flowspace (top-level key) | array | Directory › User repo › Repo › User |
| `run` | Run commands | merge | flowspace (top-level key) | array | Directory › User repo › Repo › User |
| `docs` | Web docs | merge | flowspace (top-level key) | array | Directory › User repo › Repo › User |
| `run_providers` | Run providers | merge | flowspace (top-level key) | array | Directory › User repo › Repo › User |
| `reviewers` | Reviewers | merge | flowspace (top-level key) | object | Directory › User repo › Repo › User |
| `quick_links` | Quick links | merge | flowspace (top-level key) | object | Directory › User repo › Repo › User |
| `code_search` | External code search | merge | flowspace (top-level key) | object | Directory › User repo › Repo › User |
| `worktreeDir` | Worktree directory | single | drop config | string | User repo › Repo › User |
| `branchPrefix` | Branch prefix | single | drop config | string | User repo › Repo › User |
| `isolationBase` | Fork base | single | drop config | string | User repo › Repo › User |
| `session.primary_command` | Primary command | single | settings (`settings` object; User: settings.json) | string | User repo › User |
| `git.merge_method` | Merge method | single | settings (`settings` object; User: settings.json) | `squash` / `merge` / `rebase` | User repo › Repo › User |
| `git.open_pr_in_review` | Open pull requests in a review tab | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `git.pin_pr_review_tab` | Pin pull request review tabs | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `pr.diff_groups` | Diff groups | single | settings (`settings` object; User: settings.json) | object | User repo › Repo › User |
| `tabs.new_tab` | New tab type | single | settings (`settings` object; User: settings.json) | `ask` / `terminal` | User repo › User |
| `snooze.default` | Snooze default | single | settings (`settings` object; User: settings.json) | `ask` / `30m` / `unread` / `pr` / `ci` | User repo › User |
| `snooze.durations` | Snooze quick durations | single | settings (`settings` object; User: settings.json) | array | User repo › User |
| `snooze.favs` | Snooze favorites | single | settings (`settings` object; User: settings.json) | array | User repo › User |
| `snooze.recents_n` | Snooze recent conditions | single | settings (`settings` object; User: settings.json) | `0` / `3` / `5` | User repo › User |
| `snooze.trig.unread` | Snooze until next message | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.unread_min` | Snooze ignores turns shorter than | single | settings (`settings` object; User: settings.json) | `off` / `30s` / `2m` / `5m` | User repo › User |
| `snooze.trig.pr` | Snooze until PR approved | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.pr_changes` | Snooze wakes on changes requested | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.trig.ci` | Snooze until CI finishes | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ci_mode` | Snooze wakes when checks | single | settings (`settings` object; User: settings.json) | `pass` / `any` | User repo › User |
| `snooze.ask_wake` | Ask what wakes a snooze early | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.question` | Wake early on a question | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.perm` | Wake early on a permission prompt | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.error` | Wake early on an error | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.context` | Wake early when context is nearly full | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.comment` | Wake early on a PR comment | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.approved` | Wake early when the PR is approved | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.changes` | Wake early when changes are requested | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.reviewed` | Wake early on a comment-only review | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.mention` | Wake early on a PR mention | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.closed` | Wake early when the PR merges or closes | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.ci_fail` | Wake early when a CI check fails | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.ci_done` | Wake early when CI finishes | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.ov.watches` | Wake early on named watches | single | settings (`settings` object; User: settings.json) | array | User repo › User |
| `snooze.ignore_authors` | Snooze ignored people and bots | single | settings (`settings` object; User: settings.json) | array | User repo › User |
| `snooze.ignore_checks` | Snooze ignored checks | single | settings (`settings` object; User: settings.json) | array | User repo › User |
| `snooze.check_picks` | Snooze chosen checks | single | settings (`settings` object; User: settings.json) | object | User repo › User |
| `snooze.wake.top` | Move a woken session to the top | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.wake.unread` | Mark a woken session unread | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.wake.notify` | Notify when a session wakes | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.wake.sound` | Play a sound when a session wakes | single | settings (`settings` object; User: settings.json) | bool | User repo › User |
| `snooze.watches` | Snooze watches | merge | settings (`settings` object; User: settings.json) | array | User repo › User |

**Home** means: a top-level key of a flowspace file (**flowspace**); a top-level key of a drop config file (**drop config**); or the settings store for User and a flowspace file's `settings` object above it (**settings**).

`code_search` also keeps part of its User value in Settings › Code (`code_search.engine`, `code_search.sourcegraph_url`, `code_search.url`, `code_search.by_lang.LANG`, `code_search.docs.LANG`). That part sits right after `~/.flow/flowspace.json`.

## Mark a value important

Any of these files may carry a top-level `"!important"` list of keys:

```json
{ "!important": ["worktreeDir", "run"], "worktreeDir": ".wt" }
```

- An important value beats every value that isn't, whatever the order.
- Among several important values, the setting's own order decides.
- A mark in a scope the setting does not honour is ignored, so a team file can't force `session.primary_command`.
- Spell the key exactly as it appears in the file. A mark on a key with no value in that file does nothing.
- For a Merge setting, the marked file moves to the front for that key only, so it wins duplicate entries; the other files still contribute.

At the User scope the list is an `"!important"` key in `~/.flow/settings.json`, `~/.flow/flowspace.json` or `~/.config/drop/config.json`, depending on the setting's home.

## See and edit scopes in Settings › Repos

Settings › Repos lists the repositories under your source folder (drop's `reposDir`), those of your open sessions, and any directory already under `~/.flow/repo_config/`, one row per primary checkout. A config whose checkout is gone stays listed as "no checkout found". Remote hosts are not listed.

A repository's page shows every scoped setting with the value in force and a chip for where it comes from (Default, User, Repo, User repo):

1. Click **Override** to open an editor seeded with the value in force. A text field saves on Enter or when you leave it.
2. Expand a row to see each scope in order, with its file, value and state (Applied, Overridden, Not honoured, Unset).
3. Use the `!important` toggle on the User line (it appears once the User scope has a value). The Repo line, the team's file, is read-only.
4. Click **Reset** to remove the override and its mark.

List settings are read-only on this page: it shows their merged items with their sources, and **Edit in flowspace.json** opens the file for editing, creating it if needed. It is the only action on the page that creates a file. Rows in Settings › General that have a scope rule, and Code's search engine row, carry a small "Per repo" chip that opens this page.

## Scopes from a shell

```sh
flow-cli read config-trace --key git.merge_method          # how a key resolves in the current directory
flow-cli read config-trace --dir ~/src/app                 # every scoped key, for another directory
flow-cli read repos                                        # the repositories Settings › Repos lists
flow-cli settings repo-set git.merge_method rebase         # your User repo value, for the focused session's repo
flow-cli settings repo-set worktreeDir .wt --repo app --important
flow-cli settings repo-unset git.merge_method --dir ~/src/app
```

`repo-set` and `repo-unset` write `~/.flow/repo_config/REPO/` for the repository you name with `--repo` (its key) or `--dir`, else the focused local session's. They refuse a key that has no scope rule, a key whose order has no User repo scope, a value of the wrong shape, and a corrupt file. A list or object value replaces your whole User repo value, so read the trace first and write the full new value. The reply is the key's trace: the winner, its value, the reason and every layer.

## Limits

- Only the settings in the table above vary per repository.
- Two checkouts with the same folder name share one `repo_config` directory.
- Sessions on remote hosts read only your User values.
- Changing a team's `.flowspace.json` or `.drop.json` is a change to their repository: commit it like any other file.
