Skip to content

Roll out global ~/.claude/CLAUDE.md safety rules to all machines #365

Description

@ptr727

Summary

Get the agent write-safety kit installed and current on every machine that runs Claude Code with my gh credentials logged in.

One command per machine. It installs, and it prints one line to paste back here.

Do this on each machine

Clone fresh (or git pull an existing clone — the point is that it is current), then run one command.

Linux, macOS, WSL

git clone --depth 1 https://github.com/ptr727/ProjectTemplate.git /tmp/pt && cd /tmp/pt
./host-setup/agent-safety/install.sh

Windows (PowerShell)

git clone --depth 1 https://github.com/ptr727/ProjectTemplate.git $env:TEMP\pt; cd $env:TEMP\pt
.\host-setup\agent-safety\install.ps1

Both need Python 3 and nothing else. Both are idempotent, so re-running is always safe and is the fix for anything reported below.

Restart Claude Code sessions on that machine afterwards, so the hook and CLAUDE.md load.

What to paste back

The installer ends with one line. Paste it into the checklist below:

server-2 | Debian GNU/Linux 13 (trixie) | hub e2a99f1 | payload 2600d29d59ff247a | agent-safety v1, fleet-bootstrap v1 | 2026-08-11T02:12:07Z

Host name, host type, the hub commit it installed from, a digest of the bytes installed, the marker blocks actually found in CLAUDE.md, and when. That is the record — a tick is not.

Re-checking a machine later, without changing it

./host-setup/agent-safety/install.sh --report      # Linux / macOS / WSL
.\host-setup\agent-safety\install.ps1 --report     # Windows

Read-only. Run it from a fresh hub checkout and it compares that machine against that checkout:

Verdict Exit Meaning
CURRENT 0 Machine matches this checkout
STALE 1 Lists each reason; re-run the installer
NOT INSTALLED 2 No stamp on this machine

It creates nothing, so running it on a machine that has never been set up leaves it untouched.

Rollout

Every tick below was reset. They recorded that someone ran something once, the kit has changed several times since, and none of them carries a stamp — so none can be checked. Paste the stamp line as each machine is done.

  • Server-2 Proxmox (this host — the kit is installed but predates the stamp, so re-run it)
  • Windows workstation
  • WSL2 Debian
  • WSL2 Ubuntu
  • Macbook Air
  • Thinkpad Windows
  • Thinkpad Linux
  • Any CI / headless / cron environment that invokes Claude Code with the token

Why the ticks were not enough

The previous body said it outright: "a machine ticked below is not necessarily current." Three things were being conflated, and only the third matters:

  • Ran once — what a tick records.
  • Files present — what a grep for the markers records. A block edited between its own markers passes this.
  • Current and in force — what the stamp records.

--report checks the third. It compares the installed bytes rather than markers, so a hand-edited block is caught; it reads settings.json, so a kit whose hook is no longer registered is reported inactive rather than fine; and it reports a duplicated or half-written block, which a presence check reads as success.

What is checked

  • The deployed hook and both CLAUDE.md blocks, byte for byte against the checkout, line endings normalized so a CRLF machine is not falsely stale
  • The PreToolUse hook is registered in settings.json, exactly once
  • Every managed permission rule is present
  • Markers are neither duplicated nor half-written
  • The install was not made from a dirty checkout, which would mean the recorded commit does not identify the bytes

One thing the installer will not fix

On at least this host, the superseded safety section from #364 still sits above the canonical marker block, so the two overlap. The installer only rewrites what is between its own markers, so that older text survives every re-run and --report will call the machine CURRENT with it still there.

Removing it is a judgment call on a per-machine file rather than something to automate, so it is worth a look while visiting each box.

Relates to #364. The tooling matrix half is #483. Landed in #665.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions