Agent skill
claude-flow-integration
Hybrid Claude-Flow V3 integration architecture: hook execution order, system roles, background workers, production features (DDD/ADR/security), and integration rules. Use when working with Claude-Flow hooks, workers, or production features.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/claude-flow-integration
SKILL.md
Claude-Flow Integration
This project uses a hybrid architecture combining Claude Code's native agent teams with Claude-Flow V3 features. Both systems MUST work together — neither is optional.
Architecture Philosophy
- Priority: Stability and integrity over speed optimization
- Context: Production-quality work, not just internal tooling
- Enforcement: 100% accuracy required for all workflow rules
System Roles
Our Custom System (Blocking Enforcement)
- Agent Teams: TeamCreate + native experimental teams (visible tmux panes, mandatory)
- Hooks:
.claude/hooks/*.shscripts enforce workflow rules (blocking, fail-fast) - Memory:
claude-memstores human decisions, architectural choices, preferences - Agent Specs:
.claude/agents/*.mddefine agent capabilities (authoritative for model routing) - Linear Integration: Single source of truth for requirements, status, tickets
Claude-Flow V3 (Learning & Advisory)
- Hooks: Claude-Flow hooks run AFTER our enforcement hooks (non-blocking, continueOnError: true)
- Background Workers: 10 daemon workers (map, audit, optimize, consolidate, testgaps, ultralearn, deepdive, document, refactor, benchmark)
- Memory: Claude-Flow HNSW memory stores agent patterns, coding learnings, optimization history
- Model Routing: Claude-Flow routing provides suggestions; agent specs are the final authority
- Task Management: Claude-Flow task orchestration supplements native TaskCreate/TaskUpdate
- Production Features: DDD domain tracking, ADR generation, security scanning (CVE, threat modeling)
Serena MCP (Semantic Code Intelligence)
- Symbol Navigation:
find_symbol,get_symbols_overviewfor token-efficient code reading (50-75% savings vs reading full files) - Impact Analysis:
find_referencing_symbolsto find all callers/users of any symbol - Precise Edits:
replace_symbol_body,insert_before/after_symbolfor symbol-level code modifications - Rename Refactoring:
rename_symbolwith automatic reference updates across codebase - Pattern Search:
search_for_patternfor regex search across project files - Project Memory:
read_memory,write_memoryfor project-specific code structure and conventions
Hook Execution Order (CRITICAL)
Hooks run in this exact order to ensure enforcement before learning:
Write/Edit/MultiEdit:
.claude/hooks/protect-hooks.sh(ask — prompts user before hook modifications).claude/hooks/enforce-orchestrator-delegation-v2.sh(blocking — ensures orchestrator delegates to agents; auto-allows subagents).claude/hooks/enforce-plan-files.sh(blocking — protects plan/ directory).claude/hooks/check-unwrap.sh(advisory — warns about.unwrap()in library code).claude/hooks/scan-secrets.sh(advisory — detects potential secrets/credentials in code)- Claude-Flow
pre-edithook (non-blocking — learns patterns, advisory only)
Bash commands:
.claude/hooks/protect-hooks.sh(ask — prompts user before hook modifications).claude/hooks/enforce-orchestrator-delegation-v2.sh(blocking — catches sed/awk/perl bypasses; auto-allows subagents).claude/hooks/protect-main.sh(blocking — prevents direct main commits).claude/hooks/enforce-branch-naming.sh(blocking — validates branch format).claude/hooks/enforce-review-gate.sh(blocking — requires git-review completion)- Claude-Flow
pre-commandhook (non-blocking — learns patterns, advisory only)
Task (agent spawning):
.claude/hooks/enforce-visible-agents.sh(blocking — requires team_name for agent visibility)- Claude-Flow task hook (non-blocking — advisory only)
Read/Grep/Bash (source files):
.claude/hooks/enforce-serena-usage.sh(advisory — suggests Serena for code navigation)
Stop (session end):
.claude/hooks/enforce-memory.sh(advisory — reminds to save to claude-mem).claude/hooks/check-claude-flow-memory.sh(advisory — reminds to save patterns)
TaskCompleted (task marked done):
.claude/hooks/enforce-task-quality.sh(blocking — runscargo test+cargo clippybefore task completion; skips non-code tasks)
TeammateIdle (agent going idle):
.claude/hooks/enforce-idle-quality.sh(blocking — runscargo test+cargo clippybefore idle; skips if no source changes)
UserPromptSubmit (every prompt):
.claude/hooks/enforce-ticket.sh(blocking — requires branch with ticket ID)- Claude-Flow routing hook (non-blocking)
.claude/hooks/workflow-reminder.sh(advisory)
Memory Separation
- claude-mem: User preferences, architectural decisions, debugging insights, cross-session learnings (human-driven)
- Claude-Flow memory: Agent coordination patterns, code optimization history, model performance data (agent-driven)
- Serena memory: Project code structure, conventions, build commands (code-driven, auto-discovered via onboarding)
- Linear: Ticket requirements, acceptance criteria, status tracking (project management)
- No overlap: Each memory system serves a distinct purpose; never duplicate content
Tool Routing (Serena vs Native Tools)
- Reading code structure: Use Serena
get_symbols_overview→ only read bodies you need (saves 50-75% tokens) - Finding definitions: Use Serena
find_symbolinstead of Grep for symbol definitions - Finding callers: Use Serena
find_referencing_symbolsinstead of Grep for who-calls-what - Replacing functions: Use Serena
replace_symbol_bodyfor entire function replacement (vs Edit for line-level) - Non-code files: Use Read/Edit/Grep (Serena only works with LSP-supported languages)
- Config/markdown/TOML: Use Read/Edit (Serena has limited support for non-code)
Model Routing
- Agent specs (
.claude/agents/*.md) define the authoritative model for each agent type - Claude-Flow routing provides suggestions based on task complexity and past performance
- In case of conflict: Agent spec always wins (manual configuration > automated suggestion)
- Model tiers: Opus (3: planner, red-teamer, senior-coder), Sonnet (7: requirements-interviewer, explorer, architect, coder, tech-lead, reviewer, qa), Haiku (4: junior-coder, documentation, explainer, optimizer)
- Example:
coderuses Sonnet (per spec), even if Claude-Flow suggests Opus for a task
Background Workers (Always Enabled)
All 10 Claude-Flow daemon workers run continuously:
- map: Codebase structure analysis
- audit: Code quality and security auditing
- optimize: Performance optimization suggestions
- consolidate: Memory and pattern consolidation
- testgaps: Test coverage gap detection
- ultralearn: Advanced pattern learning from agent interactions
- deepdive: Deep analysis of complex code changes
- document: Automatic documentation generation (ADR, DDD docs)
- refactor: Refactoring opportunity detection
- benchmark: Performance benchmarking and regression detection
Production Features (Always Enabled)
- DDD (Domain-Driven Design): Track bounded contexts, validate domain boundaries, maintain
/docs/ddd - ADR (Architecture Decision Records): Auto-generate decision records, maintain
/docs/adr, use MADR template - Security Scanning: Auto-scan on edit, CVE vulnerability checking, threat modeling, security pattern detection
Integration Rules
- Both systems required: Claude-Flow features supplement native teams; never replace them
- Hook order matters: Our blocking hooks run first; Claude-Flow hooks learn second
- Memory separation: Never duplicate data across claude-mem, Claude-Flow memory, and Linear
- Model authority: Agent specs define models; Claude-Flow routing is advisory only
- Stability first: All Claude-Flow hooks have
continueOnError: trueto prevent workflow blockage - 100% enforcement: Our custom hooks must maintain perfect accuracy; no false positives
Why This Architecture?
- Complementary systems: Native teams handle coordination; Claude-Flow handles learning
- Fail-safe design: Blocking enforcement prevents mistakes; non-blocking learning improves over time
- Production-ready: DDD, ADR, security features support large-scale professional work
- Clear boundaries: Each system owns specific responsibilities with no overlap
- Observable behavior: tmux panes show agent activity; background workers run invisibly
- Token efficiency: Serena's LSP-powered navigation reads only what's needed (50-75% savings over full-file reads)
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?