From 2cf69b9c1c77e106d37becf0cd882194f26ca1af Mon Sep 17 00:00:00 2001 From: rUv Date: Thu, 9 Oct 2025 20:55:24 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Align=20hooks.json=20format=20wi?= =?UTF-8?q?th=20.claude/settings.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .claude-plugin/hooks/hooks.json | 100 +++++++++----------------------- 1 file changed, 28 insertions(+), 72 deletions(-) diff --git a/.claude-plugin/hooks/hooks.json b/.claude-plugin/hooks/hooks.json index 4a4754d065..519bf22a86 100644 --- a/.claude-plugin/hooks/hooks.json +++ b/.claude-plugin/hooks/hooks.json @@ -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" } ] }