Skip to content

Claude Code hook-based auto-capture for observe_work #18

Description

@arreyder

Problem

observe_work / memory packet retrieval is opt-in: the agent has to remember to call it. In practice that means it gets called inconsistently across sessions, and we miss exactly the observations that would be most useful to future sessions.

Proposal

Ship a Claude Code hooks bundle in skills/solr-mem/ that auto-captures without any agent effort.

Hooks to wire

  • SessionStart → fetch project profile + inject into first-turn context (pairs with existing issue Auto-context injection: get_briefing tool for relevant memories #1 get_briefing)
  • UserPromptSubmit → optional: record prompt as context (privacy-filtered per the privacy issue)
  • PostToolUse → call observe_work with tool name, file paths touched, key results. Debounce + dedup.
  • Stop / SessionEnd → flush any pending observations, mark session complete
  • PreCompact → re-inject memory packet before context compaction

Design notes

  • Hooks live in the existing skills/solr-mem/ skill bundle
  • Must NOT block the tool call — observe_work is already async via the broker
  • Shell-out to a tiny Go binary that pipes JSON to the MCP server (or hits the REST endpoint if we add one)
  • Ship a user-install flow: solr-mem install-hooks that merges into ~/.claude/settings.json

Acceptance

  • skills/solr-mem/hooks/ with PostToolUse + SessionStart scripts
  • Install command that patches settings.json safely (idempotent, non-destructive merge)
  • Telemetry: hook fires land in Solr as observations with source=hook
  • Documented opt-out for sensitive projects

Prior art

agentmemory wires 12 hooks and claims this is the biggest UX win over manual add()-style APIs. They quote "zero manual effort" as the key differentiator vs mem0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions