Problem
hooks/hooks.json prefixes both the SessionStart and PreCompact hooks with:
npm install --silent --prefix ${CLAUDE_PLUGIN_ROOT} --omit=dev --no-audit --no-fund >/dev/null 2>&1 && node ...
This runs a full npm install on every session start and every compaction, even when node_modules is already populated. With the shipped 73MB package-lock.json, that install takes ~5 minutes of pure CPU on my machine (Fedora, npm 10.x):
real 5m2.947s
user 5m2.375s
sys 0m3.994s
Net effect: every claude --continue / claude --resume hangs for ~5 minutes before the prompt is usable, and PreCompact stalls compaction the same way. Because the install is silenced, there is no indication of what is blocking.
Fix
Guard the install so it only runs when dependencies are missing:
[ -d "${CLAUDE_PLUGIN_ROOT}/node_modules" ] || npm install --silent --prefix ${CLAUDE_PLUGIN_ROOT} --omit=dev --no-audit --no-fund >/dev/null 2>&1; node ${CLAUDE_PLUGIN_ROOT}/hooks/session-start.js
(and the same for the PreCompact command.)
With the guard, the hook completes in 0.11s. npm ci with the guard would also work and is more reproducible. Alternatively, run the install once at plugin install time rather than per-hook.
Plugin version: 0.2.8.
Problem
hooks/hooks.jsonprefixes both the SessionStart and PreCompact hooks with:This runs a full
npm installon every session start and every compaction, even whennode_modulesis already populated. With the shipped 73MBpackage-lock.json, that install takes ~5 minutes of pure CPU on my machine (Fedora, npm 10.x):Net effect: every
claude --continue/claude --resumehangs for ~5 minutes before the prompt is usable, and PreCompact stalls compaction the same way. Because the install is silenced, there is no indication of what is blocking.Fix
Guard the install so it only runs when dependencies are missing:
(and the same for the PreCompact command.)
With the guard, the hook completes in 0.11s.
npm ciwith the guard would also work and is more reproducible. Alternatively, run the install once at plugin install time rather than per-hook.Plugin version: 0.2.8.