$npx -y skills add spencermarx/open-code-review --skill hooks-automationAutomated coordination, formatting, and learning from Claude Code operations using intelligent hooks with MCP integration. Includes pre/post task hooks, session management, Git integration, memory coordination, and neural pattern training for enhanced development workflows.
| 1 | # Hooks Automation |
| 2 | |
| 3 | Intelligent automation system that coordinates, validates, and learns from Claude Code operations through hooks integrated with MCP tools and neural pattern training. |
| 4 | |
| 5 | ## What This Skill Does |
| 6 | |
| 7 | This 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. |
| 8 | |
| 9 | **Key Capabilities:** |
| 10 | - **Pre-Operation Hooks**: Validate, prepare, and auto-assign agents before operations |
| 11 | - **Post-Operation Hooks**: Format, analyze, and train patterns after operations |
| 12 | - **Session Management**: Persist state, restore context, generate summaries |
| 13 | - **Memory Coordination**: Synchronize knowledge across swarm agents |
| 14 | - **Git Integration**: Automated commit hooks with quality verification |
| 15 | - **Neural Training**: Continuous learning from successful patterns |
| 16 | - **MCP Integration**: Seamless coordination with swarm tools |
| 17 | |
| 18 | ## Prerequisites |
| 19 | |
| 20 | **Required:** |
| 21 | - Claude Flow CLI installed (`npm install -g claude-flow@alpha`) |
| 22 | - Claude Code with hooks enabled |
| 23 | - `.claude/settings.json` with hook configurations |
| 24 | |
| 25 | **Optional:** |
| 26 | - MCP servers configured (claude-flow, ruv-swarm, flow-nexus) |
| 27 | - Git repository for version control |
| 28 | - Testing framework for quality verification |
| 29 | |
| 30 | ## Quick Start |
| 31 | |
| 32 | ### Initialize Hooks System |
| 33 | |
| 34 | ```bash |
| 35 | # Initialize with default hooks configuration |
| 36 | npx claude-flow init --hooks |
| 37 | ``` |
| 38 | |
| 39 | This creates: |
| 40 | - `.claude/settings.json` with pre-configured hooks |
| 41 | - Hook command documentation in `.claude/commands/hooks/` |
| 42 | - Default hook handlers for common operations |
| 43 | |
| 44 | ### Basic Hook Usage |
| 45 | |
| 46 | ```bash |
| 47 | # Pre-task hook (auto-spawns agents) |
| 48 | npx claude-flow hook pre-task --description "Implement authentication" |
| 49 | |
| 50 | # Post-edit hook (auto-formats and stores in memory) |
| 51 | npx claude-flow hook post-edit --file "src/auth.js" --memory-key "auth/login" |
| 52 | |
| 53 | # Session end hook (saves state and metrics) |
| 54 | npx claude-flow hook session-end --session-id "dev-session" --export-metrics |
| 55 | ``` |
| 56 | |
| 57 | --- |
| 58 | |
| 59 | ## Complete Guide |
| 60 | |
| 61 | ### Available Hooks |
| 62 | |
| 63 | #### Pre-Operation Hooks |
| 64 | |
| 65 | Hooks that execute BEFORE operations to prepare and validate: |
| 66 | |
| 67 | **pre-edit** - Validate and assign agents before file modifications |
| 68 | ```bash |
| 69 | npx claude-flow hook pre-edit [options] |
| 70 | |
| 71 | Options: |
| 72 | --file, -f <path> File path to be edited |
| 73 | --auto-assign-agent Automatically assign best agent (default: true) |
| 74 | --validate-syntax Pre-validate syntax before edit |
| 75 | --check-conflicts Check for merge conflicts |
| 76 | --backup-file Create backup before editing |
| 77 | |
| 78 | Examples: |
| 79 | npx claude-flow hook pre-edit --file "src/auth/login.js" |
| 80 | npx claude-flow hook pre-edit -f "config/db.js" --validate-syntax |
| 81 | npx claude-flow hook pre-edit -f "production.env" --backup-file --check-conflicts |
| 82 | ``` |
| 83 | |
| 84 | **Features:** |
| 85 | - Auto agent assignment based on file type |
| 86 | - Syntax validation to prevent broken code |
| 87 | - Conflict detection for concurrent edits |
| 88 | - Automatic file backups for safety |
| 89 | |
| 90 | **pre-bash** - Check command safety and resource requirements |
| 91 | ```bash |
| 92 | npx claude-flow hook pre-bash --command <cmd> |
| 93 | |
| 94 | Options: |
| 95 | --command, -c <cmd> Command to validate |
| 96 | --check-safety Verify command safety (default: true) |
| 97 | --estimate-resources Estimate resource usage |
| 98 | --require-confirmation Request user confirmation for risky commands |
| 99 | |
| 100 | Examples: |
| 101 | npx claude-flow hook pre-bash -c "rm -rf /tmp/cache" |
| 102 | npx claude-flow hook pre-bash --command "docker build ." --estimate-resources |
| 103 | ``` |
| 104 | |
| 105 | **Features:** |
| 106 | - Command safety validation |
| 107 | - Resource requirement estimation |
| 108 | - Destructive command confirmation |
| 109 | - Permission checks |
| 110 | |
| 111 | **pre-task** - Auto-spawn agents and prepare for complex tasks |
| 112 | ```bash |
| 113 | npx claude-flow hook pre-task [options] |
| 114 | |
| 115 | Options: |
| 116 | --description, -d <text> Task description for context |
| 117 | --auto-spawn-agents Automatically spawn required agents (default: true) |
| 118 | --load-memory Load relevant memory from previous sessions |
| 119 | --optimize-topology Select optimal swarm topology |
| 120 | --estimate-complexity Analyze task complexity |
| 121 | |
| 122 | Examples: |
| 123 | npx claude-flow hook pre-task --description "Implement user authentication" |
| 124 | npx claude-flow hook pre-task -d "Continue API dev" --load-memory |
| 125 | npx claude-flow hook pre-task -d "Refactor codebase" --optimize-topology |
| 126 | ``` |
| 127 | |
| 128 | **Features:** |
| 129 | - Automatic agent spawning based on task analysis |
| 130 | - Memory loading for context continuity |
| 131 | - Topology optimization for task structure |
| 132 | - Complexity estimation and time prediction |
| 133 | |
| 134 | **pre-search** - Prepare and optimize search operations |
| 135 | ```bash |
| 136 | npx claude-flow hook pre-se |