How the Pollen hook integrates with Claude Code. What events it listens to, what it captures, and how to customize it.
Hook Configuration
The Pollen hook is a Claude Code hook that runs locally on your machine. It processes events from your Claude Code sessions and stores anonymized features in a local SQLite database.
Supported events
The hook handles these Claude Code hook events:
| Event | What it captures |
|---|---|
UserPromptSubmit | Topic classification, intent detection, language, action type |
PostToolUse | Tool name, MCP server (successful invocations) |
PostToolUseFailure | Tool name, MCP server, error context (failed invocations) |
SessionStart | New session registration with timestamp |
SessionEnd | Session arc (intent → outcome), satisfaction scoring |
Stop | Response tracking — count and average length |
Installation
Run the merge-safe setup command:
pollen setupIt installs the pollen-hook executable and preserves any existing hook entries.
The hook reads the event type from the hook_event_name field in the JSON input that Claude Code passes via stdin.
What happens on each prompt
When you submit a prompt in Claude Code:
- Claude Code pipes the event JSON to
pollen-hook - The hook opens
~/.pollen/local.db(creating it if needed) - For
UserPromptSubmit: it classifies the topic and intent locally using a lightweight classifier, then inserts a row into thecontributionstable - For
PostToolUse: it records the tool name, MCP server (if applicable), and success status intotool_events - For
SessionEnd: it computes the session arc and satisfaction score
Privacy
Topic and intent classification is fully local — no API calls, no network requests. If you have ANTHROPIC_API_KEY set, the hook optionally uses Claude Haiku to extract a short subject summary from the first prompt of each session. You can disable this by unsetting the key.
When a session ends, Pollen places a closed receipt in a durable local outbox
and uploads it in the background. pollen sync manually retries pending work.
Neither path copies local tables. Each receipt contains only:
- intent;
- agent and model ID;
- tool-category sequence;
- canonical public MCP server/tool identifiers, success, and latency buckets;
- duration bucket;
- terminal state; and
- check result.
Unknown or custom MCP aliases are grouped as private; their original names
do not leave the machine. Logos are resolved from Pollen's bundled registry,
not supplied by contributor clients.
The Worker independently rejects unknown fields, so raw content cannot be added accidentally by a future client change.
Run pollen pause to stop capture and automatic delivery. Run pollen resume
to continue. pollen leave --delete-network-data deletes server receipts and
revokes the local network credential.
Performance
The hook is designed to be fast enough that you won't notice it:
- Classification is rule-based (no ML inference)
- SQLite writes are synchronous and batched
- Async work (subject extraction) happens in the background and doesn't block the prompt