claude: replace the OpenCode plugin with an agent-policy script #1509

Merged
JakeHillion merged 1 commits from jj/mvpxzrzxlvlz into main 2026-12-06 14:23:59 +00:00
Owner

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
JakeHillion force-pushed jj/mvpxzrzxlvlz from aa5b5d62b1 to 7b7acad3e3 2026-12-06 14:02:55 +00:00 Compare
JakeHillion added 1 commit 2026-12-06 14:18:42 +00:00
claude: replace the OpenCode plugin with an agent-policy script
commit-validation / validate-single-commit (pull_request) Successful in 3s
buildbot/nix-eval Build done. (30 warnings)
buildbot/nix-build Build done.
buildbot/nix-effects Build done.
e22bb79adb
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
JakeHillion force-pushed jj/mvpxzrzxlvlz from 7b7acad3e3 to e22bb79adb 2026-12-06 14:18:42 +00:00 Compare
JakeHillion merged commit e22bb79adb into main 2026-12-06 14:23:59 +00:00
JakeHillion deleted branch jj/mvpxzrzxlvlz 2026-12-06 14:24:00 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JakeHillion/nixos#1509