[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6BXKA3HCRNFQ8KYRGSPT4XN":3,"skill-same:01M6BXKA3HCRNFQ8KYRGSPT4XN":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":36,"linkOnly":37,"markdownContent":38,"markdownBody":39,"frontMatter":40,"refName":41,"commitSha":42,"skillDirectory":43,"forksCount":44,"repositoryHtmlUrl":45,"repositoryHomepageUrl":6,"ownerHtmlUrl":46,"ownerBlogUrl":47,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M6BXKA3HCRNFQ8KYRGSPT4XN","Hooks Automation",null,"Automated coordination, formatting, and learning from Claude Code operations using intelligent hooks with MCP integration. Includes pre\u002Fpost task hooks, session management, Git integration, memory coordination, and neural pattern training for enhanced development workflows.","diegopacheco\u002Fai-playground","diegopacheco","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F121278?v=4","01M6BXCP8P7GGSJ8M1W2MFDTGT","Diego Pacheco","01M6BXCPD3WM51H465XW9YM4BV",21,"Unlicense","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fclaude-flow-fun\u002F.claude\u002Fskills\u002Fhooks-automation\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[24,5,25,26,27,28,29,30,31,32,33,34,35],"automation","MCP","memory","workflows","training","development","code","git","integration","MCP Integration","learning","coordination","2026-11-10 10:12:30",false,"---\nname: Hooks Automation\ndescription: Automated coordination, formatting, and learning from Claude Code operations using intelligent hooks with MCP integration. Includes pre\u002Fpost task hooks, session management, Git integration, memory coordination, and neural pattern training for enhanced development workflows.\n---\n\n# Hooks Automation\n\nIntelligent automation system that coordinates, validates, and learns from Claude Code operations through hooks integrated with MCP tools and neural pattern training.\n\n## What This Skill Does\n\nThis skill provides a comprehensive hook system that automatically manages development operations, coordinates swarm agents, maintains session state, and continuously learns from coding patterns. It enables automated agent assignment, code formatting, performance tracking, and cross-session memory persistence.\n\n**Key Capabilities:**\n- **Pre-Operation Hooks**: Validate, prepare, and auto-assign agents before operations\n- **Post-Operation Hooks**: Format, analyze, and train patterns after operations\n- **Session Management**: Persist state, restore context, generate summaries\n- **Memory Coordination**: Synchronize knowledge across swarm agents\n- **Git Integration**: Automated commit hooks with quality verification\n- **Neural Training**: Continuous learning from successful patterns\n- **MCP Integration**: Seamless coordination with swarm tools\n\n## Prerequisites\n\n**Required:**\n- Claude Flow CLI installed (`npm install -g claude-flow@alpha`)\n- Claude Code with hooks enabled\n- `.claude\u002Fsettings.json` with hook configurations\n\n**Optional:**\n- MCP servers configured (claude-flow, ruv-swarm, flow-nexus)\n- Git repository for version control\n- Testing framework for quality verification\n\n## Quick Start\n\n### Initialize Hooks System\n\n```bash\n# Initialize with default hooks configuration\nnpx claude-flow init --hooks\n```\n\nThis creates:\n- `.claude\u002Fsettings.json` with pre-configured hooks\n- Hook command documentation in `.claude\u002Fcommands\u002Fhooks\u002F`\n- Default hook handlers for common operations\n\n### Basic Hook Usage\n\n```bash\n# Pre-task hook (auto-spawns agents)\nnpx claude-flow hook pre-task --description \"Implement authentication\"\n\n# Post-edit hook (auto-formats and stores in memory)\nnpx claude-flow hook post-edit --file \"src\u002Fauth.js\" --memory-key \"auth\u002Flogin\"\n\n# Session end hook (saves state and metrics)\nnpx claude-flow hook session-end --session-id \"dev-session\" --export-metrics\n```\n\n---\n\n## Complete Guide\n\n### Available Hooks\n\n#### Pre-Operation Hooks\n\nHooks that execute BEFORE operations to prepare and validate:\n\n**pre-edit** - Validate and assign agents before file modifications\n```bash\nnpx claude-flow hook pre-edit [options]\n\nOptions:\n  --file, -f \u003Cpath>         File path to be edited\n  --auto-assign-agent       Automatically assign best agent (default: true)\n  --validate-syntax         Pre-validate syntax before edit\n  --check-conflicts         Check for merge conflicts\n  --backup-file             Create backup before editing\n\nExamples:\n  npx claude-flow hook pre-edit --file \"src\u002Fauth\u002Flogin.js\"\n  npx claude-flow hook pre-edit -f \"config\u002Fdb.js\" --validate-syntax\n  npx claude-flow hook pre-edit -f \"production.env\" --backup-file --check-conflicts\n```\n\n**Features:**\n- Auto agent assignment based on file type\n- Syntax validation to prevent broken code\n- Conflict detection for concurrent edits\n- Automatic file backups for safety\n\n**pre-bash** - Check command safety and resource requirements\n```bash\nnpx claude-flow hook pre-bash --command \u003Ccmd>\n\nOptions:\n  --command, -c \u003Ccmd>       Command to validate\n  --check-safety            Verify command safety (default: true)\n  --estimate-resources      Estimate resource usage\n  --require-confirmation    Request user confirmation for risky commands\n\nExamples:\n  npx claude-flow hook pre-bash -c \"rm -rf \u002Ftmp\u002Fcache\"\n  npx claude-flow hook pre-bash --command \"docker build .\" --estimate-resources\n```\n\n**Features:**\n- Command safety validation\n- Resource requirement estimation\n- Destructive command confirmation\n- Permission checks\n\n**pre-task** - Auto-spawn agents and prepare for complex tasks\n```bash\nnpx claude-flow hook pre-task [options]\n\nOptions:\n  --description, -d \u003Ctext>  Task description for context\n  --auto-spawn-agents       Automatically spawn required agents (default: true)\n  --load-memory             Load relevant memory from previous sessions\n  --optimize-topology       Select optimal swarm topology\n  --estimate-complexity     Analyze task complexity\n\nExamples:\n  npx claude-flow hook pre-task --description \"Implement user authentication\"\n  npx claude-flow hook pre-task -d \"Continue API dev\" --load-memory\n  npx claude-flow hook pre-task -d \"Refactor codebase\" --optimize-topology\n```\n\n**Features:**\n- Automatic agent spawning based on task analysis\n- Memory loading for context continuity\n- Topology optimization for task structure\n- Complexity estimation and time prediction\n\n**pre-search** - Prepare and optimize search operations\n```bash\nnpx claude-flow hook pre-search --query \u003Cquery>\n\nOptions:\n  --query, -q \u003Ctext>        Search query\n  --check-cache             Check cache first (default: true)\n  --optimize-query          Optimize search pattern\n\nExamples:\n  npx claude-flow hook pre-search -q \"authentication middleware\"\n```\n\n**Features:**\n- Cache checking for faster results\n- Query optimization\n- Search pattern improvement\n\n#### Post-Operation Hooks\n\nHooks that execute AFTER operations to process and learn:\n\n**post-edit** - Auto-format, validate, and update memory\n```bash\nnpx claude-flow hook post-edit [options]\n\nOptions:\n  --file, -f \u003Cpath>         File path that was edited\n  --auto-format             Automatically format code (default: true)\n  --memory-key, -m \u003Ckey>    Store edit context in memory\n  --train-patterns          Train neural patterns from edit\n  --validate-output         Validate edited file\n\nExamples:\n  npx claude-flow hook post-edit --file \"src\u002Fcomponents\u002FButton.jsx\"\n  npx claude-flow hook post-edit -f \"api\u002Fauth.js\" --memory-key \"auth\u002Flogin\"\n  npx claude-flow hook post-edit -f \"utils\u002Fhelpers.ts\" --train-patterns\n```\n\n**Features:**\n- Language-specific auto-formatting (Prettier, Black, gofmt)\n- Memory storage for edit context and decisions\n- Neural pattern training for continuous improvement\n- Output validation with linting\n\n**post-bash** - Log execution and update metrics\n```bash\nnpx claude-flow hook post-bash --command \u003Ccmd>\n\nOptions:\n  --command, -c \u003Ccmd>       Command that was executed\n  --log-output              Log command output (default: true)\n  --update-metrics          Update performance metrics\n  --store-result            Store result in memory\n\nExamples:\n  npx claude-flow hook post-bash -c \"npm test\" --update-metrics\n```\n\n**Features:**\n- Command execution logging\n- Performance metric tracking\n- Result storage for analysis\n- Error pattern detection\n\n**post-task** - Performance analysis and decision storage\n```bash\nnpx claude-flow hook post-task [options]\n\nOptions:\n  --task-id, -t \u003Cid>        Task identifier for tracking\n  --analyze-performance     Generate performance metrics (default: true)\n  --store-decisions         Save task decisions to memory\n  --export-learnings        Export neural pattern learnings\n  --generate-report         Create task completion report\n\nExamples:\n  npx claude-flow hook post-task --task-id \"auth-implementation\"\n  npx claude-flow hook post-task -t \"api-refactor\" --analyze-performance\n  npx claude-flow hook post-task -t \"bug-fix-123\" --store-decisions\n```\n\n**Features:**\n- Execution time and token usage measurement\n- Decision and implementation choice recording\n- Neural learning pattern export\n- Completion report generation\n\n**post-search** - Cache results and improve patterns\n```bash\nnpx claude-flow hook post-search --query \u003Cquery> --results \u003Cpath>\n\nOptions:\n  --query, -q \u003Ctext>        Original search query\n  --results, -r \u003Cpath>      Results file path\n  --cache-results           Cache for future use (default: true)\n  --train-patterns          Improve search patterns\n\nExamples:\n  npx claude-flow hook post-search -q \"auth\" -r \"results.json\" --train-patterns\n```\n\n**Features:**\n- Result caching for faster subsequent searches\n- Search pattern improvement\n- Relevance scoring\n\n#### MCP Integration Hooks\n\nHooks that coordinate with MCP swarm tools:\n\n**mcp-initialized** - Persist swarm configuration\n```bash\nnpx claude-flow hook mcp-initialized --swarm-id \u003Cid>\n\nFeatures:\n- Save swarm topology and configuration\n- Store agent roster in memory\n- Initialize coordination namespace\n```\n\n**agent-spawned** - Update agent roster and memory\n```bash\nnpx claude-flow hook agent-spawned --agent-id \u003Cid> --type \u003Ctype>\n\nFeatures:\n- Register agent in coordination memory\n- Update agent roster\n- Initialize agent-specific memory namespace\n```\n\n**task-orchestrated** - Monitor task progress\n```bash\nnpx claude-flow hook task-orchestrated --task-id \u003Cid>\n\nFeatures:\n- Track task progress through memory\n- Monitor agent assignments\n- Update coordination state\n```\n\n**neural-trained** - Save pattern improvements\n```bash\nnpx claude-flow hook neural-trained --pattern \u003Cname>\n\nFeatures:\n- Export trained neural patterns\n- Update coordination models\n- Share learning across agents\n```\n\n#### Memory Coordination Hooks\n\n**memory-write** - Triggered when agents write to coordination memory\n```bash\nFeatures:\n- Validate memory key format\n- Update cross-agent indexes\n- Trigger dependent hooks\n- Notify subscribed agents\n```\n\n**memory-read** - Triggered when agents read from coordination memory\n```bash\nFeatures:\n- Log access patterns\n- Update popularity metrics\n- Preload related data\n- Track usage statistics\n```\n\n**memory-sync** - Synchronize memory across swarm agents\n```bash\nnpx claude-flow hook memory-sync --namespace \u003Cns>\n\nFeatures:\n- Sync memory state across agents\n- Resolve conflicts\n- Propagate updates\n- Maintain consistency\n```\n\n#### Session Hooks\n\n**session-start** - Initialize new session\n```bash\nnpx claude-flow hook session-start --session-id \u003Cid>\n\nOptions:\n  --session-id, -s \u003Cid>     Session identifier\n  --load-context            Load context from previous session\n  --init-agents             Initialize required agents\n\nFeatures:\n- Create session directory\n- Initialize metrics tracking\n- Load previous context\n- Set up coordination namespace\n```\n\n**session-restore** - Load previous session state\n```bash\nnpx claude-flow hook session-restore --session-id \u003Cid>\n\nOptions:\n  --session-id, -s \u003Cid>     Session to restore\n  --restore-memory          Restore memory state (default: true)\n  --restore-agents          Restore agent configurations\n\nExamples:\n  npx claude-flow hook session-restore --session-id \"swarm-20241019\"\n  npx claude-flow hook session-restore -s \"feature-auth\" --restore-memory\n```\n\n**Features:**\n- Load previous session context\n- Restore memory state and decisions\n- Reconfigure agents to previous state\n- Resume in-progress tasks\n\n**session-end** - Cleanup and persist session state\n```bash\nnpx claude-flow hook session-end [options]\n\nOptions:\n  --session-id, -s \u003Cid>     Session identifier to end\n  --save-state              Save current session state (default: true)\n  --export-metrics          Export session metrics\n  --generate-summary        Create session summary\n  --cleanup-temp            Remove temporary files\n\nExamples:\n  npx claude-flow hook session-end --session-id \"dev-session-2024\"\n  npx claude-flow hook session-end -s \"feature-auth\" --export-metrics --generate-summary\n  npx claude-flow hook session-end -s \"quick-fix\" --cleanup-temp\n```\n\n**Features:**\n- Save current context and progress\n- Export session metrics (duration, commands, tokens, files)\n- Generate work summary with decisions and next steps\n- Cleanup temporary files and optimize storage\n\n**notify** - Custom notifications with swarm status\n```bash\nnpx claude-flow hook notify --message \u003Cmsg>\n\nOptions:\n  --message, -m \u003Ctext>      Notification message\n  --level \u003Clevel>           Notification level (info|warning|error)\n  --swarm-status            Include swarm status (default: true)\n  --broadcast               Send to all agents\n\nExamples:\n  npx claude-flow hook notify -m \"Task completed\" --level info\n  npx claude-flow hook notify -m \"Critical error\" --level error --broadcast\n```\n\n**Features:**\n- Send notifications to coordination system\n- Include swarm status and metrics\n- Broadcast to all agents\n- Log important events\n\n### Configuration\n\n#### Basic Configuration\n\nEdit `.claude\u002Fsettings.json` to configure hooks:\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"^(Write|Edit|MultiEdit)$\",\n        \"hooks\": [{\n          \"type\": \"command\",\n          \"command\": \"npx claude-flow hook pre-edit --file '${tool.params.file_path}' --memory-key 'swarm\u002Feditor\u002Fcurrent'\"\n        }]\n      },\n      {\n        \"matcher\": \"^Bash$\",\n        \"hooks\": [{\n          \"type\": \"command\",\n          \"command\": \"npx claude-flow hook pre-bash --command '${tool.params.command}'\"\n        }]\n      }\n    ],\n    \"PostToolUse\": [\n      {\n        \"matcher\": \"^(Write|Edit|MultiEdit)$\",\n        \"hooks\": [{\n          \"type\": \"command\",\n          \"command\": \"npx claude-flow hook post-edit --file '${tool.params.file_path}' --memory-key 'swarm\u002Feditor\u002Fcomplete' --auto-format --train-patterns\"\n        }]\n      },\n      {\n        \"matcher\": \"^Bash$\",\n        \"hooks\": [{\n          \"type\": \"command\",\n          \"command\": \"npx claude-flow hook post-bash --command '${tool.params.command}' --update-metrics\"\n        }]\n      }\n    ]\n  }\n}\n```\n\n#### Advanced Configuration\n\nComplete hook configuration with all features:\n\n```json\n{\n  \"hooks\": {\n    \"enabled\": true,\n    \"debug\": false,\n    \"timeout\": 5000,\n\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"^(Write|Edit|MultiEdit)$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook pre-edit --file '${tool.params.file_path}' --auto-assign-agent --validate-syntax\",\n            \"timeout\": 3000,\n            \"continueOnError\": true\n          }\n        ]\n      },\n      {\n        \"matcher\": \"^Task$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook pre-task --description '${tool.params.task}' --auto-spawn-agents --load-memory\",\n            \"async\": true\n          }\n        ]\n      },\n      {\n        \"matcher\": \"^Grep$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook pre-search --query '${tool.params.pattern}' --check-cache\"\n          }\n        ]\n      }\n    ],\n\n    \"PostToolUse\": [\n      {\n        \"matcher\": \"^(Write|Edit|MultiEdit)$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook post-edit --file '${tool.params.file_path}' --memory-key 'edits\u002F${tool.params.file_path}' --auto-format --train-patterns\",\n            \"async\": true\n          }\n        ]\n      },\n      {\n        \"matcher\": \"^Task$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook post-task --task-id '${result.task_id}' --analyze-performance --store-decisions --export-learnings\",\n            \"async\": true\n          }\n        ]\n      },\n      {\n        \"matcher\": \"^Grep$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook post-search --query '${tool.params.pattern}' --cache-results --train-patterns\"\n          }\n        ]\n      }\n    ],\n\n    \"SessionStart\": [\n      {\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook session-start --session-id '${session.id}' --load-context\"\n          }\n        ]\n      }\n    ],\n\n    \"SessionEnd\": [\n      {\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook session-end --session-id '${session.id}' --export-metrics --generate-summary --cleanup-temp\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n#### Protected File Patterns\n\nAdd protection for sensitive files:\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"^(Write|Edit|MultiEdit)$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook check-protected --file '${tool.params.file_path}'\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n#### Automatic Testing\n\nRun tests after file modifications:\n\n```json\n{\n  \"hooks\": {\n    \"PostToolUse\": [\n      {\n        \"matcher\": \"^Write$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"test -f '${tool.params.file_path%.js}.test.js' && npm test '${tool.params.file_path%.js}.test.js'\",\n            \"continueOnError\": true\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n### MCP Tool Integration\n\nHooks automatically integrate with MCP tools for coordination:\n\n#### Pre-Task Hook with Agent Spawning\n\n```javascript\n\u002F\u002F Hook command\nnpx claude-flow hook pre-task --description \"Build REST API\"\n\n\u002F\u002F Internally calls MCP tools:\nmcp__claude-flow__agent_spawn {\n  type: \"backend-dev\",\n  capabilities: [\"api\", \"database\", \"testing\"]\n}\n\nmcp__claude-flow__memory_usage {\n  action: \"store\",\n  key: \"swarm\u002Ftask\u002Fapi-build\u002Fcontext\",\n  namespace: \"coordination\",\n  value: JSON.stringify({\n    description: \"Build REST API\",\n    agents: [\"backend-dev\"],\n    started: Date.now()\n  })\n}\n```\n\n#### Post-Edit Hook with Memory Storage\n\n```javascript\n\u002F\u002F Hook command\nnpx claude-flow hook post-edit --file \"api\u002Fauth.js\"\n\n\u002F\u002F Internally calls MCP tools:\nmcp__claude-flow__memory_usage {\n  action: \"store\",\n  key: \"swarm\u002Fedits\u002Fapi\u002Fauth.js\",\n  namespace: \"coordination\",\n  value: JSON.stringify({\n    file: \"api\u002Fauth.js\",\n    timestamp: Date.now(),\n    changes: { added: 45, removed: 12 },\n    formatted: true,\n    linted: true\n  })\n}\n\nmcp__claude-flow__neural_train {\n  pattern_type: \"coordination\",\n  training_data: { \u002F* edit patterns *\u002F }\n}\n```\n\n#### Session End Hook with State Persistence\n\n```javascript\n\u002F\u002F Hook command\nnpx claude-flow hook session-end --session-id \"dev-2024\"\n\n\u002F\u002F Internally calls MCP tools:\nmcp__claude-flow__memory_persist {\n  sessionId: \"dev-2024\"\n}\n\nmcp__claude-flow__swarm_status {\n  swarmId: \"current\"\n}\n\n\u002F\u002F Generates metrics and summary\n```\n\n### Memory Coordination Protocol\n\nAll hooks follow a standardized memory coordination pattern:\n\n#### Three-Phase Memory Protocol\n\n**Phase 1: STATUS** - Hook starts\n```javascript\nmcp__claude-flow__memory_usage {\n  action: \"store\",\n  key: \"swarm\u002Fhooks\u002Fpre-edit\u002Fstatus\",\n  namespace: \"coordination\",\n  value: JSON.stringify({\n    status: \"running\",\n    hook: \"pre-edit\",\n    file: \"src\u002Fauth.js\",\n    timestamp: Date.now()\n  })\n}\n```\n\n**Phase 2: PROGRESS** - Hook processes\n```javascript\nmcp__claude-flow__memory_usage {\n  action: \"store\",\n  key: \"swarm\u002Fhooks\u002Fpre-edit\u002Fprogress\",\n  namespace: \"coordination\",\n  value: JSON.stringify({\n    progress: 50,\n    action: \"validating syntax\",\n    file: \"src\u002Fauth.js\"\n  })\n}\n```\n\n**Phase 3: COMPLETE** - Hook finishes\n```javascript\nmcp__claude-flow__memory_usage {\n  action: \"store\",\n  key: \"swarm\u002Fhooks\u002Fpre-edit\u002Fcomplete\",\n  namespace: \"coordination\",\n  value: JSON.stringify({\n    status: \"complete\",\n    result: \"success\",\n    agent_assigned: \"backend-dev\",\n    syntax_valid: true,\n    backup_created: true\n  })\n}\n```\n\n### Hook Response Format\n\nHooks return JSON responses to control operation flow:\n\n#### Continue Response\n```json\n{\n  \"continue\": true,\n  \"reason\": \"All validations passed\",\n  \"metadata\": {\n    \"agent_assigned\": \"backend-dev\",\n    \"syntax_valid\": true,\n    \"file\": \"src\u002Fauth.js\"\n  }\n}\n```\n\n#### Block Response\n```json\n{\n  \"continue\": false,\n  \"reason\": \"Protected file - manual review required\",\n  \"metadata\": {\n    \"file\": \".env.production\",\n    \"protection_level\": \"high\",\n    \"requires\": \"manual_approval\"\n  }\n}\n```\n\n#### Warning Response\n```json\n{\n  \"continue\": true,\n  \"reason\": \"Syntax valid but complexity high\",\n  \"warnings\": [\n    \"Cyclomatic complexity: 15 (threshold: 10)\",\n    \"Consider refactoring for better maintainability\"\n  ],\n  \"metadata\": {\n    \"complexity\": 15,\n    \"threshold\": 10\n  }\n}\n```\n\n### Git Integration\n\nHooks can integrate with Git operations for quality control:\n\n#### Pre-Commit Hook\n```bash\n# Add to .git\u002Fhooks\u002Fpre-commit or use husky\n\n#!\u002Fbin\u002Fbash\n# Run quality checks before commit\n\n# Get staged files\nFILES=$(git diff --cached --name-only --diff-filter=ACM)\n\nfor FILE in $FILES; do\n  # Run pre-edit hook for validation\n  npx claude-flow hook pre-edit --file \"$FILE\" --validate-syntax\n\n  if [ $? -ne 0 ]; then\n    echo \"Validation failed for $FILE\"\n    exit 1\n  fi\n\n  # Run post-edit hook for formatting\n  npx claude-flow hook post-edit --file \"$FILE\" --auto-format\ndone\n\n# Run tests\nnpm test\n\nexit $?\n```\n\n#### Post-Commit Hook\n```bash\n# Add to .git\u002Fhooks\u002Fpost-commit\n\n#!\u002Fbin\u002Fbash\n# Track commit metrics\n\nCOMMIT_HASH=$(git rev-parse HEAD)\nCOMMIT_MSG=$(git log -1 --pretty=%B)\n\nnpx claude-flow hook notify \\\n  --message \"Commit completed: $COMMIT_MSG\" \\\n  --level info \\\n  --swarm-status\n```\n\n#### Pre-Push Hook\n```bash\n# Add to .git\u002Fhooks\u002Fpre-push\n\n#!\u002Fbin\u002Fbash\n# Quality gate before push\n\n# Run full test suite\nnpm run test:all\n\n# Run quality checks\nnpx claude-flow hook session-end \\\n  --generate-report \\\n  --export-metrics\n\n# Verify quality thresholds\nTRUTH_SCORE=$(npx claude-flow metrics score --format json | jq -r '.truth_score')\n\nif (( $(echo \"$TRUTH_SCORE \u003C 0.95\" | bc -l) )); then\n  echo \"Truth score below threshold: $TRUTH_SCORE \u003C 0.95\"\n  exit 1\nfi\n\nexit 0\n```\n\n### Agent Coordination Workflow\n\nHow agents use hooks for coordination:\n\n#### Agent Workflow Example\n\n```bash\n# Agent 1: Backend Developer\n# STEP 1: Pre-task preparation\nnpx claude-flow hook pre-task \\\n  --description \"Implement user authentication API\" \\\n  --auto-spawn-agents \\\n  --load-memory\n\n# STEP 2: Work begins - pre-edit validation\nnpx claude-flow hook pre-edit \\\n  --file \"api\u002Fauth.js\" \\\n  --auto-assign-agent \\\n  --validate-syntax\n\n# STEP 3: Edit file (via Claude Code Edit tool)\n# ... code changes ...\n\n# STEP 4: Post-edit processing\nnpx claude-flow hook post-edit \\\n  --file \"api\u002Fauth.js\" \\\n  --memory-key \"swarm\u002Fbackend\u002Fauth-api\" \\\n  --auto-format \\\n  --train-patterns\n\n# STEP 5: Notify coordination system\nnpx claude-flow hook notify \\\n  --message \"Auth API implementation complete\" \\\n  --swarm-status \\\n  --broadcast\n\n# STEP 6: Task completion\nnpx claude-flow hook post-task \\\n  --task-id \"auth-api\" \\\n  --analyze-performance \\\n  --store-decisions \\\n  --export-learnings\n```\n\n```bash\n# Agent 2: Test Engineer (receives notification)\n# STEP 1: Check memory for API details\nnpx claude-flow hook session-restore \\\n  --session-id \"swarm-current\" \\\n  --restore-memory\n\n# Memory contains: swarm\u002Fbackend\u002Fauth-api with implementation details\n\n# STEP 2: Generate tests\nnpx claude-flow hook pre-task \\\n  --description \"Write tests for auth API\" \\\n  --load-memory\n\n# STEP 3: Create test file\nnpx claude-flow hook post-edit \\\n  --file \"api\u002Fauth.test.js\" \\\n  --memory-key \"swarm\u002Ftesting\u002Fauth-api-tests\" \\\n  --train-patterns\n\n# STEP 4: Share test results\nnpx claude-flow hook notify \\\n  --message \"Auth API tests complete - 100% coverage\" \\\n  --broadcast\n```\n\n### Custom Hook Creation\n\nCreate custom hooks for specific workflows:\n\n#### Custom Hook Template\n\n```javascript\n\u002F\u002F .claude\u002Fhooks\u002Fcustom-quality-check.js\n\nmodule.exports = {\n  name: 'custom-quality-check',\n  type: 'pre',\n  matcher: \u002F\\.(ts|js)$\u002F,\n\n  async execute(context) {\n    const { file, content } = context;\n\n    \u002F\u002F Custom validation logic\n    const complexity = await analyzeComplexity(content);\n    const securityIssues = await scanSecurity(content);\n\n    \u002F\u002F Store in memory\n    await storeInMemory({\n      key: `quality\u002F${file}`,\n      value: { complexity, securityIssues }\n    });\n\n    \u002F\u002F Return decision\n    if (complexity > 15 || securityIssues.length > 0) {\n      return {\n        continue: false,\n        reason: 'Quality checks failed',\n        warnings: [\n          `Complexity: ${complexity} (max: 15)`,\n          `Security issues: ${securityIssues.length}`\n        ]\n      };\n    }\n\n    return {\n      continue: true,\n      reason: 'Quality checks passed',\n      metadata: { complexity, securityIssues: 0 }\n    };\n  }\n};\n```\n\n#### Register Custom Hook\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"^(Write|Edit)$\",\n        \"hooks\": [\n          {\n            \"type\": \"script\",\n            \"script\": \".claude\u002Fhooks\u002Fcustom-quality-check.js\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n### Real-World Examples\n\n#### Example 1: Full-Stack Development Workflow\n\n```bash\n# Session start - initialize coordination\nnpx claude-flow hook session-start --session-id \"fullstack-feature\"\n\n# Pre-task planning\nnpx claude-flow hook pre-task \\\n  --description \"Build user profile feature - frontend + backend + tests\" \\\n  --auto-spawn-agents \\\n  --optimize-topology\n\n# Backend work\nnpx claude-flow hook pre-edit --file \"api\u002Fprofile.js\"\n# ... implement backend ...\nnpx claude-flow hook post-edit \\\n  --file \"api\u002Fprofile.js\" \\\n  --memory-key \"profile\u002Fbackend\" \\\n  --train-patterns\n\n# Frontend work (reads backend details from memory)\nnpx claude-flow hook pre-edit --file \"components\u002FProfile.jsx\"\n# ... implement frontend ...\nnpx claude-flow hook post-edit \\\n  --file \"components\u002FProfile.jsx\" \\\n  --memory-key \"profile\u002Ffrontend\" \\\n  --train-patterns\n\n# Testing (reads both backend and frontend from memory)\nnpx claude-flow hook pre-task \\\n  --description \"Test profile feature\" \\\n  --load-memory\n\n# Session end - export everything\nnpx claude-flow hook session-end \\\n  --session-id \"fullstack-feature\" \\\n  --export-metrics \\\n  --generate-summary\n```\n\n#### Example 2: Debugging with Hooks\n\n```bash\n# Start debugging session\nnpx claude-flow hook session-start --session-id \"debug-memory-leak\"\n\n# Pre-task: analyze issue\nnpx claude-flow hook pre-task \\\n  --description \"Debug memory leak in event handlers\" \\\n  --load-memory \\\n  --estimate-complexity\n\n# Search for event emitters\nnpx claude-flow hook pre-search --query \"EventEmitter\"\n# ... search executes ...\nnpx claude-flow hook post-search \\\n  --query \"EventEmitter\" \\\n  --cache-results\n\n# Fix the issue\nnpx claude-flow hook pre-edit \\\n  --file \"services\u002Fevents.js\" \\\n  --backup-file\n# ... fix code ...\nnpx claude-flow hook post-edit \\\n  --file \"services\u002Fevents.js\" \\\n  --memory-key \"debug\u002Fmemory-leak-fix\" \\\n  --validate-output\n\n# Verify fix\nnpx claude-flow hook post-task \\\n  --task-id \"memory-leak-fix\" \\\n  --analyze-performance \\\n  --generate-report\n\n# End session\nnpx claude-flow hook session-end \\\n  --session-id \"debug-memory-leak\" \\\n  --export-metrics\n```\n\n#### Example 3: Multi-Agent Refactoring\n\n```bash\n# Initialize swarm for refactoring\nnpx claude-flow hook pre-task \\\n  --description \"Refactor legacy codebase to modern patterns\" \\\n  --auto-spawn-agents \\\n  --optimize-topology\n\n# Agent 1: Code Analyzer\nnpx claude-flow hook pre-task --description \"Analyze code complexity\"\n# ... analysis ...\nnpx claude-flow hook post-task \\\n  --task-id \"analysis\" \\\n  --store-decisions\n\n# Agent 2: Refactoring (reads analysis from memory)\nnpx claude-flow hook session-restore \\\n  --session-id \"swarm-refactor\" \\\n  --restore-memory\n\nfor file in src\u002F**\u002F*.js; do\n  npx claude-flow hook pre-edit --file \"$file\" --backup-file\n  # ... refactor ...\n  npx claude-flow hook post-edit \\\n    --file \"$file\" \\\n    --memory-key \"refactor\u002F$file\" \\\n    --auto-format \\\n    --train-patterns\ndone\n\n# Agent 3: Testing (reads refactored code from memory)\nnpx claude-flow hook pre-task \\\n  --description \"Generate tests for refactored code\" \\\n  --load-memory\n\n# Broadcast completion\nnpx claude-flow hook notify \\\n  --message \"Refactoring complete - all tests passing\" \\\n  --broadcast\n```\n\n### Performance Tips\n\n1. **Keep Hooks Lightweight** - Target \u003C 100ms execution time\n2. **Use Async for Heavy Operations** - Don't block the main flow\n3. **Cache Aggressively** - Store frequently accessed data\n4. **Batch Related Operations** - Combine multiple actions\n5. **Use Memory Wisely** - Set appropriate TTLs\n6. **Monitor Hook Performance** - Track execution times\n7. **Parallelize When Possible** - Run independent hooks concurrently\n\n### Debugging Hooks\n\nEnable debug mode for troubleshooting:\n\n```bash\n# Enable debug output\nexport CLAUDE_FLOW_DEBUG=true\n\n# Test specific hook with verbose output\nnpx claude-flow hook pre-edit --file \"test.js\" --debug\n\n# Check hook execution logs\ncat .claude-flow\u002Flogs\u002Fhooks-$(date +%Y-%m-%d).log\n\n# Validate configuration\nnpx claude-flow hook validate-config\n```\n\n### Benefits\n\n- **Automatic Agent Assignment**: Right agent for every file type\n- **Consistent Code Formatting**: Language-specific formatters\n- **Continuous Learning**: Neural patterns improve over time\n- **Cross-Session Memory**: Context persists between sessions\n- **Performance Tracking**: Comprehensive metrics and analytics\n- **Automatic Coordination**: Agents sync via memory\n- **Smart Agent Spawning**: Task-based agent selection\n- **Quality Gates**: Pre-commit validation and verification\n- **Error Prevention**: Syntax validation before edits\n- **Knowledge Sharing**: Decisions stored and shared\n- **Reduced Manual Work**: Automation of repetitive tasks\n- **Better Collaboration**: Seamless multi-agent coordination\n\n### Best Practices\n\n1. **Configure Hooks Early** - Set up during project initialization\n2. **Use Memory Keys Strategically** - Organize with clear namespaces\n3. **Enable Auto-Formatting** - Maintain code consistency\n4. **Train Patterns Continuously** - Learn from successful operations\n5. **Monitor Performance** - Track hook execution times\n6. **Validate Configuration** - Test hooks before production use\n7. **Document Custom Hooks** - Maintain hook documentation\n8. **Set Appropriate Timeouts** - Prevent hanging operations\n9. **Handle Errors Gracefully** - Use continueOnError when appropriate\n10. **Review Metrics Regularly** - Optimize based on usage patterns\n\n### Troubleshooting\n\n#### Hooks Not Executing\n- Verify `.claude\u002Fsettings.json` syntax\n- Check hook matcher patterns\n- Enable debug mode\n- Review permission settings\n- Ensure claude-flow CLI is in PATH\n\n#### Hook Timeouts\n- Increase timeout values in configuration\n- Make hooks asynchronous for heavy operations\n- Optimize hook logic\n- Check network connectivity for MCP tools\n\n#### Memory Issues\n- Set appropriate TTLs for memory keys\n- Clean up old memory entries\n- Use memory namespaces effectively\n- Monitor memory usage\n\n#### Performance Problems\n- Profile hook execution times\n- Use caching for repeated operations\n- Batch operations when possible\n- Reduce hook complexity\n\n### Related Commands\n\n- `npx claude-flow init --hooks` - Initialize hooks system\n- `npx claude-flow hook --list` - List available hooks\n- `npx claude-flow hook --test \u003Chook>` - Test specific hook\n- `npx claude-flow memory usage` - Manage memory\n- `npx claude-flow agent spawn` - Spawn agents\n- `npx claude-flow swarm init` - Initialize swarm\n\n### Integration with Other Skills\n\nThis skill works seamlessly with:\n- **SPARC Methodology** - Hooks enhance SPARC workflows\n- **Pair Programming** - Automated quality in pairing sessions\n- **Verification Quality** - Truth-score validation in hooks\n- **GitHub Workflows** - Git integration for commits\u002FPRs\n- **Performance Analysis** - Metrics collection in hooks\n- **Swarm Advanced** - Multi-agent coordination via hooks\n","# Hooks Automation\n\nIntelligent automation system that coordinates, validates, and learns from Claude Code operations through hooks integrated with MCP tools and neural pattern training.\n\n## What This Skill Does\n\nThis skill provides a comprehensive hook system that automatically manages development operations, coordinates swarm agents, maintains session state, and continuously learns from coding patterns. It enables automated agent assignment, code formatting, performance tracking, and cross-session memory persistence.\n\n**Key Capabilities:**\n- **Pre-Operation Hooks**: Validate, prepare, and auto-assign agents before operations\n- **Post-Operation Hooks**: Format, analyze, and train patterns after operations\n- **Session Management**: Persist state, restore context, generate summaries\n- **Memory Coordination**: Synchronize knowledge across swarm agents\n- **Git Integration**: Automated commit hooks with quality verification\n- **Neural Training**: Continuous learning from successful patterns\n- **MCP Integration**: Seamless coordination with swarm tools\n\n## Prerequisites\n\n**Required:**\n- Claude Flow CLI installed (`npm install -g claude-flow@alpha`)\n- Claude Code with hooks enabled\n- `.claude\u002Fsettings.json` with hook configurations\n\n**Optional:**\n- MCP servers configured (claude-flow, ruv-swarm, flow-nexus)\n- Git repository for version control\n- Testing framework for quality verification\n\n## Quick Start\n\n### Initialize Hooks System\n\n```bash\n# Initialize with default hooks configuration\nnpx claude-flow init --hooks\n```\n\nThis creates:\n- `.claude\u002Fsettings.json` with pre-configured hooks\n- Hook command documentation in `.claude\u002Fcommands\u002Fhooks\u002F`\n- Default hook handlers for common operations\n\n### Basic Hook Usage\n\n```bash\n# Pre-task hook (auto-spawns agents)\nnpx claude-flow hook pre-task --description \"Implement authentication\"\n\n# Post-edit hook (auto-formats and stores in memory)\nnpx claude-flow hook post-edit --file \"src\u002Fauth.js\" --memory-key \"auth\u002Flogin\"\n\n# Session end hook (saves state and metrics)\nnpx claude-flow hook session-end --session-id \"dev-session\" --export-metrics\n```\n\n---\n\n## Complete Guide\n\n### Available Hooks\n\n#### Pre-Operation Hooks\n\nHooks that execute BEFORE operations to prepare and validate:\n\n**pre-edit** - Validate and assign agents before file modifications\n```bash\nnpx claude-flow hook pre-edit [options]\n\nOptions:\n  --file, -f \u003Cpath>         File path to be edited\n  --auto-assign-agent       Automatically assign best agent (default: true)\n  --validate-syntax         Pre-validate syntax before edit\n  --check-conflicts         Check for merge conflicts\n  --backup-file             Create backup before editing\n\nExamples:\n  npx claude-flow hook pre-edit --file \"src\u002Fauth\u002Flogin.js\"\n  npx claude-flow hook pre-edit -f \"config\u002Fdb.js\" --validate-syntax\n  npx claude-flow hook pre-edit -f \"production.env\" --backup-file --check-conflicts\n```\n\n**Features:**\n- Auto agent assignment based on file type\n- Syntax validation to prevent broken code\n- Conflict detection for concurrent edits\n- Automatic file backups for safety\n\n**pre-bash** - Check command safety and resource requirements\n```bash\nnpx claude-flow hook pre-bash --command \u003Ccmd>\n\nOptions:\n  --command, -c \u003Ccmd>       Command to validate\n  --check-safety            Verify command safety (default: true)\n  --estimate-resources      Estimate resource usage\n  --require-confirmation    Request user confirmation for risky commands\n\nExamples:\n  npx claude-flow hook pre-bash -c \"rm -rf \u002Ftmp\u002Fcache\"\n  npx claude-flow hook pre-bash --command \"docker build .\" --estimate-resources\n```\n\n**Features:**\n- Command safety validation\n- Resource requirement estimation\n- Destructive command confirmation\n- Permission checks\n\n**pre-task** - Auto-spawn agents and prepare for complex tasks\n```bash\nnpx claude-flow hook pre-task [options]\n\nOptions:\n  --description, -d \u003Ctext>  Task description for context\n  --auto-spawn-agents       Automatically spawn required agents (default: true)\n  --load-memory             Load relevant memory from previous sessions\n  --optimize-topology       Select optimal swarm topology\n  --estimate-complexity     Analyze task complexity\n\nExamples:\n  npx claude-flow hook pre-task --description \"Implement user authentication\"\n  npx claude-flow hook pre-task -d \"Continue API dev\" --load-memory\n  npx claude-flow hook pre-task -d \"Refactor codebase\" --optimize-topology\n```\n\n**Features:**\n- Automatic agent spawning based on task analysis\n- Memory loading for context continuity\n- Topology optimization for task structure\n- Complexity estimation and time prediction\n\n**pre-search** - Prepare and optimize search operations\n```bash\nnpx claude-flow hook pre-search --query \u003Cquery>\n\nOptions:\n  --query, -q \u003Ctext>        Search query\n  --check-cache             Check cache first (default: true)\n  --optimize-query          Optimize search pattern\n\nExamples:\n  npx claude-flow hook pre-search -q \"authentication middleware\"\n```\n\n**Features:**\n- Cache checking for faster results\n- Query optimization\n- Search pattern improvement\n\n#### Post-Operation Hooks\n\nHooks that execute AFTER operations to process and learn:\n\n**post-edit** - Auto-format, validate, and update memory\n```bash\nnpx claude-flow hook post-edit [options]\n\nOptions:\n  --file, -f \u003Cpath>         File path that was edited\n  --auto-format             Automatically format code (default: true)\n  --memory-key, -m \u003Ckey>    Store edit context in memory\n  --train-patterns          Train neural patterns from edit\n  --validate-output         Validate edited file\n\nExamples:\n  npx claude-flow hook post-edit --file \"src\u002Fcomponents\u002FButton.jsx\"\n  npx claude-flow hook post-edit -f \"api\u002Fauth.js\" --memory-key \"auth\u002Flogin\"\n  npx claude-flow hook post-edit -f \"utils\u002Fhelpers.ts\" --train-patterns\n```\n\n**Features:**\n- Language-specific auto-formatting (Prettier, Black, gofmt)\n- Memory storage for edit context and decisions\n- Neural pattern training for continuous improvement\n- Output validation with linting\n\n**post-bash** - Log execution and update metrics\n```bash\nnpx claude-flow hook post-bash --command \u003Ccmd>\n\nOptions:\n  --command, -c \u003Ccmd>       Command that was executed\n  --log-output              Log command output (default: true)\n  --update-metrics          Update performance metrics\n  --store-result            Store result in memory\n\nExamples:\n  npx claude-flow hook post-bash -c \"npm test\" --update-metrics\n```\n\n**Features:**\n- Command execution logging\n- Performance metric tracking\n- Result storage for analysis\n- Error pattern detection\n\n**post-task** - Performance analysis and decision storage\n```bash\nnpx claude-flow hook post-task [options]\n\nOptions:\n  --task-id, -t \u003Cid>        Task identifier for tracking\n  --analyze-performance     Generate performance metrics (default: true)\n  --store-decisions         Save task decisions to memory\n  --export-learnings        Export neural pattern learnings\n  --generate-report         Create task completion report\n\nExamples:\n  npx claude-flow hook post-task --task-id \"auth-implementation\"\n  npx claude-flow hook post-task -t \"api-refactor\" --analyze-performance\n  npx claude-flow hook post-task -t \"bug-fix-123\" --store-decisions\n```\n\n**Features:**\n- Execution time and token usage measurement\n- Decision and implementation choice recording\n- Neural learning pattern export\n- Completion report generation\n\n**post-search** - Cache results and improve patterns\n```bash\nnpx claude-flow hook post-search --query \u003Cquery> --results \u003Cpath>\n\nOptions:\n  --query, -q \u003Ctext>        Original search query\n  --results, -r \u003Cpath>      Results file path\n  --cache-results           Cache for future use (default: true)\n  --train-patterns          Improve search patterns\n\nExamples:\n  npx claude-flow hook post-search -q \"auth\" -r \"results.json\" --train-patterns\n```\n\n**Features:**\n- Result caching for faster subsequent searches\n- Search pattern improvement\n- Relevance scoring\n\n#### MCP Integration Hooks\n\nHooks that coordinate with MCP swarm tools:\n\n**mcp-initialized** - Persist swarm configuration\n```bash\nnpx claude-flow hook mcp-initialized --swarm-id \u003Cid>\n\nFeatures:\n- Save swarm topology and configuration\n- Store agent roster in memory\n- Initialize coordination namespace\n```\n\n**agent-spawned** - Update agent roster and memory\n```bash\nnpx claude-flow hook agent-spawned --agent-id \u003Cid> --type \u003Ctype>\n\nFeatures:\n- Register agent in coordination memory\n- Update agent roster\n- Initialize agent-specific memory namespace\n```\n\n**task-orchestrated** - Monitor task progress\n```bash\nnpx claude-flow hook task-orchestrated --task-id \u003Cid>\n\nFeatures:\n- Track task progress through memory\n- Monitor agent assignments\n- Update coordination state\n```\n\n**neural-trained** - Save pattern improvements\n```bash\nnpx claude-flow hook neural-trained --pattern \u003Cname>\n\nFeatures:\n- Export trained neural patterns\n- Update coordination models\n- Share learning across agents\n```\n\n#### Memory Coordination Hooks\n\n**memory-write** - Triggered when agents write to coordination memory\n```bash\nFeatures:\n- Validate memory key format\n- Update cross-agent indexes\n- Trigger dependent hooks\n- Notify subscribed agents\n```\n\n**memory-read** - Triggered when agents read from coordination memory\n```bash\nFeatures:\n- Log access patterns\n- Update popularity metrics\n- Preload related data\n- Track usage statistics\n```\n\n**memory-sync** - Synchronize memory across swarm agents\n```bash\nnpx claude-flow hook memory-sync --namespace \u003Cns>\n\nFeatures:\n- Sync memory state across agents\n- Resolve conflicts\n- Propagate updates\n- Maintain consistency\n```\n\n#### Session Hooks\n\n**session-start** - Initialize new session\n```bash\nnpx claude-flow hook session-start --session-id \u003Cid>\n\nOptions:\n  --session-id, -s \u003Cid>     Session identifier\n  --load-context            Load context from previous session\n  --init-agents             Initialize required agents\n\nFeatures:\n- Create session directory\n- Initialize metrics tracking\n- Load previous context\n- Set up coordination namespace\n```\n\n**session-restore** - Load previous session state\n```bash\nnpx claude-flow hook session-restore --session-id \u003Cid>\n\nOptions:\n  --session-id, -s \u003Cid>     Session to restore\n  --restore-memory          Restore memory state (default: true)\n  --restore-agents          Restore agent configurations\n\nExamples:\n  npx claude-flow hook session-restore --session-id \"swarm-20241019\"\n  npx claude-flow hook session-restore -s \"feature-auth\" --restore-memory\n```\n\n**Features:**\n- Load previous session context\n- Restore memory state and decisions\n- Reconfigure agents to previous state\n- Resume in-progress tasks\n\n**session-end** - Cleanup and persist session state\n```bash\nnpx claude-flow hook session-end [options]\n\nOptions:\n  --session-id, -s \u003Cid>     Session identifier to end\n  --save-state              Save current session state (default: true)\n  --export-metrics          Export session metrics\n  --generate-summary        Create session summary\n  --cleanup-temp            Remove temporary files\n\nExamples:\n  npx claude-flow hook session-end --session-id \"dev-session-2024\"\n  npx claude-flow hook session-end -s \"feature-auth\" --export-metrics --generate-summary\n  npx claude-flow hook session-end -s \"quick-fix\" --cleanup-temp\n```\n\n**Features:**\n- Save current context and progress\n- Export session metrics (duration, commands, tokens, files)\n- Generate work summary with decisions and next steps\n- Cleanup temporary files and optimize storage\n\n**notify** - Custom notifications with swarm status\n```bash\nnpx claude-flow hook notify --message \u003Cmsg>\n\nOptions:\n  --message, -m \u003Ctext>      Notification message\n  --level \u003Clevel>           Notification level (info|warning|error)\n  --swarm-status            Include swarm status (default: true)\n  --broadcast               Send to all agents\n\nExamples:\n  npx claude-flow hook notify -m \"Task completed\" --level info\n  npx claude-flow hook notify -m \"Critical error\" --level error --broadcast\n```\n\n**Features:**\n- Send notifications to coordination system\n- Include swarm status and metrics\n- Broadcast to all agents\n- Log important events\n\n### Configuration\n\n#### Basic Configuration\n\nEdit `.claude\u002Fsettings.json` to configure hooks:\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"^(Write|Edit|MultiEdit)$\",\n        \"hooks\": [{\n          \"type\": \"command\",\n          \"command\": \"npx claude-flow hook pre-edit --file '${tool.params.file_path}' --memory-key 'swarm\u002Feditor\u002Fcurrent'\"\n        }]\n      },\n      {\n        \"matcher\": \"^Bash$\",\n        \"hooks\": [{\n          \"type\": \"command\",\n          \"command\": \"npx claude-flow hook pre-bash --command '${tool.params.command}'\"\n        }]\n      }\n    ],\n    \"PostToolUse\": [\n      {\n        \"matcher\": \"^(Write|Edit|MultiEdit)$\",\n        \"hooks\": [{\n          \"type\": \"command\",\n          \"command\": \"npx claude-flow hook post-edit --file '${tool.params.file_path}' --memory-key 'swarm\u002Feditor\u002Fcomplete' --auto-format --train-patterns\"\n        }]\n      },\n      {\n        \"matcher\": \"^Bash$\",\n        \"hooks\": [{\n          \"type\": \"command\",\n          \"command\": \"npx claude-flow hook post-bash --command '${tool.params.command}' --update-metrics\"\n        }]\n      }\n    ]\n  }\n}\n```\n\n#### Advanced Configuration\n\nComplete hook configuration with all features:\n\n```json\n{\n  \"hooks\": {\n    \"enabled\": true,\n    \"debug\": false,\n    \"timeout\": 5000,\n\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"^(Write|Edit|MultiEdit)$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook pre-edit --file '${tool.params.file_path}' --auto-assign-agent --validate-syntax\",\n            \"timeout\": 3000,\n            \"continueOnError\": true\n          }\n        ]\n      },\n      {\n        \"matcher\": \"^Task$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook pre-task --description '${tool.params.task}' --auto-spawn-agents --load-memory\",\n            \"async\": true\n          }\n        ]\n      },\n      {\n        \"matcher\": \"^Grep$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook pre-search --query '${tool.params.pattern}' --check-cache\"\n          }\n        ]\n      }\n    ],\n\n    \"PostToolUse\": [\n      {\n        \"matcher\": \"^(Write|Edit|MultiEdit)$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook post-edit --file '${tool.params.file_path}' --memory-key 'edits\u002F${tool.params.file_path}' --auto-format --train-patterns\",\n            \"async\": true\n          }\n        ]\n      },\n      {\n        \"matcher\": \"^Task$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook post-task --task-id '${result.task_id}' --analyze-performance --store-decisions --export-learnings\",\n            \"async\": true\n          }\n        ]\n      },\n      {\n        \"matcher\": \"^Grep$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook post-search --query '${tool.params.pattern}' --cache-results --train-patterns\"\n          }\n        ]\n      }\n    ],\n\n    \"SessionStart\": [\n      {\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook session-start --session-id '${session.id}' --load-context\"\n          }\n        ]\n      }\n    ],\n\n    \"SessionEnd\": [\n      {\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook session-end --session-id '${session.id}' --export-metrics --generate-summary --cleanup-temp\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n#### Protected File Patterns\n\nAdd protection for sensitive files:\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"^(Write|Edit|MultiEdit)$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"npx claude-flow hook check-protected --file '${tool.params.file_path}'\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n#### Automatic Testing\n\nRun tests after file modifications:\n\n```json\n{\n  \"hooks\": {\n    \"PostToolUse\": [\n      {\n        \"matcher\": \"^Write$\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"test -f '${tool.params.file_path%.js}.test.js' && npm test '${tool.params.file_path%.js}.test.js'\",\n            \"continueOnError\": true\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n### MCP Tool Integration\n\nHooks automatically integrate with MCP tools for coordination:\n\n#### Pre-Task Hook with Agent Spawning\n\n```javascript\n\u002F\u002F Hook command\nnpx claude-flow hook pre-task --description \"Build REST API\"\n\n\u002F\u002F Internally calls MCP tools:\nmcp__claude-flow__agent_spawn {\n  type: \"backend-dev\",\n  capabilities: [\"api\", \"database\", \"testing\"]\n}\n\nmcp__claude-flow__memory_usage {\n  action: \"store\",\n  key: \"swarm\u002Ftask\u002Fapi-build\u002Fcontext\",\n  namespace: \"coordination\",\n  value: JSON.stringify({\n    description: \"Build REST API\",\n    agents: [\"backend-dev\"],\n    started: Date.now()\n  })\n}\n```\n\n#### Post-Edit Hook with Memory Storage\n\n```javascript\n\u002F\u002F Hook command\nnpx claude-flow hook post-edit --file \"api\u002Fauth.js\"\n\n\u002F\u002F Internally calls MCP tools:\nmcp__claude-flow__memory_usage {\n  action: \"store\",\n  key: \"swarm\u002Fedits\u002Fapi\u002Fauth.js\",\n  namespace: \"coordination\",\n  value: JSON.stringify({\n    file: \"api\u002Fauth.js\",\n    timestamp: Date.now(),\n    changes: { added: 45, removed: 12 },\n    formatted: true,\n    linted: true\n  })\n}\n\nmcp__claude-flow__neural_train {\n  pattern_type: \"coordination\",\n  training_data: { \u002F* edit patterns *\u002F }\n}\n```\n\n#### Session End Hook with State Persistence\n\n```javascript\n\u002F\u002F Hook command\nnpx claude-flow hook session-end --session-id \"dev-2024\"\n\n\u002F\u002F Internally calls MCP tools:\nmcp__claude-flow__memory_persist {\n  sessionId: \"dev-2024\"\n}\n\nmcp__claude-flow__swarm_status {\n  swarmId: \"current\"\n}\n\n\u002F\u002F Generates metrics and summary\n```\n\n### Memory Coordination Protocol\n\nAll hooks follow a standardized memory coordination pattern:\n\n#### Three-Phase Memory Protocol\n\n**Phase 1: STATUS** - Hook starts\n```javascript\nmcp__claude-flow__memory_usage {\n  action: \"store\",\n  key: \"swarm\u002Fhooks\u002Fpre-edit\u002Fstatus\",\n  namespace: \"coordination\",\n  value: JSON.stringify({\n    status: \"running\",\n    hook: \"pre-edit\",\n    file: \"src\u002Fauth.js\",\n    timestamp: Date.now()\n  })\n}\n```\n\n**Phase 2: PROGRESS** - Hook processes\n```javascript\nmcp__claude-flow__memory_usage {\n  action: \"store\",\n  key: \"swarm\u002Fhooks\u002Fpre-edit\u002Fprogress\",\n  namespace: \"coordination\",\n  value: JSON.stringify({\n    progress: 50,\n    action: \"validating syntax\",\n    file: \"src\u002Fauth.js\"\n  })\n}\n```\n\n**Phase 3: COMPLETE** - Hook finishes\n```javascript\nmcp__claude-flow__memory_usage {\n  action: \"store\",\n  key: \"swarm\u002Fhooks\u002Fpre-edit\u002Fcomplete\",\n  namespace: \"coordination\",\n  value: JSON.stringify({\n    status: \"complete\",\n    result: \"success\",\n    agent_assigned: \"backend-dev\",\n    syntax_valid: true,\n    backup_created: true\n  })\n}\n```\n\n### Hook Response Format\n\nHooks return JSON responses to control operation flow:\n\n#### Continue Response\n```json\n{\n  \"continue\": true,\n  \"reason\": \"All validations passed\",\n  \"metadata\": {\n    \"agent_assigned\": \"backend-dev\",\n    \"syntax_valid\": true,\n    \"file\": \"src\u002Fauth.js\"\n  }\n}\n```\n\n#### Block Response\n```json\n{\n  \"continue\": false,\n  \"reason\": \"Protected file - manual review required\",\n  \"metadata\": {\n    \"file\": \".env.production\",\n    \"protection_level\": \"high\",\n    \"requires\": \"manual_approval\"\n  }\n}\n```\n\n#### Warning Response\n```json\n{\n  \"continue\": true,\n  \"reason\": \"Syntax valid but complexity high\",\n  \"warnings\": [\n    \"Cyclomatic complexity: 15 (threshold: 10)\",\n    \"Consider refactoring for better maintainability\"\n  ],\n  \"metadata\": {\n    \"complexity\": 15,\n    \"threshold\": 10\n  }\n}\n```\n\n### Git Integration\n\nHooks can integrate with Git operations for quality control:\n\n#### Pre-Commit Hook\n```bash\n# Add to .git\u002Fhooks\u002Fpre-commit or use husky\n\n#!\u002Fbin\u002Fbash\n# Run quality checks before commit\n\n# Get staged files\nFILES=$(git diff --cached --name-only --diff-filter=ACM)\n\nfor FILE in $FILES; do\n  # Run pre-edit hook for validation\n  npx claude-flow hook pre-edit --file \"$FILE\" --validate-syntax\n\n  if [ $? -ne 0 ]; then\n    echo \"Validation failed for $FILE\"\n    exit 1\n  fi\n\n  # Run post-edit hook for formatting\n  npx claude-flow hook post-edit --file \"$FILE\" --auto-format\ndone\n\n# Run tests\nnpm test\n\nexit $?\n```\n\n#### Post-Commit Hook\n```bash\n# Add to .git\u002Fhooks\u002Fpost-commit\n\n#!\u002Fbin\u002Fbash\n# Track commit metrics\n\nCOMMIT_HASH=$(git rev-parse HEAD)\nCOMMIT_MSG=$(git log -1 --pretty=%B)\n\nnpx claude-flow hook notify \\\n  --message \"Commit completed: $COMMIT_MSG\" \\\n  --level info \\\n  --swarm-status\n```\n\n#### Pre-Push Hook\n```bash\n# Add to .git\u002Fhooks\u002Fpre-push\n\n#!\u002Fbin\u002Fbash\n# Quality gate before push\n\n# Run full test suite\nnpm run test:all\n\n# Run quality checks\nnpx claude-flow hook session-end \\\n  --generate-report \\\n  --export-metrics\n\n# Verify quality thresholds\nTRUTH_SCORE=$(npx claude-flow metrics score --format json | jq -r '.truth_score')\n\nif (( $(echo \"$TRUTH_SCORE \u003C 0.95\" | bc -l) )); then\n  echo \"Truth score below threshold: $TRUTH_SCORE \u003C 0.95\"\n  exit 1\nfi\n\nexit 0\n```\n\n### Agent Coordination Workflow\n\nHow agents use hooks for coordination:\n\n#### Agent Workflow Example\n\n```bash\n# Agent 1: Backend Developer\n# STEP 1: Pre-task preparation\nnpx claude-flow hook pre-task \\\n  --description \"Implement user authentication API\" \\\n  --auto-spawn-agents \\\n  --load-memory\n\n# STEP 2: Work begins - pre-edit validation\nnpx claude-flow hook pre-edit \\\n  --file \"api\u002Fauth.js\" \\\n  --auto-assign-agent \\\n  --validate-syntax\n\n# STEP 3: Edit file (via Claude Code Edit tool)\n# ... code changes ...\n\n# STEP 4: Post-edit processing\nnpx claude-flow hook post-edit \\\n  --file \"api\u002Fauth.js\" \\\n  --memory-key \"swarm\u002Fbackend\u002Fauth-api\" \\\n  --auto-format \\\n  --train-patterns\n\n# STEP 5: Notify coordination system\nnpx claude-flow hook notify \\\n  --message \"Auth API implementation complete\" \\\n  --swarm-status \\\n  --broadcast\n\n# STEP 6: Task completion\nnpx claude-flow hook post-task \\\n  --task-id \"auth-api\" \\\n  --analyze-performance \\\n  --store-decisions \\\n  --export-learnings\n```\n\n```bash\n# Agent 2: Test Engineer (receives notification)\n# STEP 1: Check memory for API details\nnpx claude-flow hook session-restore \\\n  --session-id \"swarm-current\" \\\n  --restore-memory\n\n# Memory contains: swarm\u002Fbackend\u002Fauth-api with implementation details\n\n# STEP 2: Generate tests\nnpx claude-flow hook pre-task \\\n  --description \"Write tests for auth API\" \\\n  --load-memory\n\n# STEP 3: Create test file\nnpx claude-flow hook post-edit \\\n  --file \"api\u002Fauth.test.js\" \\\n  --memory-key \"swarm\u002Ftesting\u002Fauth-api-tests\" \\\n  --train-patterns\n\n# STEP 4: Share test results\nnpx claude-flow hook notify \\\n  --message \"Auth API tests complete - 100% coverage\" \\\n  --broadcast\n```\n\n### Custom Hook Creation\n\nCreate custom hooks for specific workflows:\n\n#### Custom Hook Template\n\n```javascript\n\u002F\u002F .claude\u002Fhooks\u002Fcustom-quality-check.js\n\nmodule.exports = {\n  name: 'custom-quality-check',\n  type: 'pre',\n  matcher: \u002F\\.(ts|js)$\u002F,\n\n  async execute(context) {\n    const { file, content } = context;\n\n    \u002F\u002F Custom validation logic\n    const complexity = await analyzeComplexity(content);\n    const securityIssues = await scanSecurity(content);\n\n    \u002F\u002F Store in memory\n    await storeInMemory({\n      key: `quality\u002F${file}`,\n      value: { complexity, securityIssues }\n    });\n\n    \u002F\u002F Return decision\n    if (complexity > 15 || securityIssues.length > 0) {\n      return {\n        continue: false,\n        reason: 'Quality checks failed',\n        warnings: [\n          `Complexity: ${complexity} (max: 15)`,\n          `Security issues: ${securityIssues.length}`\n        ]\n      };\n    }\n\n    return {\n      continue: true,\n      reason: 'Quality checks passed',\n      metadata: { complexity, securityIssues: 0 }\n    };\n  }\n};\n```\n\n#### Register Custom Hook\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"^(Write|Edit)$\",\n        \"hooks\": [\n          {\n            \"type\": \"script\",\n            \"script\": \".claude\u002Fhooks\u002Fcustom-quality-check.js\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n### Real-World Examples\n\n#### Example 1: Full-Stack Development Workflow\n\n```bash\n# Session start - initialize coordination\nnpx claude-flow hook session-start --session-id \"fullstack-feature\"\n\n# Pre-task planning\nnpx claude-flow hook pre-task \\\n  --description \"Build user profile feature - frontend + backend + tests\" \\\n  --auto-spawn-agents \\\n  --optimize-topology\n\n# Backend work\nnpx claude-flow hook pre-edit --file \"api\u002Fprofile.js\"\n# ... implement backend ...\nnpx claude-flow hook post-edit \\\n  --file \"api\u002Fprofile.js\" \\\n  --memory-key \"profile\u002Fbackend\" \\\n  --train-patterns\n\n# Frontend work (reads backend details from memory)\nnpx claude-flow hook pre-edit --file \"components\u002FProfile.jsx\"\n# ... implement frontend ...\nnpx claude-flow hook post-edit \\\n  --file \"components\u002FProfile.jsx\" \\\n  --memory-key \"profile\u002Ffrontend\" \\\n  --train-patterns\n\n# Testing (reads both backend and frontend from memory)\nnpx claude-flow hook pre-task \\\n  --description \"Test profile feature\" \\\n  --load-memory\n\n# Session end - export everything\nnpx claude-flow hook session-end \\\n  --session-id \"fullstack-feature\" \\\n  --export-metrics \\\n  --generate-summary\n```\n\n#### Example 2: Debugging with Hooks\n\n```bash\n# Start debugging session\nnpx claude-flow hook session-start --session-id \"debug-memory-leak\"\n\n# Pre-task: analyze issue\nnpx claude-flow hook pre-task \\\n  --description \"Debug memory leak in event handlers\" \\\n  --load-memory \\\n  --estimate-complexity\n\n# Search for event emitters\nnpx claude-flow hook pre-search --query \"EventEmitter\"\n# ... search executes ...\nnpx claude-flow hook post-search \\\n  --query \"EventEmitter\" \\\n  --cache-results\n\n# Fix the issue\nnpx claude-flow hook pre-edit \\\n  --file \"services\u002Fevents.js\" \\\n  --backup-file\n# ... fix code ...\nnpx claude-flow hook post-edit \\\n  --file \"services\u002Fevents.js\" \\\n  --memory-key \"debug\u002Fmemory-leak-fix\" \\\n  --validate-output\n\n# Verify fix\nnpx claude-flow hook post-task \\\n  --task-id \"memory-leak-fix\" \\\n  --analyze-performance \\\n  --generate-report\n\n# End session\nnpx claude-flow hook session-end \\\n  --session-id \"debug-memory-leak\" \\\n  --export-metrics\n```\n\n#### Example 3: Multi-Agent Refactoring\n\n```bash\n# Initialize swarm for refactoring\nnpx claude-flow hook pre-task \\\n  --description \"Refactor legacy codebase to modern patterns\" \\\n  --auto-spawn-agents \\\n  --optimize-topology\n\n# Agent 1: Code Analyzer\nnpx claude-flow hook pre-task --description \"Analyze code complexity\"\n# ... analysis ...\nnpx claude-flow hook post-task \\\n  --task-id \"analysis\" \\\n  --store-decisions\n\n# Agent 2: Refactoring (reads analysis from memory)\nnpx claude-flow hook session-restore \\\n  --session-id \"swarm-refactor\" \\\n  --restore-memory\n\nfor file in src\u002F**\u002F*.js; do\n  npx claude-flow hook pre-edit --file \"$file\" --backup-file\n  # ... refactor ...\n  npx claude-flow hook post-edit \\\n    --file \"$file\" \\\n    --memory-key \"refactor\u002F$file\" \\\n    --auto-format \\\n    --train-patterns\ndone\n\n# Agent 3: Testing (reads refactored code from memory)\nnpx claude-flow hook pre-task \\\n  --description \"Generate tests for refactored code\" \\\n  --load-memory\n\n# Broadcast completion\nnpx claude-flow hook notify \\\n  --message \"Refactoring complete - all tests passing\" \\\n  --broadcast\n```\n\n### Performance Tips\n\n1. **Keep Hooks Lightweight** - Target \u003C 100ms execution time\n2. **Use Async for Heavy Operations** - Don't block the main flow\n3. **Cache Aggressively** - Store frequently accessed data\n4. **Batch Related Operations** - Combine multiple actions\n5. **Use Memory Wisely** - Set appropriate TTLs\n6. **Monitor Hook Performance** - Track execution times\n7. **Parallelize When Possible** - Run independent hooks concurrently\n\n### Debugging Hooks\n\nEnable debug mode for troubleshooting:\n\n```bash\n# Enable debug output\nexport CLAUDE_FLOW_DEBUG=true\n\n# Test specific hook with verbose output\nnpx claude-flow hook pre-edit --file \"test.js\" --debug\n\n# Check hook execution logs\ncat .claude-flow\u002Flogs\u002Fhooks-$(date +%Y-%m-%d).log\n\n# Validate configuration\nnpx claude-flow hook validate-config\n```\n\n### Benefits\n\n- **Automatic Agent Assignment**: Right agent for every file type\n- **Consistent Code Formatting**: Language-specific formatters\n- **Continuous Learning**: Neural patterns improve over time\n- **Cross-Session Memory**: Context persists between sessions\n- **Performance Tracking**: Comprehensive metrics and analytics\n- **Automatic Coordination**: Agents sync via memory\n- **Smart Agent Spawning**: Task-based agent selection\n- **Quality Gates**: Pre-commit validation and verification\n- **Error Prevention**: Syntax validation before edits\n- **Knowledge Sharing**: Decisions stored and shared\n- **Reduced Manual Work**: Automation of repetitive tasks\n- **Better Collaboration**: Seamless multi-agent coordination\n\n### Best Practices\n\n1. **Configure Hooks Early** - Set up during project initialization\n2. **Use Memory Keys Strategically** - Organize with clear namespaces\n3. **Enable Auto-Formatting** - Maintain code consistency\n4. **Train Patterns Continuously** - Learn from successful operations\n5. **Monitor Performance** - Track hook execution times\n6. **Validate Configuration** - Test hooks before production use\n7. **Document Custom Hooks** - Maintain hook documentation\n8. **Set Appropriate Timeouts** - Prevent hanging operations\n9. **Handle Errors Gracefully** - Use continueOnError when appropriate\n10. **Review Metrics Regularly** - Optimize based on usage patterns\n\n### Troubleshooting\n\n#### Hooks Not Executing\n- Verify `.claude\u002Fsettings.json` syntax\n- Check hook matcher patterns\n- Enable debug mode\n- Review permission settings\n- Ensure claude-flow CLI is in PATH\n\n#### Hook Timeouts\n- Increase timeout values in configuration\n- Make hooks asynchronous for heavy operations\n- Optimize hook logic\n- Check network connectivity for MCP tools\n\n#### Memory Issues\n- Set appropriate TTLs for memory keys\n- Clean up old memory entries\n- Use memory namespaces effectively\n- Monitor memory usage\n\n#### Performance Problems\n- Profile hook execution times\n- Use caching for repeated operations\n- Batch operations when possible\n- Reduce hook complexity\n\n### Related Commands\n\n- `npx claude-flow init --hooks` - Initialize hooks system\n- `npx claude-flow hook --list` - List available hooks\n- `npx claude-flow hook --test \u003Chook>` - Test specific hook\n- `npx claude-flow memory usage` - Manage memory\n- `npx claude-flow agent spawn` - Spawn agents\n- `npx claude-flow swarm init` - Initialize swarm\n\n### Integration with Other Skills\n\nThis skill works seamlessly with:\n- **SPARC Methodology** - Hooks enhance SPARC workflows\n- **Pair Programming** - Automated quality in pairing sessions\n- **Verification Quality** - Truth-score validation in hooks\n- **GitHub Workflows** - Git integration for commits\u002FPRs\n- **Performance Analysis** - Metrics collection in hooks\n- **Swarm Advanced** - Multi-agent coordination via hooks\n",{"name":5,"description":7},"main","90d379e95fcc23dd9759654c345424e1752b0f3a","pocs\u002Fclaude-flow-fun\u002F.claude\u002Fskills\u002Fhooks-automation",9,"https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground","https:\u002F\u002Fgithub.com\u002Fdiegopacheco","http:\u002F\u002Fdiego-pacheco.blogspot.com","Brazilian Hands-on Software Architect | 20+ years in Tech | Author | Father. Opinions are my own!","2026-11-07 09:01:46",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add diegopacheco\u002Fai-playground --skill \"Hooks Automation\"",{"tool":56,"command":57},"bunx","bunx skills add diegopacheco\u002Fai-playground --skill \"Hooks Automation\"",{"tool":59,"command":60},"pnpm","pnpm dlx skills add diegopacheco\u002Fai-playground --skill \"Hooks Automation\"","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fclaude-flow-fun\u002F.claude\u002Fskills\u002Fhooks-automation\u002FSKILL.md",true,[],[65,81,91,104,119,138],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":74,"publishedAt":36},"01M6WJ537DN520XY8MSW9ZV0RP","word-count","Counts the words, lines and characters of a text or a file.","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fskills-gateway-router\u002Fupstream-skills\u002Ftext-skills\u002Fword-count\u002FSKILL.md",[71],{"categoryNo":72,"categoryName":73,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000002","文档处理",[75,76,77,78,79,80],"count","word count","Word","characters","text","file",{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":36},"01M6WJ4Y2GT5SECWAKKYHGES4F","slugify","Turns a title or a sentence into a URL slug, lowercase words joined by hyphens with accents removed.","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fskills-gateway-router\u002Fupstream-skills\u002Ftext-skills\u002Fslugify\u002FSKILL.md",[],[83,88,89,90],"title","with","URL",{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":36},"01M6WJ4V9CWHT9NVCD441VK5MH","json-format","Validates a JSON file and pretty prints it with two space indentation, or reports where the JSON is invalid.","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fskills-gateway-router\u002Fupstream-skills\u002Fdev-skills\u002Fjson-format\u002FSKILL.md",[],[98,99,100,80,101,102,103,89],"json","format","json format","reports","invalid","it",{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":36},"01M6WJ4QMRKW8EFP71F4KS2DHE","commit-message","Writes a conventional commit message for the staged git changes.","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fskills-gateway-router\u002Fupstream-skills\u002Fdev-skills\u002Fcommit-message\u002FSKILL.md",[],[111,112,113,31,114,115,116,117,118],"commit","commit message","message","conventional commit","for","changes","staged","conventional commit message",{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":36},"01M6WJ4MAM2CJH0GWYXFBB9GQC","skills-gateway","Gateway and router to a catalog of skills that are not registered directly. Use it before any task a specialized skill could handle, such as text, JSON or git chores. It finds the right skill and loads its instructions.","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fskills-gateway-router\u002F.claude\u002Fskills\u002Fskills-gateway\u002FSKILL.md",[],[126,127,103,128,129,31,130,98,79,131,132,133,134,135,136,137],"skills gateway","gateway","task","loads","Bash","node","specialized","instructions","catalog","use","router","as",{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":36},"01M6M2PYJJQKMWGX7XT7ZJK0H3","decision-log","Record, list, show and supersede architecture decisions that persist across sessions in the shared agent infra state store. Use when the user says \"record this decision\", \"log an ADR\", \"what did we decide about\", \"list decisions\", or \"supersede decision\".","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fagent-skills-infra-poc\u002Fskills\u002Fdecision-log\u002FSKILL.md",[],[145,146,147,148,149,150,151,152,153,154,135,155,156,157,158,159,160,161,162,163],"decision log","log","decision","persist","architecture","state","adr","decide","decisions","list","show","infra","record","across","shared","store","about","supersede","sessions"]