🔧 Align hooks.json format with .claude/settings.json

- Use bash piping with 'cat | jq' for tool parameter extraction
- Match exact format from working .claude/settings.json
- Add PreCompact hooks for context management
- Add Stop hook for session cleanup

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
rUvandClaude committed 2025-10-09 20:55:24 +00:00
1 parent 55f2ea0f8f
commit 2cf69b9c1c
1 file changed
+28 -72
+28 -72
View File
@@ -2,114 +2,70 @@
"hooks": {
"PreToolUse": [
{
"matcher": "Task",
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "npx claude-flow@alpha hooks pre-task --description '${TOOL_DESCRIPTION}'",
"description": "Prepare coordination before spawning agents"
"command": "cat | jq -r '.tool_input.command // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks pre-command --command '{}' --validate-safety true --prepare-resources true"
}
]
},
{
"matcher": "Write|Edit",
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "npx claude-flow@alpha hooks pre-edit --file '${FILE_PATH}'",
"description": "Setup agent coordination before file modifications"
"command": "cat | jq -r '.tool_input.file_path // .tool_input.path // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks pre-edit --file '{}' --auto-assign-agents true --load-context true"
}
]
}
],
"PostToolUse": [
{
"matcher": "Task",
"hooks": [
{
"type": "command",
"command": "npx claude-flow@alpha hooks post-task --task-id '${TASK_ID}'",
"description": "Store task completion metrics and learnings"
}
]
},
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "npx claude-flow@alpha hooks post-edit --file '${FILE_PATH}' --memory-key 'swarm/${AGENT_ID}/${STEP_ID}'",
"description": "Format code and update neural patterns"
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "npx claude-flow@alpha hooks notify --message 'Command executed: ${COMMAND}'",
"description": "Log bash command execution"
"command": "cat | jq -r '.tool_input.command // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks post-command --command '{}' --track-metrics true --store-results true"
}
]
},
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "cat | jq -r '.tool_input.file_path // .tool_input.path // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks post-edit --file '{}' --format true --update-memory true"
}
]
}
],
"UserPromptSubmit": [
"PreCompact": [
{
"matcher": ".*",
"matcher": "manual",
"hooks": [
{
"type": "command",
"command": "npx claude-flow@alpha hooks session-restore --session-id 'swarm-${SESSION_ID}'",
"description": "Restore swarm context from previous session"
"command": "/bin/bash -c 'INPUT=$(cat); CUSTOM=$(echo \"$INPUT\" | jq -r \".custom_instructions // \\\"\\\"\"); echo \"🔄 PreCompact Guidance:\"; echo \"📋 IMPORTANT: Review CLAUDE.md in project root for:\"; echo \" • 54 available agents and concurrent usage patterns\"; echo \" • Swarm coordination strategies (hierarchical, mesh, adaptive)\"; echo \" • SPARC methodology workflows with batchtools optimization\"; echo \" • Critical concurrent execution rules (GOLDEN RULE: 1 MESSAGE = ALL OPERATIONS)\"; if [ -n \"$CUSTOM\" ]; then echo \"🎯 Custom compact instructions: $CUSTOM\"; fi; echo \"✅ Ready for compact operation\"'"
}
]
},
{
"matcher": "auto",
"hooks": [
{
"type": "command",
"command": "/bin/bash -c 'echo \"🔄 Auto-Compact Guidance (Context Window Full):\"; echo \"📋 CRITICAL: Before compacting, ensure you understand:\"; echo \" • All 54 agents available in .claude/agents/ directory\"; echo \" • Concurrent execution patterns from CLAUDE.md\"; echo \" • Batchtools optimization for 300% performance gains\"; echo \" • Swarm coordination strategies for complex tasks\"; echo \"⚡ Apply GOLDEN RULE: Always batch operations in single messages\"; echo \"✅ Auto-compact proceeding with full agent context\"'"
}
]
}
],
"SessionStart": [
"Stop": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "npx claude-flow@alpha hooks session-start --enable-memory true",
"description": "Initialize coordination system and restore context"
}
]
}
],
"SessionEnd": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "npx claude-flow@alpha hooks session-end --export-metrics true",
"description": "Persist state, export metrics, and train neural patterns"
}
]
}
],
"Notification": [
{
"matcher": "error|warning",
"hooks": [
{
"type": "command",
"command": "npx claude-flow@alpha hooks error-log --level '${LEVEL}' --message '${MESSAGE}'",
"description": "Log errors and warnings for pattern analysis"
}
]
}
],
"SubagentStop": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "npx claude-flow@alpha hooks agent-cleanup --agent-id '${AGENT_ID}'",
"description": "Clean up agent resources and store completion status"
"command": "npx claude-flow@alpha hooks session-end --generate-summary true --persist-state true --export-metrics true"
}
]
}