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
cd your-projectnpx @justack/claude-hook initThe wizard will:
- Prompt for your API key (
jstk_...) or readJUSTACK_API_KEYfrom env - Prompt for the reviewer’s email address
- Validate credentials against the Justack API
- Create
.justack/config.jsonwith 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 reasonThe 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
| Tool | Mode | Behavior |
|---|---|---|
Bash | pattern | Auto-approves safe commands, flags dangerous ones, asks for unknown |
Write | all | All file writes require approval |
Edit | all | All file edits require approval |
mcp__* | all | All 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
| Mode | Behavior |
|---|---|
all | Every call to this tool requires approval |
none | Auto-approve everything (skip this tool) |
pattern | Match 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:
- If the command matches a safe pattern → auto-approve
- If the command matches a dangerous pattern → require approval
- If neither matches → require approval (safe by default)
Patterns are simple substring matches against the command string.
Environment variables
| Variable | Description |
|---|---|
JUSTACK_API_KEY | API key (used by init if set, avoids interactive prompt) |
Approval flow
When a tool call requires approval, the hook:
- Creates or resumes a Justack session for the current Claude Code session
- Logs the tool call as formatted markdown (commands, diffs, JSON for MCP tools)
- 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
- Quickstart — Set up the Justack SDK
- Sessions Guide — How sessions and ask/log work
- TypeScript SDK — Full SDK reference