# Install

> Install bay with one command, then check the machine with `bay doctor`.

Source: https://getbay.io/docs/install (HTML).

Install bay with one command on macOS or Linux, on ARM or Intel. The script downloads a signed release, checks it, and puts one program in `~/.local/bin`. Then `bay install` sets up the machine and the repository, and `bay doctor` checks both.

## Install bay

**macOS and Linux**

```sh
curl -fsSL https://getbay.io/install.sh | sh
```

It installs the newest release that has a build for your machine. The script installs one program, then runs `bay install`. Inside a repository it also runs `bay doctor`. It needs no root access. It needs `curl` or `wget`, `sha256sum` or `shasum`, and `ssh-keygen` from OpenSSH 8.2 or newer.

**Windows**

```sh
git clone https://github.com/gudjon/bay.git
cd bay
cargo build --release
```

There is no ready Windows build, so build bay from source with a Rust toolchain. Or run the macOS and Linux command inside WSL, which installs the Linux build. bay's tests run on macOS and Linux, so WSL is the tested path. Windows has no check sandbox, so a check fails unless global Git config sets `bay.runnerSandbox` to `none`. Then a check runs with your account's full access, network included. Git for Windows' `sh.exe` runs a `#!` check script for `sh` or `bash`, and no other `#!` script starts.

**From source**

```sh
git clone https://github.com/gudjon/bay.git
cd bay
cargo build --release
./target/release/bay install
```

You need a Rust toolchain. `cargo build --target <target>` builds bay for other targets too. `bay install` places the program at `~/.local/bin/bay`. A build from source refuses when another bay is installed there, and changes nothing. The source is on GitHub at `github.com/gudjon/bay`.

## Where the program comes from

The script downloads bay from GitHub Releases. Each release holds one archive per target, a `VERSION` file, `SHA256SUMS`, and its SSH signature `SHA256SUMS.sig`. A bay release key signs `SHA256SUMS`, which covers the archives and `VERSION`. The signed `VERSION` file names the release, so an older signed release cannot stand in for it.

```text
https://github.com/gudjon/bay/releases/download/v<version>/bay-<target>.tar.gz

targets: x86_64-apple-darwin, aarch64-apple-darwin,
         x86_64-unknown-linux-musl, aarch64-unknown-linux-musl
```

> The Apple silicon build passes a full merge test on a Mac.
> The Intel macOS build is built but not yet run on an Intel Mac.

## What the script does

1. **Detect the platform** The script reads the operating system and the CPU architecture.

2. **Pick the release** It picks the newest release with a build for your machine. `BAY_VERSION` picks an exact version instead.

3. **Verify the signature** It verifies `SHA256SUMS` against `SHA256SUMS.sig` with `ssh-keygen -Y verify`. It stops when the signature does not verify. It trusts two keys: the release key, held in hardware, and the 0.x build key.

4. **Check the sha256** It checks that the signed `VERSION` file names the version it picked. It compares the sha256 of the archive with the signed `SHA256SUMS`. It stops on a mismatch, and it installs nothing.

5. **Install the program** It writes the program to `~/.local/bin/bay`.

6. **Run install and doctor** It runs `bay install`, then `bay doctor` when you run it inside a repository. When `~/.local/bin` is not on `PATH`, it names the fix and stops before both.

## What `bay install` changes

`bay install` has two scopes: this machine, and the clone it runs in. `bay install --machine` writes only the machine's part, wherever it runs. `bay update` runs it this way. `bay install` inside a clone also writes that clone's part. Outside a clone, it writes the machine's part only.

Hook entries go into the project's settings file, and one merge of that file into main reaches every clone. The table is bay's own list, as `bay help` shows it. Roll bay out to many machines gives the order for a fleet.

|  | `bay install` |
|---|---|
| Writes | the bay program and its skill in each Claude config directory |
| Writes | in a clone, without --machine: bay's hook entries in the project's agent settings file and this clone's bay.* Git config |
| Never | main: you commit and merge the settings file |
| Never | with --machine: hook entries, a project's settings or its Git config |

> Every clone and view gets the hook entries from main, and needs no `bay install` of its own for them.
> While the settings file holds uncommitted edits, the result sets `detail.hooks_to_land`, and `detail.next` says to merge it.
> `bay install` leaves global Git config and user-global Claude settings unchanged.
> It reorders no hook entry, removes none that another tool installed, and leaves an up-to-date file unchanged.
> Plain `bay install` creates no SSH keys, but `bay install --approver <name>` makes a person's missing keys in `~/.ssh`.
> When `~/.local/bin` is not on `PATH`, `bay install` stops and names the fix.

### Where each part goes

The program and the skill are the machine's part. Every other row is the clone's part.

| Part | Where it goes |
|---|---|
| The program | `~/.local/bin/bay`. |
| The skill | `skills/bay/` in every Claude config directory bay finds, as the next section says. |
| bay's hook entries | `.claude/settings.json` or `.codex/hooks.json`, when `[agent] product` on main names that product. A digest of other tools' entries goes in the local Git config. |
| `bay.main` and `bay.remote` | The local Git config: from `--main` and `--remote`, else what they hold, else the remote's default branch and `origin`. |
| `bay.machine` | The local Git config, when it is unset. |
| The commit-graph settings below | The local Git config. |
| SSH signing | The local Git config, with a key registry and a key on this machine. |

### Every Claude config directory

`bay install` and `bay update` write the skill into every Claude config directory they find. Your own comes first: `$CLAUDE_CONFIG_DIR`, else `~/.claude`. Then `~/.claude`, and each `~/.claude-*` folder that holds `settings.json`, `.claude.json`, `projects` or `skills`. On Linux, bay also takes the config directory of each running `claude` session of yours under the same `HOME`. `bay doctor` checks the copy in each one, and its `skill` row lists each directory with its state. Name any other directory in your global Git config, one value for each directory.

```sh
git config --global --add bay.claudeConfigDirs <dir>
```

> Each value is one config directory, absolute or starting with `~/`.
> bay does not look inside a named directory for more config directories.

### The commit-graph

In a clone, `bay install` also sets Git to keep a commit-graph with changed-path Bloom filters. Git reads the graph to walk history faster. Without it, bay gives the same answers, only slower. It sets `fetch.writeCommitGraph` to `true` in the local Git config, so each fetch refreshes the graph. Unless `core.commitGraph` is `false`, it writes the first graph when the clone has none with filters.

> On Git 2.52 or newer, it also sets `commitGraph.changedPaths` to `true`.
> On Git 2.46 or newer, while the clone has no filters yet, it sets `commitGraph.changedPathsVersion` to `2`.
> It leaves any of these keys that your Git config already sets.
> A graph it cannot write appears under `detail.commit_graph.write_failed`, and the install still succeeds.
> `bay install --machine` sets none of this.

## Environment variables

Set these variables for the `sh` that runs the script.

```sh
curl -fsSL https://getbay.io/install.sh | BAY_VERSION=<version> sh
```

| Variable | Effect |
|---|---|
| `BAY_VERSION` | Install this exact version. |
| `BAY_INSTALL_SKIP_SIGNATURE=1` | Check only the sha256, when `ssh-keygen` is missing. Read the warning below first. |

> `BAY_INSTALL_SKIP_SIGNATURE=1` turns off the signature check, and the script checks only the sha256.
> Then nothing shows that the program came from a bay release.
> Use it only for a local test, and never on a machine that runs agents.

## Verify

At a terminal, `bay doctor` prints one status line. A pipe or `--json` gets one JSON result instead. Exit `0` means that every required row is green, and a red row names its floor and the fix. Without an agent hook, the `hooks` row reads `off`, and Security and privacy says what bay then guards. If `bay --version` does not print a bay version, another `bay` comes first on your `PATH`. Put `~/.local/bin` first on your `PATH`, or remove the other `bay`.

```text
$ bay --version
$ bay doctor
bay <version> | git <version> | claude <version> | doctor ready
```

> In a bay repository whose remote answers, doctor pushes its verdict when it changes, or every ten minutes.
> Then `bay status --all` shows it, as the Fleet page explains.
> The `storage` row says where a clone's disk went, and what the next `bay start` would free.
> A start removes a day-old folder in the views directory that no view owns, and `next_start_frees.views` names it.
> It sizes check scratch and bay's own folder first.
> A `null` size means doctor ran out of time, never zero.

## Requirements

`bay doctor` goes red below the Git floor for the role of the machine. With Claude Code's hooks, the machine needs Claude Code 2.1.302 or newer. With Codex, it needs Codex 0.153.2 or newer.

A machine that runs checks needs a sandbox: `bwrap` on Linux. macOS has `sandbox-exec`. On Linux, `bwrap` must be able to cut off the network, because checks run without it. When AppArmor restricts user namespaces, as on Ubuntu 24.04 and later, `bwrap` cannot build the sandbox. Then the red `sandbox` row names an AppArmor profile for `bwrap` that fixes it.

| Where | Git | Why |
|---|---|---|
| An agent view | 2.40 or newer | The floor. `bay doctor` goes red below it. |
| Recommended | 2.50 or newer | Below it, `bay doctor` names the features it degrades. |
| A bay-hosted main branch | 2.54 or newer | The main hook that keeps main append-only. |
| A runner | 2.50 or newer | `bay runner run` refuses below it with `TOOL_BELOW_FLOOR`. |

## Uninstall

First remove bay's hook entries from the project's settings file, and merge that change into main. Then unset bay's local Git config in each clone where you ran `bay install`. Then remove the program, its kept versions, the bay skill and bay's state directory from the machine. Never delete bay refs on a shared remote: other agents still read them.

```sh
# once, on main: remove bay's entries from .claude/settings.json (or .codex/hooks.json), and merge that change
# in each clone where you ran bay install:
git config --local --unset gpg.format
git config --local --unset gpg.ssh.allowedSignersFile
git config --local --unset bay.unrelated-hooks-digest
git config --local --unset bay.machine
git config --local --unset bay.main
git config --local --unset bay.remote
git config --local --unset bay.origin                # only if you set it, on the origin's own machine
git config --local --unset bay.producerName   # set by bay when this clone wrote unsigned evidence
git config --local --unset bay.registryKey    # these three: set by bay install --approver
git config --local --unset bay.approverKey
git config --local --unset bay.approverName
git config --local --unset fetch.writeCommitGraph   # these three: only if bay install set them
git config --local --unset commitGraph.changedPaths
git config --local --unset commitGraph.changedPathsVersion
git for-each-ref refs/bay/          # local bay refs; delete them only in this clone
# bay's views and sessions: remove its worktrees, then "$(git rev-parse --git-common-dir)/bay"

# on the machine
rm ~/.local/bin/bay
rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/bay/versions"
rm -rf "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/skills/bay"   # and skills/bay in each directory doctor's skill row lists
rm -rf "${XDG_STATE_HOME:-$HOME/.local/state}/bay"
git config --global --unset-all bay.claudeConfigDirs
git config --global --unset bay.updateVersion
git config --global --unset bay.updateAuto
git config --global --unset bay.runnerSandbox
git config --global --unset-all bay.checkReadPath
git config --global --unset bay.checkStartLoad1        # these seven: only if you set them for a runner
git config --global --unset bay.checkStartCpuSome
git config --global --unset-all bay.checkStartCpuCgroup
git config --global --unset bay.checkCpus
git config --global --unset-all bay.singleMachineEnvironment
git config --global --unset bay.runnerParallelChecks
git config --global --unset bay.runnerAhead
```
