---
description: "Turn on continuous mode on THIS machine: pick the repos it watches; labelled GitHub issues and assigned+labelled Jira items then run in a worktree and stop at an open PR. Use when the machine should pick work up unattended."
description-tr: "Bu makinede sürekli modu açar: izlenecek repoları seçersin, etiketli GitHub issue'ları ve sana atanmış + etiketli Jira maddeleri worktree'de geliştirilip PR'da durur. Repo listesini değiştirmek için aynı komutu tekrar çalıştır."
argument-hint: "(no arguments  -  opens the repo picker)"
parameters: []
gui: button
destructive: false
confirm: required
---

# multi-agent autopilot-on  -  continuous mode, on this machine

> **Pickers follow** `$HOME/.claude/multi-agent-refs/picker-contract.md`: never a one-option call, and branch on the option selected, not on its text.

Turns on the mode that picks work up without being asked. **No repo is included
by default and none is ever added implicitly** - you choose, here, every time.

The gate is this selection, per machine; a label alone is only a filter.
Reasoning and detail for every step: `$HOME/.claude/multi-agent-refs/autopilot-on/details.md`. Read it
when Jira is a source or a step's reasoning is needed.

## Steps

### 1. Prerequisites, stated before anything is written

```bash
gh auth status >/dev/null 2>&1 || echo "BLOCKED: gh is not authenticated - run 'gh auth login'"
command -v jq >/dev/null 2>&1 || echo "BLOCKED: jq is required"
node "$HOME/.claude/scripts/doctor.mjs" >/dev/null 2>&1; [ "$?" -ge 2 ] && echo "BLOCKED: doctor reports a blocking problem - fix it first"
```

Any BLOCKED line stops here and is reported.

### 2. The repo list, both halves of it

```bash
bash "$HOME/.claude/lib/autopilot-activation.sh" list
```

Two states come back and **both are shown**:

- `eligible` - push rights and a checkout on this machine
- `unavailable` - push rights, no local checkout, listed WITH that reason

Never hide the second list.

### 3. Pick, with the current selection already checked

Read `~/.claude/autopilot/config.json` if it exists, then one `AskUserQuestion`
(`multiSelect: true`) over the **eligible** rows:

- `question` (in `outputLanguage`): which repos this machine should pick work up from
- `header`: "Repos" (English, UI contract)
- `options`: one per eligible repo, currently-selected ones marked "(seçili)" / "(selected)"

**This is how repos are added and removed** (check adds, uncheck removes); there
is no `add-repo` / `remove-repo` command.

Unavailable repos are printed above the question as a plain list with their
reason, not offered as options.

### 4. Sources and labels, per selected repo

One `AskUserQuestion` per newly added repo (never re-ask a configured one):

- Sources: `GitHub issues` / `Jira` / both
- Label: default **`agent-queue`** on both sides, editable

Both sources pick up only items **assigned to you** that carry the label; the
query per source is in `details.md`, "Source queries". When Jira is selected,
state the two Jira caveats from that section (global label namespace, Labels
field on the edit screen).

Then one more question per repo, for the **second queue**:

```
header: "Analysis"
question: <localized: "Should this repo also pick up analysis work? A labelled item then runs the analysis command and stops at a written document instead of a pull request.">
options:
  - label: "Development only"                  # pre-selected
    description: <localized: "The repo stays on one queue. Nothing changes.">
  - label: "Analysis too, agent-analysis"
    description: <localized: "Items carrying agent-analysis are analysed; the label must differ from the development one.">
  - label: "Analysis too, my own label"
    description: <localized: "Same, under a label you name.">
```

Branch on the option selected, never on its text. **Development only** writes
neither `analysisQueue` nor an analysis label, and that is what leaves the repo
out: an analysis label nobody asked for would enrol a repo in a second queue
that spends runs on documents. The other two write `analysisQueue: true` plus
`analysisGithubLabel` / `analysisJiraLabel` for the sources selected above. The
analysis label must differ from the development one on the same tracker - a
config where they are equal is refused when the queue next loads, so refuse it
here, say which two fields collided, and re-ask.

Reasoning and the analysis query: `details.md`, "Source queries".

Run the query before saving it, and show the count:

```bash
bash "$HOME/.claude/scripts/jira-search.sh" --jql "$JQL" --max 5 | jq '.total, [.issues[].key]'
```

Report "0 items, query valid" and "query rejected" differently.

### 5. Keep the Mac awake: display on, or allowed to sleep

While the mode is on, a second launchd agent, `com.multi-agent.autopilot-awake`,
runs `/usr/bin/caffeinate -s -i` so the Mac does not sleep between ticks (why:
`details.md`, "Keeping the Mac awake").

One `AskUserQuestion` decides the display:

- `question` (in `outputLanguage`): while autopilot is on, should the display stay on too, or may it sleep?
- `header`: "Display" (English, UI contract)
- options: `{ label: "Display may sleep", description: "Recommended. The system stays awake; builds, simulator screenshots and headless browsers work with the display off" }` / `{ label: "Keep display on", description: "Adds caffeinate -d. Costs energy and screen wear" }`

Branch on the option selected: **Display may sleep** writes `awake.display:
false`, **Keep display on** writes `awake.display: true`, both with
`awake.enabled: true`. A config that already carries `awake` shows its current
answer as the first option.

### 6. Write the config

Validate against `schemas/autopilot-config.schema.json`, then write
`~/.claude/autopilot/config.json` (0600, in a 0700 directory) via
`ma_ap_write` in `lib/autopilot-state.sh`. Defaults that are not asked:
`slots: 1`, `scanIntervalSeconds: 120`, `maxAttempts: 2`,
`costCeilingUsd: 25`. `awake` carries the answer from the previous step. Never
write `askOnLowMaturity`, `reportStatus`, `sendItemKeys` or `depthRouter`; drop
them when rewriting an older file. `analysisQueue` and the analysis labels are
written only for a repo whose step 4 answer asked for them, and removed from a
repo whose answer no longer does.

### 7. Build the menu bar indicator (best effort)

```bash
SRC="$HOME/.claude/scripts/autopilot-menubar.swift"
OUT="$HOME/.claude/autopilot/bin/menubar"
if command -v swiftc >/dev/null 2>&1; then
  swiftc -O "$SRC" -o "$OUT" 2>/dev/null && chmod 700 "$OUT"
fi
```

Built from source on demand, never shipped as a binary. No `swiftc` means no
indicator and nothing else changes - say so in one line rather than failing.
`autopilot-status` works either way. The runner rebuilds it when the source is
newer.

### 8. Confirm the schedule, naming the file

First, every credential the saved config needs, probed the way a background
tick will read it:

```bash
node "$HOME/.claude/scripts/autopilot-arming.mjs" probe
```

`PROBE_READY=false` removes **Start** from the question below: each
`PROBE_PROBLEM=` line names the logical key (or GitHub) and the fix, and is shown
as it is. "Configure only" stays available. `PROBE_WARNING=` lines are shown and
do not block (why: `details.md`, "Probe warnings").

Render `templates/multi-agent-autopilot.plist.template` by substituting its seven
placeholders with the block in `details.md`, "Rendering the plist" (template via
`ma_ap_asset`, never a literal templates path), then show the resolved **path** and interval and `AskUserQuestion`:

- `question`: install the schedule at `~/Library/LaunchAgents/com.multi-agent.autopilot.plist`, and the awake agent at `~/Library/LaunchAgents/com.multi-agent.autopilot-awake.plist`, and start picking work up?
- options: `{ label: "Start" }` / `{ label: "Configure only", description: "Save the repo selection, do not schedule anything yet" }`

"Configure only" is a real answer and the safe default to offer first.

On **Start**, load the schedule and the awake agent, naming every repo selected
in step 3:

```bash
node "$HOME/.claude/scripts/autopilot-control.mjs" on --repo <owner/name> [--repo <owner/name>...]
```

It re-probes credentials, renders and loads the plist and installs the awake
agent (detail: `details.md`). `scheduled: false` with probe problems means
nothing was loaded; say so with the problems. Exit 1 with `launchd refused`
means launchd refused the job: say so, with its path, and say the Mac may sleep
between ticks until it is fixed. "Configure only" is `--configure-only`, which
saves the selection and installs neither.

### 9. Report what is now true

Say all five: which repos and which labels, naming any repo that is on the
analysis queue as well and what that queue delivers (a document, not a PR); that it survives a restart with no
command to run (launchd loads at **login**, not boot); that the machine is kept awake while the mode is on and whether the display is kept on; the slot count
and the ceiling this machine would allow (`ma_ap_slot_ceiling`); and that
`/multi-agent:autopilot-off` is the only way to stop it.

## What this does not do

- **No cap on PRs.** Every labelled item becomes a PR; the bounds are
  `costCeilingUsd` over a rolling 24 hours and machine capacity, never a daily count.
- **Does not merge.** The runner stops at an open PR; the merge decision stays
  yours.
- **Does not touch an attended run.** Per-repo concurrency is 1: the queue skips
  a repo you are working in.
