Help us shape the future of Go! Take the 2026 Go Developer Survey

claudehooks

package
v1.55.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package claudehooks installs and detects Stapler Squad's standalone Claude Code hooks in a global ~/.claude/settings.json file.

Two independent hooks are supported:

  • Rules: a PreToolUse hook running "<ssq-hooks> check", which classifies each tool request against the local rules database (allow/deny).
  • Notifications: Notification + Stop hooks running "<ssq-hook-handler> <event>", which produce audio chimes / attention alerts.

Unlike the per-session HTTP hooks in server/services/hook_injector.go (which are scoped to a stapler-squad-managed session via X-CS-Session-ID), these target the user's GLOBAL settings so they fire for any Claude Code session, including ones started from a plain terminal.

All mutations are idempotent and write atomically (temp file + rename).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGlobalSettingsPath

func DefaultGlobalSettingsPath() (string, error)

DefaultGlobalSettingsPath returns ~/.claude/settings.json.

func InstallNotifications

func InstallNotifications(settingsPath, handlerPath string) error

InstallNotifications registers "<handlerPath> notification" and "<handlerPath> stop" as Notification and Stop hooks. Idempotent per event.

func InstallRules

func InstallRules(settingsPath, binPath string) error

InstallRules registers "<binPath> check" as a PreToolUse hook. Idempotent: it is a no-op if a PreToolUse hook with the rules marker is already present.

func RulesHookCommand

func RulesHookCommand(binPath string) string

RulesHookCommand is the PreToolUse command for a given ssq-hooks binary path.

Types

type Status

type Status struct {
	RulesInstalled         bool `json:"rulesInstalled"`
	NotificationsInstalled bool `json:"notificationsInstalled"`
}

Status reports which of our global hooks are currently installed.

func DetectStatus

func DetectStatus(settingsPath string) (Status, error)

DetectStatus reads settingsPath and reports which hooks are present. A missing settings file is not an error — it reports both hooks as not installed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL