Skip to main content

Module hook

Module hook 

Source
Expand description

Hook CLI command.

Provides the subcog hook subcommand for Claude Code integration. Hooks are invoked by Claude Code at specific lifecycle events to inject context, detect signals, and capture memories.

§Supported Hooks

HookTriggerPurpose
session-startSession beginsInject relevant memories into context
user-prompt-submitUser sends messageDetect search intent, surface memories
post-tool-useTool execution completesSurface related memories
pre-compactBefore context compactionAuto-capture important content
stopSession endsAnalyze session, sync to remote

§Usage

# Called by Claude Code hooks configuration
subcog hook session-start
subcog hook user-prompt-submit --prompt "How do I implement auth?"
subcog hook post-tool-use --tool-name "Read" --result "..."
subcog hook pre-compact --context "..."
subcog hook stop

§Configuration

Hooks are configured in .claude/settings.json:

{
  "hooks": {
    "SessionStart": [{ "type": "command", "command": "subcog hook session-start" }],
    "UserPromptSubmit": [{ "type": "command", "command": "subcog hook user-prompt-submit" }]
  }
}

Structs§

HookCommand
Hook command handler (DOC-H1).