The Claude Code Bash hook lived in an OpenCode plugin, a TypeScript npm
package with a build step and a lockfile, though OpenCode is no longer
used. The hook rewrote commands, adding nix build flags and quoting
flake references, which hid the correction from the agent. Because it
rewrote nix build, it also had to approve it, and it approved any
command containing a nix build, whatever else the command ran.
agent-policy is a stdlib-only Python script that either denies a tool
call with a reason or passes it on. It keeps the same rules, but a
command the hook used to rewrite is now denied with a message saying
what to change, and nix build only has to use --no-link. Claude Code
calls it as agent-policy claude-hook, and its unit tests run as a
flake check in place of the plugin's. nix build is approved by a
Bash(nix build *) allow rule instead, which Claude Code matches against
each command in a compound one.
Test plan:
CI
Ran the built hook on a git commit in a jj repo (denied, exit 2)
Built maverick and checked managed-settings.json carries the hook
and the allow rule
The Claude Code Bash hook lived in an OpenCode plugin, a TypeScript npm
package with a build step and a lockfile, though OpenCode is no longer
used. The hook rewrote commands, adding nix build flags and quoting
flake references, which hid the correction from the agent. Because it
rewrote nix build, it also had to approve it, and it approved any
command containing a nix build, whatever else the command ran.
agent-policy is a stdlib-only Python script that either denies a tool
call with a reason or passes it on. It keeps the same rules, but a
command the hook used to rewrite is now denied with a message saying
what to change, and nix build only has to use --no-link. Claude Code
calls it as `agent-policy claude-hook`, and its unit tests run as a
flake check in place of the plugin's. nix build is approved by a
Bash(nix build *) allow rule instead, which Claude Code matches against
each command in a compound one.
Test plan:
- CI
- Ran the built hook on a git commit in a jj repo (denied, exit 2)
- Built maverick and checked managed-settings.json carries the hook
and the allow rule
The Claude Code Bash hook lived in an OpenCode plugin, a TypeScript npm
package with a build step and a lockfile, though OpenCode is no longer
used. The hook rewrote commands, adding nix build flags and quoting
flake references, which hid the correction from the agent. Because it
rewrote nix build, it also had to approve it, and it approved any
command containing a nix build, whatever else the command ran.
agent-policy is a stdlib-only Python script that either denies a tool
call with a reason or passes it on. It keeps the same rules, but a
command the hook used to rewrite is now denied with a message saying
what to change, and nix build only has to use --no-link. Claude Code
calls it as `agent-policy claude-hook`, and its unit tests run as a
flake check in place of the plugin's. nix build is approved by a
Bash(nix build *) allow rule instead, which Claude Code matches against
each command in a compound one.
Test plan:
- CI
- Ran the built hook on a git commit in a jj repo (denied, exit 2)
- Built maverick and checked managed-settings.json carries the hook
and the allow rule
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
The Claude Code Bash hook lived in an OpenCode plugin, a TypeScript npm
package with a build step and a lockfile, though OpenCode is no longer
used. The hook rewrote commands, adding nix build flags and quoting
flake references, which hid the correction from the agent. Because it
rewrote nix build, it also had to approve it, and it approved any
command containing a nix build, whatever else the command ran.
agent-policy is a stdlib-only Python script that either denies a tool
call with a reason or passes it on. It keeps the same rules, but a
command the hook used to rewrite is now denied with a message saying
what to change, and nix build only has to use --no-link. Claude Code
calls it as
agent-policy claude-hook, and its unit tests run as aflake check in place of the plugin's. nix build is approved by a
Bash(nix build *) allow rule instead, which Claude Code matches against
each command in a compound one.
Test plan:
and the allow rule
aa5b5d62b1to7b7acad3e37b7acad3e3toe22bb79adb