Hedge
All packs

Guards

Hooks stop an agent's shell commands from running network code, using GitHub outside your owners, pushing past review, or polling in loops.

Add to your Hedge

How it works

  1. Agent's shell command
  2. Guard hook
  3. The command runs or stops

Workflows

  • Shell guards

    On with the pack

    Agents cannot pipe network code into a shell, run a package the project lacks, change how Git maps URLs, use gh outside your GitHub owners, poll in a loop of turns, hide the exit status of a push, commit, merge or gate behind a pipe, kill their own shell with pkill -f, skip Git hooks, force-push without a lease, or push to main of a repository that takes pull requests.

  • Merge gate

    Off until you turn it onNeeds GitHub

    An agent's Trunk enqueue or merge of a pull request waits until hedge proof gate passed at the head of each open layer of its stack, or you overrode the gate for that head.

    Read before you turn it on

    An enqueue or merge waits up to 15 seconds while the gate reads GitHub and the decision ledger, and it is refused when either cannot be read. Repositories in guards.merge-gate-exempt skip the gate.

  • Signed Git allowlist

    Off until you turn it onNeeds a devbox

    Git refuses any remote whose GitHub owner is not on a list you signed. With the shell guards on, gh follows the same list.

    Read before you turn it on

    Git refuses every remote outside the signed list, including other hosts than GitHub. Root, or anyone with sudo, can remove it. It stops mistakes, not a hostile agent. An agent that runs as you can override it with its own Git config, or edit the staged script before you run it with sudo.

  • Package age

    On with the pack

    Package installs through pnpm and Bun take only versions at least three days old, unless a project or you set another age.

  • OOM survival

    Off until you turn it onNeeds a devbox

    Before memory runs out, earlyoom stops a runaway test or build, and T3's agent threads survive when the kernel kills a process inside them.

  • gh stack

    Off until you turn it onNeeds GitHub

    Hedge installs GitHub's gh stack extension at a pinned version with a checked digest, and the push guard counts the branches a gh stack push sends.

What it costs

You run nothing. A hook checks each shell command before it starts.

Know before you turn it on

A guard can refuse a command you meant. The refusal says why and what to do instead. Every guard is off until you turn it on.

Settings6 settings that your agent asks about
  • guards.personWhom should a refusal tell the agent to ask, such as your first name?Default: the person who runs this machine
  • guards.ownersWhich GitHub owners may agents use, separated by commas, such as you,your-org?
  • guards.main-push-reposWhich GitHub repositories take pushes straight to main or master, as owner/name separated by commas?
  • guards.allow-rulesWhich Claude allow rules that skip the auto-mode review does this machine add for gh, one per line? The shell guards refuse each command such a rule matches that does more than the rule is for.
  • guards.merge-gate-exemptWhich GitHub repositories may agents merge without a hedge proof gate pass, as owner/name or owner/* separated by commas?
  • guards.signersWhich SSH public keys may sign the Git allowlist, one per line?

Add Guards to your Hedge

Paste this prompt into a T3 Code thread on a machine that runs Hedge.

Your install prompt

Add this Hedge pack to my setup with me: Guards.

Hedge runs on my hub and my nodes in the cloud, not on my Mac. Run each command of this prompt on the hub, over SSH with the `PATH` line of https://raw.githubusercontent.com/PostHog/hedge/main/SETUP.md when you run elsewhere. Install nothing from Hedge here. Ask me each choice with your question tool, and run every command yourself.

1. Find my hub. List my cloud boxes as step 1 of https://raw.githubusercontent.com/PostHog/hedge/main/SETUP.md does, and run `hedge hub status` over SSH on each one that runs, until one names the hub. Do not ask a `hedge` on this Mac: an earlier setup can leave one here. The name after "The hub:" is the SSH name of the hub. In each SSH command of a note, put that whole name in place of the host that holds `<hub>`. When every box prints "The hub: not named", or no box runs Hedge, I have no hub yet. Tell me, and offer to set one up first with steps 5, 7, and 9 of https://raw.githubusercontent.com/PostHog/hedge/main/SETUP.md. To make a box that already runs Hedge the hub, skip step 5 for it.
2. Run `hedge update` on the hub, so it has the newest engine and packs. Then run `hedge packs` there, and leave out each pack that is already on.
3. Read the setup note of each pack. Ask me what it asks, and collect the flags that it names. Where a note names "the setup command" or "the command in item 2 of step 9", use the `hedge packs` command of this prompt. Do not run a step that a note puts after that command yet.
   - Guards: ~/.local/share/hedge/engine/packs/guards/SETUP.md
4. Turn the packs on with one command on the hub, and add the flags that the notes name:
   hedge packs --add guards
5. Do the steps that each note puts after the command.
6. Run `hedge doctor` on the hub, and explain each line. Do each `To do:` line with me, and say what a sign-in is for before it opens.
7. My nodes take the change at their next `hedge update`. To give it to one now, run `hedge update` there.
Open in T3 Code

Add more packs in one prompt