Scopes and worktree rules
A scope is a named part of your work. Sessions and the Board can show one scope, and a herdr or tmux client can mirror one. There are two kinds:
- Projects you choose. A set of projects (or every project), plus any session you pin. A scope can also hold only what you pin.
- GitHub. The scope has a GitHub source: the issues assigned to you in one owner, or every open issue on a Projects board. Its issues arrive on the Board, get a worktree and a session, and are cleaned up when they merge. The Git provider catalog supplies the active projects; the source selects which repositories’ issues the scope follows.
A scope is not a permission: every signed-in client can open any session, whatever scope it shows.
Sources and clients never talk to each other; both meet at branches and sessions. See model.md for the whole model.
| Concept | What it is | Who owns the truth |
|---|---|---|
| Scope | A name, a mode (matching sessions plus pins, or pins only), projects, pins, and optionally a source | PiFi |
| GitHub source | Open assigned issues for a GitHub connection’s account in one GitHub owner (optionally some repositories), plus repositories of other owners you add, optionally with a Projects board. With --follow board: every open issue on its Projects board, assigned or not |
GitHub owns issues, assignees and board columns |
| Issue (tracked issue) | One open issue a source follows: its title, board priority, parent and sub-issue count, linked branches, pull request and board column, and the branch and worktree PiFi works on | GitHub; PiFi keeps a snapshot |
| Keep a session in every worktree (project setting) | Every non-main worktree gets one session when it first appears | PiFi |
| Remove merged worktrees (project setting) | When a worktree’s pull request has merged, archive its sessions and remove the worktree and its local branch | GitHub (PR state) and host git |
What a scope holds
- A scope of projects you choose holds every session in those projects, plus the sessions you pin. In pinned mode it holds only the pins.
- A GitHub scope holds the sessions on branches linked to its issues, in any state, plus any session in its repositories that is live right now. A stopped session with no issue is not in it; it is under Current.
- A pin is membership only: it does not keep a session from being archived, and archiving removes it.
- A scope does not depend on where a session was started: a Pi you start by hand in any terminal belongs to the scopes that hold its project.
What happens in a GitHub scope
- An issue is assigned to you in the source’s owner: it appears in the Board’s Not started column, under the scope. With
--follow boardan issue appears once it is on the board and outside the backlog columns. Issues in repositories that have no project in PiFi are counted in the scope’s sync error, which names the repositories. - Work starts when the issue has a branch: a linked branch (the issue’s Development sidebar) or the head branch of an open pull request that closes it. Start session on the Board or in New session → From an issue creates the linked branch (
<number>-<title>) directly through the GitHub connection when there is no existing link, fetches it into a worktree on the project’s default host (or any connected host with a checkout), and opens an idle session titled#<number> <title>. A branch that already exists gets its worktree on its own at the next sync, or the worktree you already have is linked. - The pull request opens: the branch moves to In review on the Board. It merges: the branch moves to Merged, and with “Remove merged worktrees” on, about ten minutes later its sessions are archived and the worktree and local branch removed.
- The issue closes, is unassigned, leaves the board or returns to a backlog column with no branch or pull request: it disappears from the scope. The branch, its worktree and its sessions stay.
Browse before starting. On the Board, use Issue list, or choose From an issue in New session. In a scope with a source, both show its tracked issues; picking a repository only narrows that list. Under All work or a scope of projects you choose, selecting one GitHub repository shows its open issues, including unassigned and off-board issues. A single-repository scope skips the redundant selector. Select a title to read it without starting anything. The original GitHub link still works if PiFi cannot load the description. Start session does not send the description to Pi.
Repository browsing loads one repository at a time. Load more retrieves the next page; search is limited to loaded issues until all pages arrive. A failed board sync is shown as stale, not as an empty board or a repository-wide list. A repo issue and the same issue on a board share their branch and session. Starting directly from the repo creates a GitHub-linked branch when there is no existing link and requires write access for that action. It neither assigns the issue nor moves a card.
Link by hand. When you already started work in a worktree, open its session’s menu and choose Link to issue…: it lists the project’s issues that have no branch yet. The branch becomes the issue’s branch, so its sessions stay in the issue’s scope, and with write-back the card moves to the --on-start column at the next sync. A main checkout cannot be linked; pin the session to the scope instead. Unlink from #N undoes a link GitHub does not know about. Once GitHub links a branch to the issue (its Development sidebar, or a pull request that closes it), GitHub’s link is used.
Scopes create no tasks. Tasks are for automations (spec.md).
Setting up
A scope of projects you choose needs only a name:
pifi scopes create scratch --mode pinnedpifi scopes create apps --project web --project apiA GitHub source uses a GitHub connection from Settings › Projects (either a GitHub App or a Personal Access Token), with no gh CLI required on any host. For a Projects board, the connection needs Projects permission (built into PiFi, or the project scope on a Classic PAT). Work runs on each project’s default host (or whichever connected host has a checkout).
-
Connect GitHub in Settings › Projects so the repositories appear as projects, and turn on the two project settings if you want them.
-
Create the scope in Settings › Scopes (New scope, then GitHub issues), or with the CLI:
Terminal window pifi scopes create work --github-connection my-account --owner acmepifi scopes create customers --github-connection my-account --owner acme-customers \--board 3 --on-start "In progress" --on-review "In review" --write-back--github-connection <id|account>selects the GitHub connection.--repo owner/name(repeatable) limits it to some repositories.--status-fieldnames the board’s status field (defaultStatus).--also owner/name(repeatable) adds a repository of another owner, for work that lives outside the organization: its project joins the scope and your assigned issues there are tracked too. An issue belongs to one scope, so do not cover the same repository with two GitHub scopes. -
pifi scopes sync <name>syncs now; otherwise every GitHub scope syncs every two minutes.pifi scopes listshows the last sync and error.
pifi scopes edit <name> changes either part. On a scope of projects you choose, --github-connection with --owner adds a source (in the web app: Edit, then GitHub issues); --no-github removes one: its issues leave the Board and the scope keeps its current projects as your own list.
Following a board
For a personal board where issues are triaged by column and not assigned, follow the board instead of your assignments:
pifi scopes create personal --github-connection my-account --owner your-login \ --board 4 --follow board --backlog Backlog --priority-field Priority \ --on-start "In progress" --on-review "In review" --write-back--follow boardtracks every open issue on the board, whoever is assigned;--follow assigned(the default) tracks issues assigned to you. It needs--board.--backlog <column>(repeatable;--no-backlogon edit) names columns whose cards are not tracked until GitHub shows a branch or closing pull request for them, so a long backlog stays out of Not started. Move an issue to Ready (or any other column) to plan it.--priority-field <name>(--no-priority-fieldon edit) names a single-select field such as Priority. Cards show its value; choose Source priority to sort by it in Issue list and New session. Those lists default to repository and issue number. Link to issue still lists by priority first. A board without the field has no priority.- Sub-issues: a sub-issue’s card says “Part of #N” and a parent shows “N/M sub-issues”; a parent stays an ordinary issue you can start.
- GitHub’s own project workflows (new items to Backlog, merged pull requests to Done, auto-archive) keep working; PiFi moves a card at most once per column.
In the web app
Settings > Scopes shows each scope as a card: what it contains, where it is mirrored, and links that select it on Sessions or the Board.
- A GitHub scope adds its owner and repositories, the GitHub connection, the board and how it moves cards, the last sync with the issue count and any error. Under Projects it lists the projects it covers, each with the two worktree switches. Sync now syncs at once.
- Delete removes the scope; for a GitHub scope, also its issues.
New scope and Edit open one form: a name and what the scope contains (projects you choose, pins only, or GitHub issues). Choosing GitHub issues on an existing scope connects it; choosing another option on a GitHub scope disconnects it, which removes its issues from the Board and keeps the scope. The scope selector on Sessions and the Board marks a GitHub scope, such as work · GitHub; the pencil beside it opens the same form, and the Sessions menu ends with “New scope…”. With a GitHub scope selected, the Board can show the Projects board’s own columns instead of stages. Deleting a scope does not touch its sessions; clients that mirrored it mirror nothing until you bind them again.
Watching only
When something else already starts and finishes your work (for example pi-issues’ issue tool, which links a branch, makes the worktree and sets the board status, and herdr’s worktree-reaper, which removes merged worktrees), let PiFi watch instead of act, so two tools never move the same card or remove the same worktree:
- create the scope without
--write-backand with--no-worktrees(orpifi scopes edit <name> --no-write-back --no-worktrees), so it neither moves cards nor makes a worktree for an issue branch that has none; - leave “Keep a session in every worktree” and “Remove merged worktrees” off for its projects;
- start work your usual way. The Pi you start is adopted (terminal-sessions.md), its worktree is found, and a branch GitHub links to an issue shows that issue, its pull request and its board column.
Start session on the Board still works when you want it.
Board write-back
With --write-back, PiFi moves a card to the --on-start column once its worktree exists, and to the --on-review column once a pull request is open, at most once per column, so a card you move back stays where you put it. On the Board, with the scope’s board columns shown, you can also drag a card to another column. Every move is verified against GitHub first, and skipped when:
- the card is assigned to someone else and not to the source’s user (following a board, a card assigned to nobody is moved);
- someone else is assigned too and
--no-move-sharedis set (shared cards move by default); - the card is no longer in the column PiFi last saw (refresh and try again).
Only the status field is ever written. Draft items (not issues) are ignored.
Limits
- Polling only (every two minutes); no webhooks. github.com only, and GitHub is the only source.
- At most 200 tracked issues per scope; following a board reads its first 500 open issues. Beyond that, nothing is removed until the list fits again.
- Board columns are not stages: stages (Not started, Working, In review, Merged) come from the branch and its pull request.
- Landed means: the pull request is merged, the worktree’s HEAD is the merged head, the tree is clean, and no session is running, for ten minutes. A squash-merged branch with local commits added afterwards is kept.
- If the GitHub connection has expired or lacks access, a scope reports the error and nothing else changes.
From 0.20
Until 0.20 a scope was two things: a view (the filter) and a tracker (the GitHub side), which kept a view of its own name. They are one thing now.
- Every view is a scope. A tracker and its view became one GitHub scope, with the view’s name, mode and pins. It has the tracker’s id, so nothing is re-synced and no card moves twice.
pifi views,pifi trackersand--viewstill work and print a notice; they will be removed.scopes create --github-connectionreplaces the older--github-hostandtrackers create --hostflags (inscopes,--hostlimits a scope to a host, as it did inviews).trackers deleteremoved the tracker and kept its view: that isscopes edit <name> --no-githubnow, andscopes deleteremoves the scope.- Settings > Trackers is Settings > Scopes, and lists every scope.
- A browser that had a tracker’s view selected shows All sessions once; select the scope again.
- The upgrade is one-way: back up the coordinator first (operations.md).