integrations

Cursor

Use Cursor hooks to check brin before installing packages or browsing the web

Cursor's hooks system lets you intercept agent actions before they execute. Use the beforeShellExecution hook to check brin whenever the agent installs a package.

##Setup

1. Create .cursor/hooks.json:

JSON
{
  "version": 1,
  "hooks": {
    "beforeShellExecution": [
      {
        "command": ".cursor/hooks/brin-check.sh",
        "matcher": "npm|yarn|pnpm|bun|pip|cargo"
      }
    ]
  }
}

2. Create .cursor/hooks/brin-check.sh:

Bash
#!/bin/bash
input=$(cat)
cmd=$(echo "$input" | jq -r '.command')
 
# Match install commands
if [[ "$cmd" =~ ^(npm\ (i|install|add)|yarn\ add|pnpm\ (add|i)|bun\ (add|i)|pip\ install|cargo\ add)\ (.+)$ ]]; then
  pkg="${BASH_REMATCH[4]}"
 
  # Detect origin
  if [[ "$cmd" =~ ^pip ]]; then origin="pypi"
  elif [[ "$cmd" =~ ^cargo ]]; then origin="crate"
  else origin="npm"
  fi
 
  # Check brin using response headers for speed
  verdict=$(curl -sf -o /dev/null -w "%header{x-brin-verdict}" "https://api.brin.sh/${origin}/${pkg}")
 
  if [[ "$verdict" == "dangerous" || "$verdict" == "suspicious" ]]; then
    score=$(curl -sf -o /dev/null -w "%header{x-brin-score}" "https://api.brin.sh/${origin}/${pkg}")
    jq -n --arg v "$verdict" --arg s "$score" --arg p "$pkg" \
      '{continue:true, permission:"deny", agent_message:"brin: \($p) is \($v) (score: \($s)). Do not install."}'
  else
    echo '{"continue":true,"permission":"allow"}'
  fi
else
  echo '{"continue":true,"permission":"allow"}'
fi

3. Make it executable:

Bash
chmod +x .cursor/hooks/brin-check.sh

Restart Cursor to load the hook.

##How it works

The hook uses curl response headers (x-brin-verdict, x-brin-score) for a lightweight check — no JSON parsing needed. If the verdict is suspicious or dangerous, the command is blocked and the agent is told why.

If brin is unreachable, the hook allows the command through.

##Global configuration

To apply to all projects, create the hook at ~/.cursor/hooks/brin-check.sh and reference it in ~/.cursor/hooks.json.