Skip to content

Claude Code Hook

@justack/claude-hook registers as a Claude Code PreToolUse hook. When Claude tries to use a tool, the hook evaluates the call against configurable rules, auto-approves safe commands, and routes dangerous or unknown actions to your Justack inbox for approval.

Setup

1. Get a Justack API key

Sign up at justack.dev and create an API key from the dashboard.

2. Initialize the hook

Terminal window
cd your-project
npx @justack/claude-hook init

The wizard will:

  • Prompt for your API key (jstk_...) or read JUSTACK_API_KEY from env
  • Prompt for the reviewer’s email address
  • Validate credentials against the Justack API
  • Create .justack/config.json with default rules
  • Add .justack/ to .gitignore
  • Register the hook in .claude/settings.json

3. Use Claude Code as normal

The hook runs automatically. When Claude triggers a dangerous action, you’ll get a notification in your Justack inbox with the full tool call details, diffs, and an approve/deny prompt.

How it works

Claude Code tool call
→ PreToolUse hook fires
→ Rule engine evaluates tool + arguments
→ Safe? Auto-approve (no output)
→ Dangerous/unknown? Send to Justack inbox
→ Log formatted tool call (command, diff, JSON)
→ Ask reviewer: approve / deny + optional feedback
→ Approved? Allow (with optional modified arguments)
→ Denied? Block with reason

The hook is fail-closed — if Justack is unreachable, the action is denied. If the hook itself crashes, it fails open (exits with code 0) so Claude Code isn’t blocked by bugs.

Default rules

ToolModeBehavior
BashpatternAuto-approves safe commands, flags dangerous ones, asks for unknown
WriteallAll file writes require approval
EditallAll file edits require approval
mcp__*allAll MCP tool calls require approval

Safe patterns (auto-approved): ls, cat, git status, git diff, git log, pnpm install, tsc, eslint, etc.

Dangerous patterns (require approval): rm, git push, sudo, curl -X POST, npm publish, node, python, etc.

Configuration

The config lives at .justack/config.json in your project root:

{
"apiKey": "jstk_...",
"recipientEmail": "reviewer@example.com",
"rules": {
"Bash": {
"mode": "pattern",
"dangerous": ["rm ", "git push", "sudo "],
"safe": ["ls", "git status", "cat "]
},
"Write": { "mode": "all" },
"Edit": { "mode": "all" },
"mcp__*": { "mode": "all" }
}
}

Rule modes

ModeBehavior
allEvery call to this tool requires approval
noneAuto-approve everything (skip this tool)
patternMatch against dangerous and safe substring lists. Unknown commands require approval.

Tool names support glob patterns (e.g. mcp__* matches all MCP tools).

Pattern matching

For pattern mode rules, commands are checked in order:

  1. If the command matches a safe pattern → auto-approve
  2. If the command matches a dangerous pattern → require approval
  3. If neither matches → require approval (safe by default)

Patterns are simple substring matches against the command string.

Environment variables

VariableDescription
JUSTACK_API_KEYAPI key (used by init if set, avoids interactive prompt)

Approval flow

When a tool call requires approval, the hook:

  1. Creates or resumes a Justack session for the current Claude Code session
  2. Logs the tool call as formatted markdown (commands, diffs, JSON for MCP tools)
  3. Asks the reviewer with three inputs:
    • Approve — confirm toggle (default: yes)
    • Feedback — optional text sent back to Claude as additional context
    • Modified arguments — optional JSON to replace the original tool arguments

Next Steps