[BUG] the docs say PreCompact fires for both "auto" and "manual" triggers, but auto isn't firing

Resolved 💬 3 comments Opened Feb 16, 2026 by huhoic Closed Feb 19, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

  • Claude Code version: 2.1.42
  • PreCompact + SessionStart hooks configured in ~/.claude/settings.json
  • Hooks fire on manual /compact (debug log confirms)
  • Hooks do NOT fire on auto-compact (debug log has no entries during auto-compact sessions)
  • CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=70 set

Interim workaround: Disable auto-compact and compact manually:

export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=0

What Should Happen?

The hook should fire for auto-compact.

Error Messages/Logs

Steps to Reproduce

The bug: Claude Code's hook system on Windows resolves bash to C:\Windows\System32\bash.exe (WSL bash) instead of Git Bash,
even though Git Bash is the configured shell for the Claude Code session itself.

  1. Windows 11 with WSL components present (even if not fully configured)
  2. Git Bash installed at C:\Program Files\Git\
  3. Both C:\Windows\System32\bash.exe (WSL) and C:\Program Files\Git\usr\bin\bash.exe (Git) exist in PATH
  4. Configure a hook in ~/.claude/settings.json using bash as the command:

"PreCompact": [{ "hooks": [{ "type": "command", "command": "bash .claude/hooks/pre-compact.sh" }] }]

  1. Run /compact
  2. Hook fails with: WSL (9 - Relay) ERROR: CreateProcessCommon:800: execvpe(/bin/bash) failed: No such file or directory

The Claude Code Bash tool uses Git Bash correctly, but the hooks system resolves to WSL bash.

The fix

Update ~/.claude/settings.json to use the full Git Bash path (PROGRA~1 avoids space issues):

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.42

Platform

Other

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

The bug: Claude Code's hook system on Windows resolves bash to C:\Windows\System32\bash.exe (WSL bash) instead of Git Bash,
even though Git Bash is the configured shell for the Claude Code session itself.

  1. Windows 11 with WSL components present (even if not fully configured)
  2. Git Bash installed at C:\Program Files\Git\
  3. Both C:\Windows\System32\bash.exe (WSL) and C:\Program Files\Git\usr\bin\bash.exe (Git) exist in PATH
  4. Configure a hook in ~/.claude/settings.json using bash as the command:

"PreCompact": [{ "hooks": [{ "type": "command", "command": "bash .claude/hooks/pre-compact.sh" }] }]

  1. Run /compact
  2. Hook fails with: WSL (9 - Relay) ERROR: CreateProcessCommon:800: execvpe(/bin/bash) failed: No such file or directory

The Claude Code Bash tool uses Git Bash correctly, but the hooks system resolves to WSL bash.

The fix

Update ~/.claude/settings.json to use the full Git Bash path (PROGRA~1 avoids space issues):

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗