hooks

package
v1.0.56 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package hooks provides Claude Code hook management functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasSessionCaptureHook

func HasSessionCaptureHook(settings *ClaudeSettings) bool

HasSessionCaptureHook checks if the session capture hook is already installed

func InstallSessionCaptureHook

func InstallSessionCaptureHook() (bool, error)

InstallSessionCaptureHook installs the PostToolUse hook for sl session capture. Returns (installed bool, err error) where installed is true if a new hook was added.

func SaveClaudeSettings

func SaveClaudeSettings(settings *ClaudeSettings) error

SaveClaudeSettings saves settings to ~/.claude/settings.json

func UninstallSessionCaptureHook

func UninstallSessionCaptureHook() (bool, error)

UninstallSessionCaptureHook removes the session capture hook. Returns (removed bool, err error) where removed is true if the hook was found and removed.

Types

type ClaudeSettings

type ClaudeSettings struct {
	Hooks map[string][]HookMatcher `json:"hooks,omitempty"`
	// Preserve other fields
	Other map[string]json.RawMessage `json:"-"`
}

ClaudeSettings represents the structure of ~/.claude/settings.json

func LoadClaudeSettings

func LoadClaudeSettings() (*ClaudeSettings, error)

LoadClaudeSettings loads settings from ~/.claude/settings.json

func (ClaudeSettings) MarshalJSON

func (s ClaudeSettings) MarshalJSON() ([]byte, error)

func (*ClaudeSettings) UnmarshalJSON

func (s *ClaudeSettings) UnmarshalJSON(data []byte) error

Custom JSON marshaling to preserve unknown fields

type Hook

type Hook struct {
	Type    string `json:"type"`
	Command string `json:"command"`
}

Hook represents a single hook configuration

type HookMatcher

type HookMatcher struct {
	Matcher string `json:"matcher"`
	Hooks   []Hook `json:"hooks"`
}

HookMatcher represents a hook matcher in Claude settings

Jump to

Keyboard shortcuts

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