> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mutagent.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Linear

> Use a Linear team as your Software Factory board while code and pull requests stay on GitHub.

Use a Linear team as the Factory's board. In the cloud, the Mutagent app for Linear reads the team's
issues and updates their states and comments. Its updates show as the app, not as the person who
installed it. On your machine, Architech works the same board with the community
[`linear` CLI](https://github.com/schpet/linear-cli) and your own Linear login. Code, pull requests,
reviews and merges stay on GitHub.

## Connect the Mutagent app

**1. Start the connection**

In Mutagent, open **Configuration › Integrations** and select **Connect** on the Linear card.
Or sign in as yourself with `architech factory login` and run:

```bash theme={null}
architech factory integrations connect linear --wait
```

A person finishes the connection in a browser, so a workspace API key can't start it.

**2. Approve in Linear**

Open the consent page and choose the Linear workspace that owns your team. Use an account that
can install apps there. The recommended team access is **All public teams**. Whatever you
choose, the team you bind must be visible to the app: binding looks up its key in the connected
Linear workspace and refuses a key it can't find with `BOARD_TEAM_NOT_FOUND`.

The app asks to read and write issues and to be assigned and mentioned. It is installed once
per Linear workspace and shared by your organization's Mutagent workspaces.

**3. Check the connection**

Return to **Configuration › Integrations** and check that Linear shows as connected. Also
[connect the Mutagent GitHub App](https://docs.mutagent.io/factory/cloud.md) and give it access to the code repositories.
Factory runs check out code and open pull requests on GitHub.

### Reconnect

To give the app a fresh consent, for example when its grant expired or was narrowed, run the
reconnect from the CLI. The Linear card in **Configuration › Integrations** has no Reconnect button.

```bash theme={null}
architech factory integrations reconnect linear --wait
```

Open the printed URL and approve again, keeping the team you bind visible to the app (**All public
teams** is the recommended choice). Like connect, it needs you signed in with
`architech factory login`.

### Disconnect

Each Mutagent workspace has its own Linear connection, used by the Factory and by gateway Linear
triggers. The Linear grant behind it is shared: the app is installed once per Linear workspace and
used by every Mutagent workspace in your organization that connects to it.

> [!WARNING]
>
> Any disconnect revokes that shared grant. Every other Mutagent workspace that uses it needs a
> reconnect too: until someone reconnects Linear there, its Factory boards and Linear triggers stop.

Two ways to disconnect differ in what they do to this workspace's boards:

| Do this | What happens |
| - | - |
| Select **Remove** on the Linear card, or run `mutagent gateway disconnect linear --force` | Revokes the shared grant. This workspace's Linear boards stay bound, but the Factory can't read or update the team until you reconnect. |
| Run `architech factory integrations disconnect linear --force` | Revokes the shared grant and also unbinds every Linear board in this workspace. After you connect again, push the factory file again to bind the team. |

If Linear can't confirm the revocation, **Remove** and `mutagent gateway disconnect` still
disconnect in Mutagent and warn you to revoke the Mutagent app in Linear's settings. The
`architech factory integrations disconnect` command gives no such warning; after it, check that the
Mutagent app is gone from Linear's settings.

## Bind a Linear team

From your repository, write a factory file for your team. The team key is the prefix of its issue
identifiers, such as `ENG` in `ENG-42`:

```bash theme={null}
architech factory init .architech/factory/factory.yaml --board linear --team ENG --repo acme/web
```

The board block names the provider and the team. The GitHub repositories for the code stay in
`repos`:

```yaml theme={null}
boards:
  main:
    provider: linear
    ref: { team: ENG }
```

When the `linear` CLI is signed in, `init` reads the team's workflow states and writes a
`statusMap` onto them. Then [push the file and enable the Factory](https://docs.mutagent.io/factory/cloud.md). Push binds the
team. Every issue in the bound team is on the board; there is no separate Project to add it to.

## Map statuses to your workflow states

The Factory moves each issue through your team's own workflow states. `statusMap` maps each
[Factory status](https://docs.mutagent.io/factory/reference/statuses.md) to a state name, matched exactly and then ignoring
case. Map existing states: Architech never creates a workflow state, and binding refuses a map that
names a state the team doesn't have.

```yaml theme={null}
boards:
  main:
    provider: linear
    ref: { team: ENG }
    statusMap:
      triage: Backlog
      planning: In Progress
      approved: In Progress
      in_progress: In Progress
      awaiting_approval: In Review
      in_review: In Review
      awaiting_merge: In Review
      on_hold: On-Hold
      done: Done
      dropped: Canceled
```

* **The names are examples.** In Review and On-Hold are the Factory's default names, not required
  ones. If your team calls them `Reviewing` and `Paused`, map those. Add a state in Linear only if
  you want one, or leave the key out.
* **A status you leave out isn't mirrored.** The Factory doesn't move the issue for that status.
* **Map `done` to a completed state** if you want the Factory to close an open issue when its work
  lands; without it, the Factory can't close a Linear issue. Map `dropped` to a canceled state.
* **With no `statusMap` at all**, the Factory uses the six default names: Triage, In Progress, In
  Review, On-Hold, Done and Dropped. Then each must exist on the team, or binding fails with
  `BOARD_STATUSES_MISSING`.
* The state you map to `triage` parks an issue: an issue in it is never started.

## Start work on an issue

There are two ways to hand an issue to the Factory:

| Do this | What happens |
| - | - |
| Add the pickup label, `factory:pickup` by default | The Factory starts a run at plan. |
| Assign or delegate the issue to **Mutagent** | The Factory starts a run at plan. The assignment takes the place of the pickup label. |

An assignment or delegation starts a run only when:

* an active, non-app member of the bound team makes the change;
* the change reaches the Factory by webhook (see below);
* the issue is still assigned or delegated to the app when the run is admitted;
* a trigger on `assigned` to `factory` matches. The default triggers include one. If your file has
  an explicit `triggers` list, which replaces the defaults, keep an entry like this:

```yaml theme={null}
triggers:
  - name: assigned
    on: { source: board, event: assigned, assignee: factory }
    run: { stage: plan }
```

Either way, the issue must be open, in the bound team and outside the `triage` state, and it must
not carry the hold label (`merge:hold` by default). An issue already in a completed, canceled or
duplicate state can't start a run.

A person can stop an open run from Linear: moving the issue to a completed, canceled or duplicate
state, or to the state you mapped to `dropped`, cancels it. The move must be the issue's newest
status change, and it counts only while the issue is still in that state when the Factory reads it;
a move that was undone, or that a newer move replaced, cancels nothing. The Factory's own moves never cancel a run.

A person can also pause a run from Linear: comment `pause` on the issue, and `resume` to continue.
The comment must be the word alone, in any case. See
[Pause or resume a run by comment](https://docs.mutagent.io/factory/operating.md#pause-or-resume-a-run-by-comment).

### Webhooks and polling

The app receives signed webhooks for issue and comment changes, and the Factory also polls the
bound team. A pickup label is picked up from either one. An assignment starts a run only from its
webhook. If one didn't start a run, remove the assignment and assign the issue again, or add the
pickup label. The Factory ignores its own updates.

## Decide on the plan

The Factory posts its plan as a comment on the Linear issue. Apply labels to answer it, using the
names in your factory file. Use plain team labels, not a label group, so an issue can carry more
than one of them.

| Label | What to do |
| - | - |
| Approve plan: `factory:approved` (`labels.approvePlan`) | Read the plan comment, then apply the label to start building. |
| Revise plan: `factory:changes` (`labels.revisePlan`) | Comment with what needs to change, then apply the label. Read the replacement plan before approving it. |
| Fast lane (`labels.fastLane`, none by default) | If configured, apply it to pre-approve a small change that qualifies for the [fast lane](https://docs.mutagent.io/factory/gates.md#the-fast-lane). |
| Hold: `merge:hold` (`labels.hold`) | On an item already picked up and worked on, with a pull request: it blocks the merge until a person removes it. |

Only an active, non-app member of the bound team counts as a person here, and for the `pause` and
`resume` comments; the app and other automation never do. The Factory removes each plan label as it uses it. Moving an issue to another
state doesn't approve it. Pull request reviews and merge controls stay on GitHub; see
[Approvals and merge controls](https://docs.mutagent.io/factory/gates.md).

## Pull requests and the Final Status

Each pull request the Factory opens names its Linear issue in its description by the issue's own
identifier: your team key and number, such as `ENG-42` (or `MUT-7` on a team whose key is `MUT`).

* A pull request for a task that is a Linear sub-issue says `Fixes ENG-43`, plus `Part of ENG-42`
  for its parent.
* When the plan's parts aren't separate sub-issues, only the sole part of the plan's last wave says
  `Fixes ENG-42`. Earlier parts, and parts that share the last wave with another part, say only
  `Part of ENG-42`: then the Factory closes the issue when its work lands.

For each task, the Factory also keeps one comment on its Linear issue (the sub-issue, or the issue
itself when the task has none) with the pull request's link and a **🏁 Final Status** line. That
line reads "not posted on the pull request yet" until the Final Status audit for the same build
head is on the pull request. The Factory reads it again when the review finishes, and edits the
comment in place.

An ordinary Factory pull request also declares one `Surface:` line, such as
`Surface: none — docs only` for a change to docs, configuration or tests alone. A trunk pull request,
the one pull request of a feature built in waves, declares each child's surface in its Evidence
Ledger instead. Whether a pull request needs UI evidence depends on that declaration, on the files
and on the review; see [The Surface line](https://docs.mutagent.io/factory/gates.md#the-surface-line).

> [!TIP]
>
> Linear's own GitHub integration (**Settings › Integrations › GitHub** in Linear) also reads the
> `Fixes` line and attaches the pull request to the issue. If you install it, turn off its pull
> request status automations or point them at the same states as your `statusMap`, so they don't
> move issues somewhere the Factory doesn't expect.

## Limits

* **The scheduled daily brief doesn't read Linear.** A `/daily-brief` routine runs in a cloud
  sandbox with no Linear access, so its brief covers the Factory's own activity: runs, merged pull
  requests and open questions.
* **`/triage` in the cloud writes nothing to Linear.** On a Linear board, a cloud `/triage` run
  doesn't comment on or file a Linear issue, and it doesn't fall back to filing a GitHub issue
  either: its plan is in the run's summary.

## Work with the board locally

On your machine, Architech uses the `linear` CLI, signed in as you, so its updates are made as you,
not as the app:

* `/publish` creates a Linear Project for a spec, with its parent issue and, by default, one
  sub-issue per task. With `policy.plan.subItems: none`, the tasks are a checklist in the parent issue
  instead.
* `/sync` reads the team's issues and moves them to the states your `statusMap` names.
* `/triage ENG-412` comments its plan on that issue. `/triage "<description>" --issue` files a
  new issue that carries the plan, or comments on an existing issue that already describes the
  problem. With `--local`, it writes nothing to the board.
* `/daily-brief` only reads the team's issue changes into the brief; it writes nothing to Linear.

When you choose a Linear team in [onboarding](https://docs.mutagent.io/architech/onboard.md), Architech offers to install the
CLI and sign you in.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.