shell hook

Cursor

Drop a shell hook script into .cursor/hooks/ and point Cursor at it. Every AI action gets evaluated before it runs.

API key required

You need a Neptrix API key to complete this setup. API keys come with Neptrix for teams, our hosted platform, which is in closed beta. Request access.

Installation

  1. 1Copy the script below
  2. 2Save it as .cursor/hooks/pre-tool-use.sh in your project
  3. 3Run: chmod +x .cursor/hooks/pre-tool-use.sh
  4. 4Replace YOUR_API_KEY with your key
  5. 5Configure Cursor to use the hook script in Settings > AI > Hooks
Add this configuration to.cursor/hooks/pre-tool-use.sh
.cursor/hooks/pre-tool-use.sh
1#!/bin/sh
2# Neptrix governance hook for Cursor
3# Save this as .cursor/hooks/pre-tool-use.sh and make it executable
4# Fails closed: if Neptrix is unreachable the action is denied.
5# Set NEPTRIX_FAIL_MODE=open to proceed ungoverned instead (not recommended).
6
7r=$(curl -sf --max-time 5 -X POST https://qpthort-backend-production.up.railway.app/hooks/claude-code/pre-tool-use -H "x-api-key: YOUR_API_KEY" -H "Content-Type: application/json" --data-binary @-) && { printf "%s" "$r"; exit 0; }; [ "$NEPTRIX_FAIL_MODE" = "open" ] && { echo "[Neptrix] WARNING: governance service unreachable and NEPTRIX_FAIL_MODE=open - tool call proceeding UNGOVERNED. Unset NEPTRIX_FAIL_MODE to restore fail-closed." >&2; exit 0; }; echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"[Neptrix] Governance service unreachable - action denied. Set NEPTRIX_FAIL_MODE=open to override."}}'

Replace YOUR_API_KEY with your API key. Request access to Neptrix for teams.

How it works

1

Agent proposes action

Before each tool call, your agent sends the proposed action to Neptrix for evaluation.

2

Neptrix evaluates

Constitutional governance rules evaluate the action. The decision is logged to your audit trail.

3

Decision returned

ALLOW, BLOCK, ESCALATE, or MODIFY. Agents auto-discover: no registration needed.

Neptrix for teams is in closed beta.

Request access to Neptrix for teams, or ask for Neptrix Hub and govern your agents on your own machine.