Core plugin providing: - Skills: core CLI reference, PHP patterns, Go patterns - Commands: /core:remember for context persistence - Hooks: - PreToolUse: block dangerous commands (rm -rf, sed -i, grep -l |) - PreToolUse: enforce core CLI over raw go/php commands - PostToolUse: auto-format Go/PHP, check for debug statements - PostToolUse: warn about uncommitted work after git commit - PreCompact: save state to prevent amnesia after auto-compact - SessionStart: restore context from recent sessions (<3h) - MCP: core CLI server integration Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
28 lines
792 B
Bash
Executable file
28 lines
792 B
Bash
Executable file
#!/bin/bash
|
|
# Suggest /compact at logical intervals to manage context window
|
|
# Tracks tool calls per session, suggests compaction every 50 calls
|
|
|
|
SESSION_ID="${CLAUDE_SESSION_ID:-$$}"
|
|
COUNTER_FILE="/tmp/claude-tool-count-${SESSION_ID}"
|
|
THRESHOLD="${COMPACT_THRESHOLD:-50}"
|
|
|
|
# Read or initialize counter
|
|
if [[ -f "$COUNTER_FILE" ]]; then
|
|
COUNT=$(($(cat "$COUNTER_FILE") + 1))
|
|
else
|
|
COUNT=1
|
|
fi
|
|
|
|
echo "$COUNT" > "$COUNTER_FILE"
|
|
|
|
# Suggest compact at threshold
|
|
if [[ $COUNT -eq $THRESHOLD ]]; then
|
|
echo "[Compact] ${THRESHOLD} tool calls - consider /compact if transitioning phases" >&2
|
|
fi
|
|
|
|
# Suggest at intervals after threshold
|
|
if [[ $COUNT -gt $THRESHOLD ]] && [[ $((COUNT % 25)) -eq 0 ]]; then
|
|
echo "[Compact] ${COUNT} tool calls - good checkpoint for /compact" >&2
|
|
fi
|
|
|
|
exit 0
|