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
PreToolUsematcher entry;Bashis the default.
Functions§
- hook_
command - The hook command string written into settings for
mode. - install
- Install the steering hook into
existingsettings text (or create a fresh document), gating each tool intools. Returns the new text and whether it changed. Idempotent: re-installing the same command/tools is a no-op; a--modechange rewrites the command in place; a new tool adds its matcher. Comments and layout inexistingare preserved. - uninstall
- Remove every steering hook from
existingsettings text, pruning emptied matcher entries (and thePreToolUse/hookscontainers when they end up empty). Comments and layout elsewhere are preserved.