Start here

Quickstart

Install bay, set your checks, start a runner, then start and merge a first change.

This page takes a repository to its first merge. You install bay, commit a config and a policy to main, and start a runner. Then an agent opens a change with bay start and submits it with bay merge.

  1. 01

    Install bay

    Run the script on each machine that runs agents or a runner.

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

    Check the machine

    Fix each red row before you go on. Each red row names its fix. Until the next step turns on the agent hook, the hooks row reads off. Security and privacy says what bay guards with the hook, and without it.

    sh
    bay doctor
  3. 03

    Configure the repository

    .bay/config.toml names the agent product, and Configuration lists its keys. Each check's command lives in .bay/policy.toml, reads a bay.check.request/1 on stdin, and writes a bay.check.result/1 on stdout. Test one before you commit it: bay plugin test check -- <command> runs bay's contract cases and changes nothing. Commit the config and push it to main, since bay reads it only from main. Then run bay install in this clone to add the hook entries, and other clones need no step of their own. Once the policy below is on main, merge the new .claude/settings.json with bay save "add bay hooks", and every clone then runs bay's hooks.

    toml
    # .bay/config.toml
    [agent]
    product = "claude"
  4. 04

    Set the required checks

    .bay/policy.toml on main lists each required check, with its expected_minimum: the fewest tests it must collect. when_paths names the files a check tests, and a change no check covers merges at once, with no runner. The adapter list names every file that decides a pass, and bay runs those files from the base. A change to the policy or a check's files also runs its own new files, and both must pass. Without .bay/policy.toml on main, the runner blocks every merge with POLICY_MISSING, so push the first policy to main yourself. A repository that wants no checks says so: unchecked = true in its policy.

    toml
    # .bay/policy.toml (on main)
    revision = 5                       # an integer; every policy change raises it
    
    [[check]]
    id = "tests"
    environment = "linux-x86_64"
    command = "scripts/bay-check tests"
    when_paths = ["src/**", "tests/**", "pytest.ini", "scripts/bay-check", "scripts/bay-check.d/**"]   # a change elsewhere skips it
    adapter = ["scripts/bay-check", "scripts/bay-check.d/", "pytest.ini"]
    inputs = []                        # inputs beyond the tree; "commit" or "history" keys evidence by commit
    expected_minimum = 400             # required, no default
    timeout_s = 1800
    path = ["/usr/local/bin", "/usr/bin", "/bin"]   # absolute directories; the check's PATH
    env = ["DATABASE_URL"]             # the only variables passed from the runner
    retry_on_failure = 1               # rerun a failure on the same tree, up to 5 times
    allow_flaky = false                # a failure then a pass is flaky: CHECK_FLAKY
    
    [[check]]
    id = "e2e"
    environment = "linux-x86_64"
    command = "scripts/bay-check e2e"
    when_paths = ["src/**", "e2e/**", "scripts/bay-check", "scripts/bay-check.d/**"]
    adapter = ["scripts/bay-check", "scripts/bay-check.d/"]
    expected_minimum = 20
    
    [[quarantine]]                     # optional: one check set aside for a stated time
    id = "e2e"                         # a required check with expected_minimum above zero must remain
    environment = "linux-x86_64"
    reason = "red on main since change k3m7p2ra; fix in progress"
    end = "2026-10-25"                 # a date or a Change-Id
    owner = "platform-team"            # optional: who answers for it
    since = "2026-10-18"               # optional: when it was set aside; bay status shows its age
    
    [limits]                           # optional; each key a positive integer
    max_file_mib = 10                  # any one file the change adds or changes, in MiB
    max_files = 200                    # the files it touches
    max_added_lines = 5000             # the lines it adds; a binary file adds none
    max_waiting_approvals = 5          # changes that may wait for a yes at once
  5. 05

    Start a runner

    A runner is optional: without one, bay merge --wait and bay save merge right where they run. With one, the runner finishes each merge after its agent leaves. Run it under a supervisor, such as the one bay runner install writes, and run at least two. Each check runs in a sandbox: bwrap on Linux, sandbox-exec on macOS, unless the machine sets bay.runnerSandbox to none. There, a check sees only its candidate, its own files and system files, with no network. Set network = true on a [[check]] that needs the network.

    sh
    bay runner run
  6. 06

    Start a change

    The agent says what the work is, in a few words, and names the paths it needs. bay opens a sparse view of those paths and prints its result. --paths . opens the whole tree. Set BAY_ACTOR to name the agent, or bay uses your user name.

    sh
    bay start "fix the login page" --paths src/api tests/api
  7. 07

    Edit, then merge

    The agent edits files in the view, then commits them with a message that main's commit keeps. bay merge returns at once with an operation id, and a runner checks the candidate and merges it. A change no check covers merges at once. To hear the outcome, run bay merge <change> --wait=3600 as a background task. A person who edits the main checkout directly runs bay save <intent>. Run bay without a runner explains it.

    sh
    bay merge
  8. 08

    Read the state

    bay status describes your own changes, at most 20, with each state and why it waits. It names everyone else's under detail.more_changes. bay status <change> reads one. A refusal names what you can still do and when to retry. For a failed check, the refusal and bay status say why each failed unit failed. Its say counts your open changes by who owes the next step, and names the ones that need someone.

    sh
    bay status