-
Couldn't load subscription status.
- Fork 1.2k
Open
Description
Persistent "Stop hook error" in Claude Code despite proper configuration
Environment
- claude-flow version: v2.7.1 (stable)
- Installation method:
npm install -g claude-flow@2.7.1 - IDE: Claude Code (Anthropic's official CLI)
- OS: Linux (GitHub Codespaces)
- Node version: v22.17.0
Issue Description
The Stop hook continuously fails with "Stop hook error" messages appearing after nearly every operation in Claude Code, despite:
- Proper installation of claude-flow v2.7.1 stable
- Hooks being configured to use global
claude-flowcommand (not npx) - All other hooks (PreToolUse, PostToolUse) working correctly
- The hook command itself working when executed manually
Current Configuration
.claude/settings.json Stop Hook:
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "claude-flow hooks session-end --generate-summary true --persist-state true --export-metrics true || exit 0"
}
]
}
]Environment:
"env": {
"CLAUDE_FLOW_HOOKS_ENABLED": "true",
"CLAUDE_FLOW_CHECKPOINTS_ENABLED": "true"
}Reproduction Steps
- Install claude-flow v2.7.1:
npm install -g claude-flow@2.7.1 - Initialize:
claude-flow init --force - Update all hook commands from
npx claude-flow@alphatoclaude-flow(global) - Execute any Bash command or tool in Claude Code
- Observe "Stop hook error" messages appearing repeatedly
Expected Behavior
The Stop hook should:
- Execute silently when stopping background processes
- Generate session summaries without errors
- Not interfere with normal operations
Actual Behavior
- "Stop hook error" appears 3 times after nearly every operation
- Errors persist even with
|| exit 0fallback - Manual execution of the hook command works perfectly:
$ claude-flow hooks session-end --generate-summary true --persist-state true --export-metrics true ✅ Session-end hook completed
What We've Tried
- ✅ Updated from alpha version to v2.7.1 stable
- ✅ Changed from
npx claude-flow@alphato globalclaude-flowcommand - ✅ Added
|| exit 0fallback to prevent failure propagation - ✅ Removed all
.claude/hooks/*.shshell script files - ✅ Verified hook command works when run directly
- ❌ Setting
"Stop": [](empty) - This stops errors but defeats the purpose
Additional Context
- PreToolUse hooks (
pre-command,pre-edit) work correctly - PostToolUse hooks (
post-command,post-edit) work correctly - PreCompact hooks work correctly
- Only the Stop hook consistently fails
Screenshots
The error appears like this in Claude Code:
● Bash(claude-flow --version && echo "---" && which claude-flow)
⎿ v2.7.1
⎿ Stop hook error
⎿ Stop hook error
⎿ Stop hook error
Hypothesis
The Stop hook may be invoked in contexts where:
- stdin/stdout are not available (background process termination)
- The working directory or environment differs from normal execution
- Session state or database locks prevent proper execution
- Multiple Stop events fire simultaneously, causing race conditions
Requested Solution
- Make Stop hooks more resilient to execution context issues
- Add debug logging to help diagnose why Stop hooks fail
- Provide configuration option to disable Stop hooks without affecting other hooks
- Document what contexts Stop hooks run in and their requirements
Workaround
Current workaround is to disable Stop hooks entirely:
"Stop": []However, this loses the valuable session-end functionality.
Impact
- Clutters terminal output with error messages
- May indicate underlying issues with hook execution
- Affects user confidence in the hook system
- Makes it difficult to see actual errors among hook errors
System Details
$ claude-flow --version
v2.7.1
⚡ Alpha 128 - Build Optimization & Memory Coordination
$ which claude-flow
/home/codespace/nvm/current/bin/claude-flow
$ env | grep CLAUDE
CLAUDECODE=1
CLAUDE_FLOW_AUTO_COMMIT=false
CLAUDE_FLOW_AUTO_PUSH=false
CLAUDE_FLOW_HOOKS_ENABLED=true
CLAUDE_FLOW_CHECKPOINTS_ENABLED=trueWould appreciate guidance on how to properly configure Stop hooks or debug why they're failing in this specific context.
Metadata
Metadata
Assignees
Labels
No labels