v3/implementation/PLUGIN_INTEGRATION.md
This document describes how claude-flow integrates with the official Claude Code plugin system.
plugin/
├── .claude-plugin/
│ └── plugin.json # Official plugin manifest
├── .mcp.json # MCP server bundle
├── hooks/
│ └── hooks.json # Hook configurations
├── skills -> ../.claude/skills # 60+ skills
├── commands -> ../.claude/commands # 100+ commands
└── agents -> ../v2/.claude/agents # 80+ agents
plugin.json){
"name": "claude-flow",
"version": "3.0.0",
"capabilities": {
"skills": true,
"commands": true,
"agents": true,
"hooks": true,
"mcpServers": true
}
}
| V3 Internal Event | Official Claude Code Event | Tool Matcher |
|---|---|---|
PreEdit | PreToolUse | ^(Write|Edit|MultiEdit)$ |
PostEdit | PostToolUse | ^(Write|Edit|MultiEdit)$ |
PreCommand | PreToolUse | ^Bash$ |
PostCommand | PostToolUse | ^Bash$ |
PreTask | UserPromptSubmit | - |
PostTask | PostToolUse | ^Task$ |
SessionStart | SessionStart | - |
SessionEnd | Stop | - |
AgentSpawn | PostToolUse | ^Task$ |
AgentTerminate | SubagentStop | - |
PreRoute | UserPromptSubmit | - |
The plugin bundles three MCP servers:
Skills follow the official SKILL.md format:
---
name: skill-name
description: What this skill does
allowed-tools: Read, Write, Bash
---
# Skill Name
[Instructions for Claude]
The @claude-flow/hooks package includes an official hooks bridge:
import {
OfficialHooksBridge,
processOfficialHookInput,
outputOfficialHookResult,
executeWithBridge,
} from '@claude-flow/hooks';
// Process input from Claude Code
const input = await processOfficialHookInput();
// Convert to V3 context
const context = OfficialHooksBridge.toV3Context(input);
// Execute V3 handler
const result = await handler(context);
// Convert back to official output
const output = OfficialHooksBridge.toOfficialOutput(result, input.hook_event_name);
outputOfficialHookResult(output);
# Add plugin marketplace
/plugin marketplace add claude-flow https://github.com/ruvnet/claude-flow
# Install plugin
/plugin install claude-flow
# Clone and link
git clone https://github.com/ruvnet/claude-flow
claude --plugin-dir ./claude-flow/plugin
npx claude-flow@alpha init --hooks
Add to .claude/settings.json:
{
"hooks": {
"PreToolUse": [...],
"PostToolUse": [...],
"UserPromptSubmit": [...],
"SessionStart": [...],
"Stop": [...]
}
}
Enable only specific hooks by choosing matchers:
{
"hooks": {
"PreToolUse": [
{
"matcher": "^(Write|Edit)$",
"hooks": [{ "type": "command", "command": "npx claude-flow@alpha hooks pre-edit" }]
}
]
}
}
After installation, MCP tools are available:
mcp__claude-flow__swarm_initmcp__claude-flow__agent_spawnmcp__claude-flow__task_orchestratemcp__claude-flow__memory_usagemcp__claude-flow__hooks_routemcp__claude-flow__hooks_metrics{
"name": "claude-flow-marketplace",
"plugins": [
{
"name": "claude-flow",
"description": "Multi-agent swarm coordination",
"version": "3.0.0",
"path": "plugin"
}
]
}
/plugin marketplace add name https://github.com/user/repo/plugin install claude-flow@name┌─────────────────────────────────────────────────────────────┐
│ Claude Code │
├─────────────────────────────────────────────────────────────┤
│ Official Hooks API │
│ ┌─────────────┬─────────────┬─────────────┬──────────────┐ │
│ │ PreToolUse │ PostToolUse │ SessionStart│ UserPrompt │ │
│ └──────┬──────┴──────┬──────┴──────┬──────┴──────┬───────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────────────────────────┐│
│ │ Official Hooks Bridge ││
│ │ (v3/@claude-flow/hooks/src/bridge/official-hooks-bridge)││
│ └──────────────────────────────────────────────────────────┘│
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌─────────────┬─────────────┬─────────────┬──────────────┐ │
│ │ PreEdit │ PostEdit │ SessionStart│ PreTask │ │
│ │ PreCommand │ PostCommand │ SessionEnd │ PostTask │ │
│ └─────────────┴─────────────┴─────────────┴──────────────┘ │
│ V3 Hooks System │
├─────────────────────────────────────────────────────────────┤
│ @claude-flow/hooks │
│ ┌───────────┬───────────┬───────────┬───────────────────┐ │
│ │ Registry │ Executor │ Daemons │ MCP Tools │ │
│ └───────────┴───────────┴───────────┴───────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ Skills │ Commands │ Agents │ MCP Servers │
└─────────────────────────────────────────────────────────────┘
.claude/ configurations