Community workarounds for 5 open bugs — hooks, compaction, MCP auth
Summary
Tested workarounds for 5 open bugs affecting heavy hook users with MCP connectors. Production-validated on v2.1.79, macOS, with 8 hooks, Gmail MCP, and Google Drive MCP.
Environment
- Claude Code: v2.1.79
- OS: macOS 26.3.1 Tahoe (Darwin 25.3.0)
- Hooks: 8 configured (PreToolUse, PostToolUse, PreCompact, PostCompact, Notification, Stop, SessionEnd, SessionStart)
- MCP: Gmail, Google Drive, Chrome, Preview, Registry, Scheduled Tasks
- Context: Opus 4.6 1M, 49 knowledge files, 140 skills, 19 agents, 47 commands
Bug 1: False "Hook Error" labels (#34713, #10936, #10463)
Problem: Every hook execution shows "Hook Error" in transcript regardless of success. With 8 hooks, this floods model context and causes premature turn endings.
Root cause: Hooks that output JSON to stdout (e.g. {"decision":"allow"}) without the hookSpecificOutput wrapper trigger the error label. Also, unconsumed stdin causes broken pipe errors.
Workaround applied:
- Always consume stdin with
INPUT=$(cat) at the top of every hook
- Never output JSON to stdout for simple allow/block hooks — use stderr only
- Block messages go to stderr with
[BLOCKED] prefix for clarity
- Redirect all subcommand stderr with
2>/dev/null to prevent stray output
# Before (triggers false error):
echo '{"decision":"block","reason":"blocked"}'
exit 2
# After (clean):
echo "[BLOCKED] Reason here" >&2
exit 2
Impact: Eliminates 100% of false hook error labels in our setup.
Bug 2: CLAUDE_AUTOCOMPACT_PCT_OVERRIDE is counterproductive (#24677, #31806)
Problem: Setting CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=75 causes earlier compaction, not later. The env var can only lower the threshold (Math.min clamp in source), so values below default (~83.5%) trigger compaction sooner, wasting working space.
Workaround: Remove the env var entirely. On 1M context models (Opus 4.6, Sonnet 4.6), the default threshold provides ample working space. The death spiral is effectively eliminated by the 5x larger context window.
Suggestion for Anthropic: Document clearly that this env var can only lower the threshold, and consider renaming it or adding validation that warns when the value is below default.
Bug 3: MCP connectors lose auth after compaction (#34832)
Problem: Gmail and Google Drive MCP connectors silently lose OAuth session tokens after auto-compaction. The UI still shows "connected" but tool calls fail.
Workaround applied: Added a PostCompact hook that sends a macOS notification reminding to toggle connectors OFF/ON:
{
"PostCompact": [{
"hooks": [{
"type": "command",
"command": "osascript -e 'display notification \"MCP connectors may need re-auth\" with title \"Context Compacted\" sound name \"Glass\"' 2>/dev/null; cat > /dev/null"
}]
}]
}
Suggestion for Anthropic: Persist MCP auth state outside conversation context (e.g., in mcp-needs-auth-cache.json or process environment) so it survives compaction.
Bug 4: No hook hot-reload (#22679, #5513 — 81 upvotes)
Problem: Changes to hooks in settings.json require full session restart. No /reload command exists.
Workaround: Created /reload command using SIGHUP signal:
# ~/.claude/commands/reload.md
Esegui: `kill -HUP $PPID`
Combined with a shell wrapper function that catches exit code 129 and restarts with -c (continue). This preserves session context while reloading hooks from disk.
Suggestion for Anthropic: Implement /reload or /refresh-hooks as a built-in command. The SIGHUP approach works but requires a wrapper script.
Bug 5: 529 Overloaded mitigation (#35487)
Configuration that helps:
ENABLE_TOOL_SEARCH=auto:5 — defers MCP tool definitions, reducing tokens per request
subagentModel: haiku — routes subagents to separate capacity pool
SLASH_COMMAND_TOOL_CHAR_BUDGET=15000 — limits skill expansion
MAX_THINKING_TOKENS=8000 — caps thinking overhead
- Manual
/compact at natural breakpoints instead of relying on auto-compaction
General recommendations
- Document hook exit code semantics prominently: exit 0 = allow, exit 1 = error (fail-open!), exit 2 = block. Many users use exit 1 thinking it blocks.
- Add
PostCompact to hooks documentation: It's supported but undocumented.
- Consider a
--validate-hooks CLI flag to test hook scripts before deployment.
Community workarounds for 5 open bugs — hooks, compaction, MCP auth
Summary
Tested workarounds for 5 open bugs affecting heavy hook users with MCP connectors. Production-validated on v2.1.79, macOS, with 8 hooks, Gmail MCP, and Google Drive MCP.
Environment
Bug 1: False "Hook Error" labels (#34713, #10936, #10463)
Problem: Every hook execution shows "Hook Error" in transcript regardless of success. With 8 hooks, this floods model context and causes premature turn endings.
Root cause: Hooks that output JSON to stdout (e.g.
{"decision":"allow"}) without thehookSpecificOutputwrapper trigger the error label. Also, unconsumed stdin causes broken pipe errors.Workaround applied:
INPUT=$(cat)at the top of every hook[BLOCKED]prefix for clarity2>/dev/nullto prevent stray outputImpact: Eliminates 100% of false hook error labels in our setup.
Bug 2: CLAUDE_AUTOCOMPACT_PCT_OVERRIDE is counterproductive (#24677, #31806)
Problem: Setting
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=75causes earlier compaction, not later. The env var can only lower the threshold (Math.min clamp in source), so values below default (~83.5%) trigger compaction sooner, wasting working space.Workaround: Remove the env var entirely. On 1M context models (Opus 4.6, Sonnet 4.6), the default threshold provides ample working space. The death spiral is effectively eliminated by the 5x larger context window.
Suggestion for Anthropic: Document clearly that this env var can only lower the threshold, and consider renaming it or adding validation that warns when the value is below default.
Bug 3: MCP connectors lose auth after compaction (#34832)
Problem: Gmail and Google Drive MCP connectors silently lose OAuth session tokens after auto-compaction. The UI still shows "connected" but tool calls fail.
Workaround applied: Added a
PostCompacthook that sends a macOS notification reminding to toggle connectors OFF/ON:{ "PostCompact": [{ "hooks": [{ "type": "command", "command": "osascript -e 'display notification \"MCP connectors may need re-auth\" with title \"Context Compacted\" sound name \"Glass\"' 2>/dev/null; cat > /dev/null" }] }] }Suggestion for Anthropic: Persist MCP auth state outside conversation context (e.g., in
mcp-needs-auth-cache.jsonor process environment) so it survives compaction.Bug 4: No hook hot-reload (#22679, #5513 — 81 upvotes)
Problem: Changes to hooks in settings.json require full session restart. No
/reloadcommand exists.Workaround: Created
/reloadcommand using SIGHUP signal:Combined with a shell wrapper function that catches exit code 129 and restarts with
-c(continue). This preserves session context while reloading hooks from disk.Suggestion for Anthropic: Implement
/reloador/refresh-hooksas a built-in command. The SIGHUP approach works but requires a wrapper script.Bug 5: 529 Overloaded mitigation (#35487)
Configuration that helps:
ENABLE_TOOL_SEARCH=auto:5— defers MCP tool definitions, reducing tokens per requestsubagentModel: haiku— routes subagents to separate capacity poolSLASH_COMMAND_TOOL_CHAR_BUDGET=15000— limits skill expansionMAX_THINKING_TOKENS=8000— caps thinking overhead/compactat natural breakpoints instead of relying on auto-compactionGeneral recommendations
PostCompactto hooks documentation: It's supported but undocumented.--validate-hooksCLI flag to test hook scripts before deployment.