hooks-automation
Automated 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.
What this skill does
# Hooks Automation Intelligent automation system that coordinates, validates, and learns from Claude Code operations through hooks integrated with MCP tools and neural pattern training. ## What This Skill Does 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. **Key Capabilities:** - **Pre-Operation Hooks**: Validate, prepare, and auto-assign agents before operations - **Post-Operation Hooks**: Format, analyze, and train patterns after operations - **Session Management**: Persist state, restore context, generate summaries - **Memory Coordination**: Synchronize knowledge across swarm agents - **Git Integration**: Automated commit hooks with quality verification - **Neural Training**: Continuous learning from successful patterns - **MCP Integration**: Seamless coordination with swarm tools ## Prerequisites **Required:** - Claude Flow CLI installed (`npm install -g claude-flow@alpha`) - Claude Code with hooks enabled - `.claude/settings.json` with hook configurations **Optional:** - MCP servers configured (claude-flow, ruv-swarm, flow-nexus) - Git repository for version control - Testing framework for quality verification ## Quick Start ### Initialize Hooks System ```bash # Initialize with default hooks configuration npx claude-flow init --hooks ``` This creates: - `.claude/settings.json` with pre-configured hooks - Hook command documentation in `.claude/commands/hooks/` - Default hook handlers for common operations ### Basic Hook Usage ```bash # Pre-task hook (auto-spawns agents) npx claude-flow hook pre-task --description "Implement authentication" # Post-edit hook (auto-formats and stores in memory) npx claude-flow hook post-edit --file "src/auth.js" --memory-key "auth/login" # Session end hook (saves state and metrics) npx claude-flow hook session-end --session-id "dev-session" --export-metrics ``` --- ## Complete Guide ### Available Hooks #### Pre-Operation Hooks Hooks that execute BEFORE operations to prepare and validate: **pre-edit** - Validate and assign agents before file modifications ```bash npx claude-flow hook pre-edit [options] Options: --file, -f <path> File path to be edited --auto-assign-agent Automatically assign best agent (default: true) --validate-syntax Pre-validate syntax before edit --check-conflicts Check for merge conflicts --backup-file Create backup before editing Examples: npx claude-flow hook pre-edit --file "src/auth/login.js" npx claude-flow hook pre-edit -f "config/db.js" --validate-syntax npx claude-flow hook pre-edit -f "production.env" --backup-file --check-conflicts ``` **Features:** - Auto agent assignment based on file type - Syntax validation to prevent broken code - Conflict detection for concurrent edits - Automatic file backups for safety **pre-bash** - Check command safety and resource requirements ```bash npx claude-flow hook pre-bash --command <cmd> Options: --command, -c <cmd> Command to validate --check-safety Verify command safety (default: true) --estimate-resources Estimate resource usage --require-confirmation Request user confirmation for risky commands Examples: npx claude-flow hook pre-bash -c "rm -rf /tmp/cache" npx claude-flow hook pre-bash --command "docker build ." --estimate-resources ``` **Features:** - Command safety validation - Resource requirement estimation - Destructive command confirmation - Permission checks **pre-task** - Auto-spawn agents and prepare for complex tasks ```bash npx claude-flow hook pre-task [options] Options: --description, -d <text> Task description for context --auto-spawn-agents Automatically spawn required agents (default: true) --load-memory Load relevant memory from previous sessions --optimize-topology Select optimal swarm topology --estimate-complexity Analyze task complexity Examples: npx claude-flow hook pre-task --description "Implement user authentication" npx claude-flow hook pre-task -d "Continue API dev" --load-memory npx claude-flow hook pre-task -d "Refactor codebase" --optimize-topology ``` **Features:** - Automatic agent spawning based on task analysis - Memory loading for context continuity - Topology optimization for task structure - Complexity estimation and time prediction **pre-search** - Prepare and optimize search operations ```bash npx claude-flow hook pre-search --query <query> Options: --query, -q <text> Search query --check-cache Check cache first (default: true) --optimize-query Optimize search pattern Examples: npx claude-flow hook pre-search -q "authentication middleware" ``` **Features:** - Cache checking for faster results - Query optimization - Search pattern improvement #### Post-Operation Hooks Hooks that execute AFTER operations to process and learn: **post-edit** - Auto-format, validate, and update memory ```bash npx claude-flow hook post-edit [options] Options: --file, -f <path> File path that was edited --auto-format Automatically format code (default: true) --memory-key, -m <key> Store edit context in memory --train-patterns Train neural patterns from edit --validate-output Validate edited file Examples: npx claude-flow hook post-edit --file "src/components/Button.jsx" npx claude-flow hook post-edit -f "api/auth.js" --memory-key "auth/login" npx claude-flow hook post-edit -f "utils/helpers.ts" --train-patterns ``` **Features:** - Language-specific auto-formatting (Prettier, Black, gofmt) - Memory storage for edit context and decisions - Neural pattern training for continuous improvement - Output validation with linting **post-bash** - Log execution and update metrics ```bash npx claude-flow hook post-bash --command <cmd> Options: --command, -c <cmd> Command that was executed --log-output Log command output (default: true) --update-metrics Update performance metrics --store-result Store result in memory Examples: npx claude-flow hook post-bash -c "npm test" --update-metrics ``` **Features:** - Command execution logging - Performance metric tracking - Result storage for analysis - Error pattern detection **post-task** - Performance analysis and decision storage ```bash npx claude-flow hook post-task [options] Options: --task-id, -t <id> Task identifier for tracking --analyze-performance Generate performance metrics (default: true) --store-decisions Save task decisions to memory --export-learnings Export neural pattern learnings --generate-report Create task completion report Examples: npx claude-flow hook post-task --task-id "auth-implementation" npx claude-flow hook post-task -t "api-refactor" --analyze-performance npx claude-flow hook post-task -t "bug-fix-123" --store-decisions ``` **Features:** - Execution time and token usage measurement - Decision and implementation choice recording - Neural learning pattern export - Completion report generation **post-search** - Cache results and improve patterns ```bash npx claude-flow hook post-search --query <query> --results <path> Options: --query, -q <text> Original search query --results, -r <path> Results file path --cache-results Cache for future use (default: true) --train-patterns Improve search patterns Examples: npx claude-flow hook post-search -q "auth" -r "results.json" --train-patterns ``` **Features:** - Result caching for faster subsequent searches - Search pattern improvement - Relevance scoring #### MCP Integration Hooks Hooks that coordinate with MCP swarm tools: **mcp-initialized** - Pe
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.