command hook

Claude Code (Global)

Configure governance once in ~/.claude/settings.json and it applies to every Claude Code session across all your projects.

需要 API 密钥

您需要 Neptrix API 密钥才能完成此设置。API 密钥随我们的托管平台 Neptrix for teams 一同提供,该平台目前处于封闭测试阶段。 申请使用。

安装

  1. 1Copy the configuration below
  2. 2Create or open ~/.claude/settings.json in your home directory
  3. 3Paste the configuration and replace YOUR_API_KEY with your key
  4. 4Restart Claude Code: every tool call across all projects now goes through Neptrix
将此配置添加到~/.claude/settings.json
~/.claude/settings.json
1{
2 "hooks": {
3 "PreToolUse": [
4 {
5 "matcher": ".*",
6 "hooks": [
7 {
8 "type": "command",
9 "command": "r=$(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.\"}}'",
10 "timeout": 10
11 }
12 ]
13 }
14 ]
15 }
16}

将 YOUR_API_KEY 替换为您的 API 密钥。 申请使用 Neptrix for teams。

工作原理

1

智能体提议操作

在每次工具调用之前,您的智能体将提议的操作发送给 Neptrix 进行评估。

2

Neptrix 进行评估

宪法治理规则评估操作。决策被记录到您的审计追踪中。

3

返回决策

ALLOW、BLOCK、ESCALATE 或 MODIFY。智能体自动发现,无需注册。

Neptrix for teams 目前处于封闭测试阶段。

申请使用 Neptrix for teams,或申请使用 Neptrix Hub,在您自己的机器上治理智能体。