Skip to main content

Module install

Module install 

Source
Expand description

Merging the steering hook into a Claude Code settings file. The merge runs through the comment- and layout-preserving ct-patch engine (crate::patch): the existing file is parsed only to decide which edits to make, and those edits are byte-range splices against the original text, so the user’s comments and formatting survive.

Enums§

Scope
Which settings file the hook is written to.
Tool
A harness tool the steering hook can be installed to gate. Each becomes its own PreToolUse matcher entry; Bash is the default.

Functions§

hook_command
The hook command string written into settings for mode.
install
Install the steering hook into existing settings text (or create a fresh document), gating each tool in tools. Returns the new text and whether it changed. Idempotent: re-installing the same command/tools is a no-op; a --mode change rewrites the command in place; a new tool adds its matcher. Comments and layout in existing are preserved.
uninstall
Remove every steering hook from existing settings text, pruning emptied matcher entries (and the PreToolUse/hooks containers when they end up empty). Comments and layout elsewhere are preserved.