Skip to content
Agent Orchestration
Hook

Hooks

What bernstein runs automatically, and when. A hook is a command Claude Code fires at a fixed moment, without you asking for it.

From plugin
bernstein
1.2k26 skills1 agent3 commands1 hook
+1

Claude Code

$ npx -y skills add sipyourdrink-ltd/bernstein --agent claude-code

Where it lives

  • hooks/smart_approve.pyGitHub
    Read the script
    #!/usr/bin/env python3
    """Claude Code PreToolUse hook - smart auto-approve for agent tool calls.
    
    Reads the tool-call payload from stdin (Claude Code hook JSON format),
    classifies the command, and exits with the appropriate code:
    
        Exit 0  - approve  (tool call proceeds)
        Exit 1  - deny     (tool call blocked; reason written to stdout)
        Exit 2  - ask      (escalate to human; reason written to stdout)
    
    Usage in ~/.claude/settings.json or .claude/settings.json:
    
        {
          "hooks": {
            "PreToolUse": [
              {
                "matcher": "Bash",
                "hooks": [
                  {
                    "type": "command",
                    "command": "python /path/to/bernstein/hooks/smart_approve.py"
                  }
                ]
              }
            ]
          }
        }
    
    Or to cover all tools:
    
        {
          "hooks": {
            "PreToolUse": [
              {
                "matcher": "*",
                "hooks": [
                  {
                    "type": "command",
                    "command": "python /path/to/bernstein/hooks/smart_approve.py"
                  }
                ]
              }
            ]
          }
        }
    
    The hook can also be used standalone for testing:
    
        echo '{"tool_name": "Bash", "tool_input": {"command": "ls -la"}}' | python hooks/smart_approve.py
        echo $?   # 0 - approved
    """
    
    from __future__ import annotations
    
    import json
    import sys
    
    
    def main() -> int:
        """Read hook payload from stdin, classify, return exit code."""
        try:
            raw = sys.stdin.read()
            if not raw.strip():
                # No input - allow (edge case in some hook configurations)
                return 0
            payload: dict[str, object] = json.loads(raw)
        except (json.JSONDecodeError, OSError) as exc:
            # Cannot parse → escalate to human
            print(json.dumps({"decision": "ask", "reason": f"Hook parse error: {exc}"}))
            return 2
    
        tool_name = str(payload.get("tool_name", ""))
        tool_input_raw = payload.get("tool_input", {})
        tool_input: dict[str, object] = (
            dict(tool_input_raw)  # type: ignore[arg-type]
            if isinstance(tool_input_raw, dict)
            else {}
        )
    
        # Import here so the hook works even when bernstein isn't on PYTHONPATH:
        # fall back to a copy of the logic if the package isn't importable.
        try:
            from bernstein.core.auto_approve import Decision, classify_tool_call
    
            result = classify_tool_call(tool_name, tool_input)
        except ImportError:
            # Fallback: approve everything if the package isn't installed.
            # This preserves the previous --dangerously-skip-permissions behaviour.
            print(json.dumps({"decision": "approve", "reason": "bernstein not installed; fallback approve"}))
            return 0
    
        if result.decision == Decision.APPROVE:
            # Writing nothing to stdout is the standard "allow" signal.
            return 0
    
        if result.decision == Decision.DENY:
            print(json.dumps({"decision": "block", "reason": result.reason}))
            return 1
    
        # ASK - escalate to human
        print(json.dumps({"decision": "ask", "reason": result.reason}))
        return 2
    
    
    if __name__ == "__main__":
        sys.exit(main())
    

Read the script before you install anything that runs on your machine. This is the one part of a plugin that acts without being asked.

@sipyourdrink-ltd
Ships withbernstein

The open-source governance layer for AI agents: write the rules declaratively, Bernstein enforces them and produces the verifiable, replayable record. Free, Apache-2.0. https://bernstein.run

1.2k26 skills1 agent1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
1.2k
Star history of sipyourdrink-ltd/bernstein on GitHub, a chart by star-history.com

More plugins that ship hooks.

oh-my-claudecode

oh-my-claudecode

Splits a complex task across several specialized Claude Code agents working in parallel, then keeps going until the result is checked. You describe what you want in plain language instead of memorizing commands.

84 skills+441k
@yeachan-heo@yeachan-heo
Install Plugin
ouroboros

ouroboros

Turns a rough feature idea into a written spec through guided questions, then has the agent build it and checks the result against that spec. Instead of hand-checking whether the work is finished, you get an automatic evaluation gate that runs in your coding agent.

26 skills+36.4k
@q00@q00
Install Plugin
myclaude

myclaude

A plugin that runs coding tasks through multiple AI backends (Codex, Claude, Gemini, OpenCode) with a structured development workflow, parallel execution, browser automation and multi-session task checkpointing.

11 skills+32.8k
@stellarlinkco@stellarlinkco
Install Plugin
harmonist

harmonist

Coordinates AI agents with mechanical protocol enforcement, a workflow gate, memory validation and a session hook. Includes a catalog of specialist agents and has no runtime dependencies.

199 agents+12.2k
@gammalabtechnologies@gammalabtechnologies
Install Plugin
fablize

fablize

A Claude Code plugin that enforces finishing multi-step tasks with evidence and verification at each stage. It works as a procedure for Opus or any Claude model, not as chance.

1 skill+2891
@fivetaku@fivetaku
Install Plugin
hello2cc

hello2cc

Adjusts how third-party models behave inside Claude Code so they run closer to a native Opus session, covering subagent lifecycle, session hooks and tool interception. It does not replace your gateway, provider mapping or account setup.

1 agent11 hooks690
@hellowind777@hellowind777
Install Plugin
super-board

super-board

Autonomous GitHub Project build → QA → review loop for Claude Code. One-line install.

10 skills7 hooks670
@erictechpro@erictechpro
Install Plugin
bkit

bkit

Runs a PDCA workflow with phase gating, spec checks, and delegation to sub-agents for planning, QA, and deployment. Fires at session start and on prompts, edits, task creation, and phase transitions.

44 skills+3605
@ww-w-ai@ww-w-ai
Install Plugin

Questions about the hooks in bernstein.

Which coding agents can use the hooks in bernstein?
The hooks in bernstein install in Claude Code and Cursor: each runs Claude Code hooks from .claude/settings.json, so copy the hooks there.