From abd25d52087f2fbeb53e09c9947cd1c9578c173d Mon Sep 17 00:00:00 2001 From: rUv Date: Fri, 26 Sep 2025 17:45:35 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=96=20Checkpoint:=20Edit=20/workspaces?= =?UTF-8?q?/claude-code-flow/.claude/commands/hooks/overview.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/checkpoints/1758908711.json | 1 + .claude/checkpoints/1758908713.json | 1 + .claude/commands/hooks/overview.md | 79 +++++++++++++++++++++++++++-- 3 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 .claude/checkpoints/1758908711.json create mode 100644 .claude/checkpoints/1758908713.json diff --git a/.claude/checkpoints/1758908711.json b/.claude/checkpoints/1758908711.json new file mode 100644 index 0000000000..026230b0ab --- /dev/null +++ b/.claude/checkpoints/1758908711.json @@ -0,0 +1 @@ +{"branch": "checkpoint/pre-edit-20250926-174511", "file": "/workspaces/claude-code-flow/.claude/commands/hooks/overview.md", "timestamp": "2025-09-26T17:45:11Z", "type": "pre-edit", "original_branch": "alpha-125"} diff --git a/.claude/checkpoints/1758908713.json b/.claude/checkpoints/1758908713.json new file mode 100644 index 0000000000..82a9e84e88 --- /dev/null +++ b/.claude/checkpoints/1758908713.json @@ -0,0 +1 @@ +{"tag": "checkpoint-20250926-174513", "file": "/workspaces/claude-code-flow/.claude/commands/hooks/overview.md", "timestamp": "2025-09-26T17:45:13Z", "type": "post-edit", "branch": "alpha-125", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 48 ++++++++ .claude-flow/metrics/task-metrics.json | 6 +- .claude/checkpoints/1758908688.json | 1 + .claude/checkpoints/1758908690.json | 1 + .claude/commands/coordination/task-orchestrate.md | 136 ++++++++++++++++++++-- .claude/commands/hooks/overview.md | 15 ++- .claude/commands/memory/memory-usage.md | 106 +++++++++++++++-- claude-flow-wiki | 0 9 files changed, 291 insertions(+), 24 deletions(-) "} diff --git a/.claude/commands/hooks/overview.md b/.claude/commands/hooks/overview.md index 6fb39ccb28..8c8a5a3b10 100644 --- a/.claude/commands/hooks/overview.md +++ b/.claude/commands/hooks/overview.md @@ -42,7 +42,16 @@ Hooks are configured in `.claude/settings.json`: "matcher": "^(Write|Edit|MultiEdit)$", "hooks": [{ "type": "command", - "command": "npx claude-flow hook pre-edit --file '${tool.params.file_path}'" + "command": "npx claude-flow hook pre-edit --file '${tool.params.file_path}' --memory-key 'swarm/editor/current'" + }] + } + ], + "PostToolUse": [ + { + "matcher": "^(Write|Edit|MultiEdit)$", + "hooks": [{ + "type": "command", + "command": "npx claude-flow hook post-edit --file '${tool.params.file_path}' --memory-key 'swarm/editor/complete'" }] } ] @@ -50,14 +59,74 @@ Hooks are configured in `.claude/settings.json`: } ``` +## MCP Tool Integration in Hooks + +Hooks automatically trigger MCP tools for coordination: + +```javascript +// Pre-task hook spawns agents +npx claude-flow hook pre-task --description "[task]" +// Internally calls: +mcp__claude-flow__agent_spawn { type: "appropriate-agent" } + +// Post-edit hook updates memory +npx claude-flow hook post-edit --file "[file]" +// Internally calls: +mcp__claude-flow__memory_usage { + action: "store", + key: "swarm/editor/[file]", + namespace: "coordination", + value: JSON.stringify({ file, changes, timestamp }) +} + +// Session-end hook persists state +npx claude-flow hook session-end +// Internally calls: +mcp__claude-flow__memory_persist { sessionId: "[session-id]" } +``` + +## Memory Coordination Protocol + +All hooks follow the mandatory memory write pattern: + +```javascript +// 1. STATUS - Hook starts +mcp__claude-flow__memory_usage { + action: "store", + key: "swarm/hooks/[hook-name]/status", + namespace: "coordination", + value: JSON.stringify({ status: "running", hook: "[name]" }) +} + +// 2. PROGRESS - Hook processes +mcp__claude-flow__memory_usage { + action: "store", + key: "swarm/hooks/[hook-name]/progress", + namespace: "coordination", + value: JSON.stringify({ progress: 50, action: "processing" }) +} + +// 3. COMPLETE - Hook finishes +mcp__claude-flow__memory_usage { + action: "store", + key: "swarm/hooks/[hook-name]/complete", + namespace: "coordination", + value: JSON.stringify({ status: "complete", result: "success" }) +} +``` + ## Benefits - 🤖 Automatic agent assignment based on file type - 🎨 Consistent code formatting -- 🧠 Continuous neural pattern improvement -- 💾 Cross-session memory persistence -- 📊 Performance metrics tracking +- 🧠 Continuous neural pattern improvement +- 💾 Cross-session memory persistence via MCP tools +- 📊 Performance metrics tracking through memory +- 🔄 Automatic memory coordination between agents +- 🎯 Smart agent spawning based on task analysis ## See Also - [Pre-Edit Hook](./pre-edit.md) - [Post-Edit Hook](./post-edit.md) -- [Session End Hook](./session-end.md) \ No newline at end of file +- [Session End Hook](./session-end.md) +- [Memory Usage](../memory/memory-usage.md) +- [Agent Spawning](../agents/agent-spawning.md) \ No newline at end of file