greenbelay 6.4.0

A guard for Claude Code's tool calls: it reads each one before it runs, the work-process verdicts (plan review, implementation review, preview) included
# Installing

The binary first, then the wiring. They are separate acts on purpose: a
program that can refuse the commands your agent runs should not install itself
into your `settings.json` as a side effect of you fetching it.

## The binary

```sh
curl -fsSL https://raw.githubusercontent.com/greenharness/greenbelay/main/install/install.sh | sh
```

```powershell
irm https://raw.githubusercontent.com/greenharness/greenbelay/main/install/install.ps1 | iex
```

Either one downloads a release binary, verifies it against the published
`SHA256SUMS`, and puts it in `~/.local/bin`. Neither wires anything in.

Or: `brew install fredericrous/tap/greenbelay`, `cargo install greenbelay`,
or a binary straight from
[Releases](https://github.com/greenharness/greenbelay/releases/latest) — Linux
x86_64 (gnu and static musl) and aarch64 (gnu), macOS (Intel and Apple
silicon), and Windows x86_64.

## Upgrading from amont-agent

greenbelay was called `amont-agent` until 4.0.0. The installers and the
formula also place `amont-agent` beside `greenbelay`, as a copy of the same
binary, so hook entries written for the old name keep firing after the
upgrade. With Homebrew, the upgrade goes through the tap's rename, and
Homebrew trusts only the formula you named, so trust greenbelay first:

```sh
brew trust --formula fredericrous/tap/greenbelay
brew upgrade fredericrous/tap/amont-agent
```

Without the `brew trust`, Homebrew stops with "Refusing to load formula
fredericrous/tap/greenbelay from untrusted tap". Then move the hook entries
to the new name once:

```sh
greenbelay install --write   # replaces the amont-agent entries, adds no second set
greenbelay doctor
```

`cargo install greenbelay` places no `amont-agent` copy. The `amont-agent`
crates stay at 3.35.0. Release 5.0.0 also renames the names the tool reads
and writes (the `~/.claude/greenbelay/` directory, `greenbelay.*` git config
keys, `GREENBELAY_*` variables) and moves this machine's data once; see
[migrating to the new data names](migrate.md).

The installers read `GREENBELAY_BIN_DIR` and `GREENBELAY_VERSION`; the old
`AMONT_AGENT_BIN_DIR` and `AMONT_AGENT_VERSION` still work, with a warning.

## Why there is no npm package

There was one, briefly, and removing it is the more useful answer than
listing install methods.

`install` bakes the ABSOLUTE path of the running binary into
`settings.json`, deliberately: a `PATH`-resolved command exits 127 into
Claude Code's non-blocking bucket the moment `PATH` differs, which disables
the guard with nothing to notice it. npm cannot supply a stable absolute
path. Under `npx` the binary lives in npm's `_npx` cache, which npm garbage-
collects; under a project-local `npm i -D` it lives in one project's
`node_modules`, while the guard it configures is machine-global — so
`rm -rf node_modules` in one repository would silently disable the guard for
every session on the machine.

amont has an npm package for a reason that does not transfer: it is a
per-repository tool, and `npm i -D amont` plus a `prepare` script means the
hooks travel with the repository. This is per-developer machine
configuration — `~/.claude/settings.json`, global git config, a journal in
`~/.claude/`. Nothing about it belongs to a project.

Every channel above hands `install` a path that stays put.

## The wiring

```sh
greenbelay install          # prints the settings block, writes nothing
greenbelay install --write  # merges it into ~/.claude/settings.json
```

`install` refuses to guess. It will not patch a `settings.json` it could not
parse, and it will not write one whose formatting it cannot reproduce — a diff
full of reformatting hides the one line it added — so it prints the block and
changes nothing unless `--reformat` says otherwise. `uninstall` removes exactly
what it wrote and leaves everything else byte-identical.

```sh
greenbelay install --write --project   # .claude/settings.json instead
greenbelay install --write --local     # .claude/settings.local.json
```

Four kinds of entry are written: the guard on `PreToolUse`, for Bash and for
the file tools; the assertions on `PostToolUse` for Bash, which check what a
command that reported success actually did; a `PostToolUse` entry for Read,
which remembers a file only once it has actually been read; a
`PostToolUse` entry for the LSP tool, which records the files each agent asked
LSP about (`code-read-not-lsp` stays silent on a later Read of them); and a
`SessionStart` entry that leaves a heartbeat and states where the checkout
stands against the remote. Without the heartbeat, `doctor` cannot tell "nothing
fired this week" from "the guard has been dead since Tuesday".

Your `settings.json` keeps the mode it already had, and a file created here
starts at `0600`: it can hold MCP environment blocks, and those hold
credentials.

## Knowing it is alive

Claude Code hooks fail open quietly: a command that cannot be resolved exits
127, which is a *non-blocking* status, and nothing tells you. `doctor` exits
non-zero when the guard is inert, so it can run from cron:

```
✓ installed in /Users/you/.claude/settings.json
✓ greenbelay 4.0.0 at /Users/you/.local/bin/greenbelay
✓ a refused command produces a valid decision document
✓ last ran 4m ago
✓ acting on pipe-to-tail
```

`greenbelay doctor --json` prints one JSON document on stdout instead:
`healthy` (the same verdict as the exit status), `findings` (a list of `ok`,
`advisory`, `line` and `detail`), and `integration`, which is reported apart
from health: `state` is `present`, `partial`, `absent` or `unknown` (a settings
file exists and could not be read), with `settings_file` and `binary` (null
when no entry was found) and `missing`, the hook entries this version installs
that are not there. `doctor --help` prints its usage and exits 0.

Where no `plan-review-*` or `implementation-review` agent is installed (not in
the Claude config `agents/`, the repository's `.claude/agents/`, or any
installed plugin), the plan-panel and implementation-review rules cannot be
satisfied. They then say so once, with `grh install workflow` as the remedy,
instead of holding the call, and only where they would otherwise have refused:
a review found in the transcript or already remembered is honoured as before.
An agents directory or plugin manifest that cannot be read counts as installed.

## Turning it off

```sh
GREENBELAY_OFF=1                                # this shell only
git config --global greenbelay.enabled false    # everywhere
greenbelay uninstall --write                    # remove the settings entries
```

Demoting one rule is almost always the better move than switching the guard
off — see [stances](stances.md). A guard that is hard to back out of is one
people uninstall instead of demoting, and uninstalling takes every rule with
it.