Hooks Overview

kiteguard integrates with the native hook system of each supported AI agent. The number of interception points varies by agent.

Claude Code hooks

HookWhen it firesPrimary threat
UserPromptSubmitBefore prompt reaches Claude APIPII in prompt, prompt injection
PreToolUseBefore any tool executesDangerous commands, file access
PostToolUseAfter tool returns contentInjection in files, PII in read content
StopAfter response is generatedSecrets/PII in Claude's output

Cursor hooks

HookWhen it firesPrimary threat
beforeSubmitPromptBefore prompt is sentPII, prompt injection
preToolUseBefore any tool callDangerous tool use
beforeShellExecutionBefore a shell command runsDangerous commands
beforeReadFileBefore a file is readSensitive path access
beforeMCPExecutionBefore an MCP tool executesSSRF, command injection, secrets
beforeTabFileReadBefore tab context file is readSensitive path access
postToolUseAfter tool returnsInjection in tool output
afterShellExecutionAfter shell command completesInjection in shell output
afterMCPExecutionAfter MCP tool returnsSecrets in MCP result
afterAgentResponseAfter the final responsePII/secrets in response

All six before* hooks are registered with failClosed: true — if kiteguard fails to start, Cursor blocks the action.

Gemini CLI hooks

HookWhen it fires
before_toolBefore any tool executes
after_toolAfter any tool returns

Why all hooks are needed

No single hook covers every attack vector:

  • Only a prompt hook: Misses injections embedded in files the agent reads
  • Only a pre-tool hook: Can't see file contents, only paths
  • Only a post-response hook: Damage is already done before the response

All hooks together provide complete coverage with no blind spots.