/plugin marketplace add ojallington/session-memory-optimizer/plugin install ojallington-session-memory-optimizer@ojallington/session-memory-optimizerDefined in hooks/hooks.json
{
"PreCompact": [
{
"hooks": [
{
"type": "prompt",
"prompt": "CONTEXT OPTIMIZATION GUIDANCE:\n\nWhen compacting this session, apply these priorities:\n\nPRESERVE (Critical):\n- Current active task and immediate goals\n- Recent decisions and their rationale\n- Active file contents being edited\n- Unresolved errors or blockers\n- User preferences established this session\n- Pending TODOs and action items\n\nPRESERVE (Summarized):\n- Overall project context (summarize, don't lose)\n- Key patterns/conventions established\n- Major milestones and their outcomes\n\nSAFE TO AGGRESSIVELY COMPRESS:\n- Old tool outputs (git status, ls, etc.) that are stale\n- File contents that were subsequently edited (use latest version)\n- Exploratory paths that were explicitly abandoned\n- Verbose error messages that have been resolved\n- Repeated similar exchanges (keep conclusions, drop iterations)\n- Background research no longer actively referenced\n\nCOMPACTION STRATEGY:\n1. Preserve intent and decisions over implementation details\n2. Keep 'why' reasoning, compress 'how' details\n3. Maintain continuity of active work\n4. Summarize completed work, detail pending work\n\nReturn compacted context that maintains productivity.",
"timeout": 30000
}
],
"matcher": "*"
}
],
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/session-end-saver.sh 2>/dev/null || true",
"timeout": 10000
}
],
"matcher": "*"
}
],
"PostToolUse": [
{
"hooks": [
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/post-tool-tracker.sh 2>/dev/null || true",
"timeout": 3000
}
],
"matcher": "Read|Write|Edit|Bash|Grep|Glob"
}
],
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/session-start-loader.sh 2>/dev/null || true",
"timeout": 5000
}
],
"matcher": "*"
}
]
}{
"riskFlags": {
"touchesBash": true,
"matchAllTools": false,
"touchesFileWrites": true
},
"typeStats": {
"prompt": 1,
"command": 3
},
"eventStats": {
"PreCompact": 1,
"SessionEnd": 1,
"PostToolUse": 1,
"SessionStart": 1
},
"originCounts": {
"absolutePaths": 0,
"pluginScripts": 3,
"projectScripts": 0
},
"timeoutStats": {
"commandsWithoutTimeout": 0
}
}