{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "MEMEX_CLI_PATH=\"${CLAUDE_PLUGIN_ROOT}/dist/cli.js\"; if [ ! -f \"$MEMEX_CLI_PATH\" ]; then echo '## Memex: plugin dist not found\n\nReinstall the memex Claude Code plugin or run: `npm install -g @touchskyer/memex`'; exit 0; fi && node \"$MEMEX_CLI_PATH\" sync 2>/dev/null; TOTAL=$(node \"$MEMEX_CLI_PATH\" read index 2>/dev/null | grep -c '^\\- \\[\\[' || true); SECTIONS=$(node \"$MEMEX_CLI_PATH\" read index 2>/dev/null | awk '/^## /{ if(s) print s\" (\"c\" cards)\"; s=$0; c=0; next } /^\\- \\[\\[/{ c++ } END{ if(s) print s\" (\"c\" cards)\" }'); if [ \"$TOTAL\" -gt 0 ]; then RECALL=\"When the task touches a topic above, run \\`memex search <keyword>\\` then \\`memex read <slug>\\` for the top hits.\nDo this BEFORE writing code or starting diagnosis — your past self already solved adjacent problems.\nFor full recall: invoke the \\`memex-recall\\` skill.\"; else RECALL=\"No cards yet. Still invoke the \\`memex-recall\\` skill — keyword search may find matches even without an index.\nAfter completing work, invoke \\`memex-retro\\` to start building your knowledge base.\"; fi; echo \"## Memex Memory System Active ($TOTAL cards)\n\n### Your Knowledge Map\n$SECTIONS\n\n### Recall — before starting work\n$RECALL\nNever include actual secrets, credentials, tokens, or exact secret file contents in memex query/body arguments; use abstract descriptions or redacted examples.\n\n### Retro — after completing work\nAfter code changes, debugging, or architectural decisions: invoke \\`memex-retro\\` skill.\nAsk: 'Did I learn something reusable?' If yes, write a card.\nCard format: title, created (YYYY-MM-DD), source: retro, category. Slugs: English kebab-case.\nLanguage: match the user's CLAUDE.md preferences.\" && last_org=$(cat ~/.memex/.last-organize 2>/dev/null || true) && if [ -n \"$last_org\" ]; then days_since=$(( ($(date +%s) - $(python3 -c \"import datetime; print(int(datetime.datetime.strptime('$last_org','%Y-%m-%d').timestamp()))\" 2>/dev/null || echo $(date +%s))) / 86400 )); if [ $days_since -ge 7 ]; then echo \"\nWARNING: Last organize was ${days_since} days ago. Consider /memex-organize.\"; fi; else echo '\nNOTE: /memex-organize has never been run.'; fi"
          }
        ]
      }
    ],
    "Stop": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "echo '## 🧠 Memex Retro Reminder\n\n**MANDATORY**: If this task involved code changes, architectural decisions, debugging, or non-trivial problem solving, you MUST invoke the \\`memex-retro\\` skill NOW before ending your turn.\n\nDid you learn something reusable? Capture it as a knowledge card. Do not include actual secrets, credentials, tokens, or exact secret file contents.\n\n**Skip retro only if**: This was purely informational (no problem solving) or you already captured insights during the session.'"
          }
        ]
      }
    ]
  }
}