Skip to main content

What it does

The hook integration installs a UserPromptSubmit hook that injects a short GitWhy awareness paragraph at the start of every agent turn. This guarantees the agent is aware of GitWhy in every conversation, regardless of context window state.
The hook injects tokens on every prompt turn. Use this method only if other methods (MCP, Skill files, Rules) aren’t sufficient for your workflow.

Setup

Run git why setup and select Hook from the menu, or add the hook configuration below manually. This adds a hook configuration to .claude/settings.local.json (for Claude Code):
When triggered, git-why hook-run outputs a short instruction paragraph that the agent receives before your prompt.

What gets injected

This is approximately 50-60 tokens per prompt turn.

When to use the hook

Use the hook when:
  • The agent frequently loses awareness of GitWhy mid-session
  • You want a hard guarantee that every prompt includes GitWhy context
  • Other integration methods are not available for your agent
Do not use the hook if:
  • Skill files or Rules are working reliably (lower token cost, same awareness)
  • You are concerned about per-turn token usage

Agent compatibility

See also

  • MCP server — tool access without per-turn injection
  • Rules — session-level awareness at lower token cost