Skip to content
Development
Hook

Hooks

What davegoldblatt-recall runs automatically, and when. A hook is a command Claude Code fires at a fixed moment, without you asking for it.

From plugin
davegoldblatt-recall
20310 skills10 commands2 hooks
Install
$ npx -y skills add davegoldblatt/total-recall --agent claude-code

Ships with davegoldblatt-recall. Installing the plugin gets these hooks.

What fires, and when

SessionStart

Fires once when a session begins, and again after a context compaction. It is where a plugin sets up its environment, or restores state the compaction dropped.

  • "${CLAUDE_PLUGIN_ROOT}"/hooks/session-start.sh

PreCompact

  • "${CLAUDE_PLUGIN_ROOT}"/hooks/pre-compact.sh
Read hooks/hooks.json

Where it lives

  • hooks/pre-compact.shRunsGitHub
    Read the script
    #!/usr/bin/env bash
    # Total Recall — PreCompact Hook
    #
    # Fires before context compaction. Writes a compaction marker to today's
    # daily log. Does NOT read or parse conversation transcripts.
    #
    # Hook input: JSON object on stdin (ignored — we only write files).
    
    set -euo pipefail
    
    # Use Claude Code's project dir env var, fall back to git root or cwd
    PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
    MEMORY_DIR="$PROJECT_ROOT/memory"
    TODAY="$(date +%Y-%m-%d)"
    NOW="$(date +%H:%M)"
    DAILY="$MEMORY_DIR/daily/$TODAY.md"
    
    # Bail if memory system isn't initialized
    if [ ! -d "$MEMORY_DIR/daily" ]; then
      exit 0
    fi
    
    # Create today's daily log if it doesn't exist
    if [ ! -f "$DAILY" ]; then
      cat > "$DAILY" << EOF
    # $TODAY
    
    ## Decisions
    
    ## Corrections
    
    ## Commitments
    
    ## Open Loops
    
    ## Notes
    EOF
    fi
    
    # Drain stdin so the hook doesn't hang
    if ! [ -t 0 ]; then
      cat > /dev/null
    fi
    
    # Append compaction marker
    echo "" >> "$DAILY"
    echo "## [pre-compact $NOW]" >> "$DAILY"
    echo "" >> "$DAILY"
    echo "- Compaction occurred at $NOW. Review recent work and use /recall-write to preserve anything important." >> "$DAILY"
    echo "" >> "$DAILY"
    
  • hooks/session-start.shRunsGitHub
    Read the script
    #!/usr/bin/env bash
    # Total Recall — SessionStart Hook
    #
    # Fires on session start. Stdout is injected as additional context.
    # Reads open loops and recent daily log highlights to prime the session.
    
    set -euo pipefail
    
    # Use Claude Code's project dir env var, fall back to git root or cwd
    PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
    MEMORY_DIR="$PROJECT_ROOT/memory"
    
    # Bail if memory system isn't initialized
    if [ ! -d "$MEMORY_DIR" ]; then
      exit 0
    fi
    
    TODAY="$(date +%Y-%m-%d)"
    YESTERDAY="$(date -v-1d +%Y-%m-%d 2>/dev/null || date -d 'yesterday' +%Y-%m-%d 2>/dev/null || echo '')"
    
    echo "## Total Recall — Session Context"
    echo ""
    
    # Open loops (always relevant)
    OPEN_LOOPS="$MEMORY_DIR/registers/open-loops.md"
    if [ -f "$OPEN_LOOPS" ]; then
      ACTIVE_ITEMS=$(grep -c '^\- \[ \]' "$OPEN_LOOPS" 2>/dev/null || echo "0")
      if [ "$ACTIVE_ITEMS" -gt 0 ]; then
        echo "### Open Loops ($ACTIVE_ITEMS active)"
        grep '^\- \[ \]' "$OPEN_LOOPS" 2>/dev/null || true
        echo ""
      fi
    fi
    
    # Today's daily log
    DAILY_TODAY="$MEMORY_DIR/daily/$TODAY.md"
    if [ -f "$DAILY_TODAY" ]; then
      LINES=$(wc -l < "$DAILY_TODAY" | tr -d ' ')
      if [ "$LINES" -gt 5 ]; then
        echo "### Today's Log ($TODAY) — $LINES lines"
        tail -20 "$DAILY_TODAY"
        echo ""
      fi
    fi
    
    # Yesterday's daily log (brief)
    if [ -n "$YESTERDAY" ]; then
      DAILY_YESTERDAY="$MEMORY_DIR/daily/$YESTERDAY.md"
      if [ -f "$DAILY_YESTERDAY" ]; then
        echo "### Yesterday's Log ($YESTERDAY)"
        grep -A2 '## Decisions\|## Corrections\|## Commitments\|## Open Loops' "$DAILY_YESTERDAY" 2>/dev/null | head -20 || true
        echo ""
      fi
    fi
    
    # Word count warning on working memory
    if [ -f "$PROJECT_ROOT/CLAUDE.local.md" ]; then
      WORD_COUNT=$(wc -w < "$PROJECT_ROOT/CLAUDE.local.md" | tr -d ' ')
      if [ "$WORD_COUNT" -gt 1200 ]; then
        echo "**Warning**: Working memory (CLAUDE.local.md) at $WORD_COUNT words (limit: 1500). Consider pruning."
        echo ""
      fi
    fi
    

Read the script before you install anything that runs on your machine. This is the one part of a plugin that acts without being asked.

Ships withdavegoldblatt-recall

A memory system for Claude Code that remembers what matters and forgets what doesn't.

Get the whole plugin