Hooks
Hooks are how ContextPilot captures local coding-agent activity. Two agents are wired automatically in v1: Claude Code via native hook wrappers, and OpenAI Codex CLI via a session-log watcher daemon. Both produce the same normalized event shape on the local worker at http://127.0.0.1:3848.
Pipelines
Claude Code tool event
↓
managed wrapper in ~/.claude/hooks
↓
POST /api/hook or /api/hooks/batch
↓
worker extracts compact memory
↓
SQLite write + dedupe + ingest audit
↓
searchable by CLI and MCPCodex writes JSONL to ~/.codex/sessions/...
↓
codex-watcher daemon tails new lines
↓
pairs function_call + function_call_output by call_id
↓
POST /api/hook
↓
worker extracts compact memory
↓
same SQLite + dedupe path as ClaudeWhat the beta captures
- File reads: path, content hash, and estimated token weight without storing the full source body.
- File edits: compact edit summary when the hook event includes enough diff context.
- Commands: command metadata, exit code, and compact output summaries.
- Session end: session lifecycle and savings aggregation metadata.
- Manual notes: memories created by
contextpilot rememberor MCP.
Install and verify
contextpilot install
contextpilot doctor
contextpilot eventsdoctor checks that the hook build artifacts exist, the managed wrappers are installed and executable, and Claude MCP registration points at the built server.
Hook event schema
The worker accepts one event at POST /api/hook or many at POST /api/hooks/batch.
The event type. This chooses the extractor path.
The agent name. Claude Code hooks emit "claude"; the Codex watcher emits "codex". Custom integrations may use "manual".
Absolute path to the project root.
Unix epoch milliseconds.
Optional ID used to group events into a session.
For tool events, the tool name from the agent.
Tool input as JSON. File paths and command strings are extracted from here.
Optional tool output. The worker stores compact summaries, not raw source dumps.
Custom events
If you are testing another agent, post matching events directly:
curl -s -X POST http://127.0.0.1:3848/api/hook \
-H 'content-type: application/json' \
-d '{
"kind": "manual",
"agent": "custom",
"projectRoot": "'$PWD'",
"title": "Important project rule",
"content": "Keep tenant billing checks server-side.",
"timestamp": 1716422400000
}'Debugging
contextpilot doctor
contextpilot events --limit 20
contextpilot savingsIf Claude Code events stay empty, restart Claude Code so it reloads hook configuration, then run doctor again. If Codex events are missing, confirm the Codex watcher daemon is running in doctor output. Agent-specific troubleshooting lives in the integration pages linked above.