#!/bin/bash # Suggest /compact after ~50 tool calls # Event: PreToolUse | Matcher: Edit|Write # Profile: standard # Non-blocking reminder (exit 0) COUNTER_FILE="${CLAUDE_PROJECT_DIR:-.}/.claude/hooks/.tool-counter" # Initialize counter if it doesn't exist if [ ! -f "$COUNTER_FILE" ]; then echo "0" > "$COUNTER_FILE" fi # Increment counter COUNT=$(cat "$COUNTER_FILE" 2>/dev/null || echo "0") COUNT=$((COUNT + 1)) echo "$COUNT" > "$COUNTER_FILE" # Suggest compact every 50 calls if [ $((COUNT % 50)) -eq 0 ]; then echo "Context optimization: $COUNT tool calls in this session. Consider running /strategic-compact if context feels bloated." >&2 fi exit 0