Added in git-flow
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
# Self-Healing Workflows
|
||||
|
||||
## Purpose
|
||||
Automatically detect and recover from errors without interrupting your flow.
|
||||
|
||||
## Self-Healing Features
|
||||
|
||||
### 1. Error Detection
|
||||
Monitors for:
|
||||
- Failed commands
|
||||
- Syntax errors
|
||||
- Missing dependencies
|
||||
- Broken tests
|
||||
|
||||
### 2. Automatic Recovery
|
||||
|
||||
**Missing Dependencies:**
|
||||
```
|
||||
Error: Cannot find module 'express'
|
||||
→ Automatically runs: npm install express
|
||||
→ Retries original command
|
||||
```
|
||||
|
||||
**Syntax Errors:**
|
||||
```
|
||||
Error: Unexpected token
|
||||
→ Analyzes error location
|
||||
→ Suggests fix through analyzer agent
|
||||
→ Applies fix with confirmation
|
||||
```
|
||||
|
||||
**Test Failures:**
|
||||
```
|
||||
Test failed: "user authentication"
|
||||
→ Spawns debugger agent
|
||||
→ Analyzes failure cause
|
||||
→ Implements fix
|
||||
→ Re-runs tests
|
||||
```
|
||||
|
||||
### 3. Learning from Failures
|
||||
Each recovery improves future prevention:
|
||||
- Patterns saved to knowledge base
|
||||
- Similar errors prevented proactively
|
||||
- Recovery strategies optimized
|
||||
|
||||
**Pattern Storage:**
|
||||
```javascript
|
||||
// Store error patterns
|
||||
mcp__claude-flow__memory_usage({
|
||||
"action": "store",
|
||||
"key": "error-pattern-" + Date.now(),
|
||||
"value": JSON.stringify(errorData),
|
||||
"namespace": "error-patterns",
|
||||
"ttl": 2592000 // 30 days
|
||||
})
|
||||
|
||||
// Analyze patterns
|
||||
mcp__claude-flow__neural_patterns({
|
||||
"action": "analyze",
|
||||
"operation": "error-recovery",
|
||||
"outcome": "success"
|
||||
})
|
||||
```
|
||||
|
||||
## Self-Healing Integration
|
||||
|
||||
### MCP Tool Coordination
|
||||
```javascript
|
||||
// Initialize self-healing swarm
|
||||
mcp__claude-flow__swarm_init({
|
||||
"topology": "star",
|
||||
"maxAgents": 4,
|
||||
"strategy": "adaptive"
|
||||
})
|
||||
|
||||
// Spawn recovery agents
|
||||
mcp__claude-flow__agent_spawn({
|
||||
"type": "monitor",
|
||||
"name": "Error Monitor",
|
||||
"capabilities": ["error-detection", "recovery"]
|
||||
})
|
||||
|
||||
// Orchestrate recovery
|
||||
mcp__claude-flow__task_orchestrate({
|
||||
"task": "recover from error",
|
||||
"strategy": "sequential",
|
||||
"priority": "critical"
|
||||
})
|
||||
```
|
||||
|
||||
### Fallback Hook Configuration
|
||||
```json
|
||||
{
|
||||
"PostToolUse": [{
|
||||
"matcher": "^Bash$",
|
||||
"command": "npx claude-flow hook post-bash --exit-code '${tool.result.exitCode}' --auto-recover"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
## Benefits
|
||||
- 🛡️ Resilient workflows
|
||||
- 🔄 Automatic recovery
|
||||
- 📚 Learns from errors
|
||||
- ⏱️ Saves debugging time
|
||||
@@ -0,0 +1,90 @@
|
||||
# Cross-Session Memory
|
||||
|
||||
## Purpose
|
||||
Maintain context and learnings across Claude Code sessions for continuous improvement.
|
||||
|
||||
## Memory Features
|
||||
|
||||
### 1. Automatic State Persistence
|
||||
At session end, automatically saves:
|
||||
- Active agents and specializations
|
||||
- Task history and patterns
|
||||
- Performance metrics
|
||||
- Neural network weights
|
||||
- Knowledge base updates
|
||||
|
||||
### 2. Session Restoration
|
||||
```javascript
|
||||
// Using MCP tools for memory operations
|
||||
mcp__claude-flow__memory_usage({
|
||||
"action": "retrieve",
|
||||
"key": "session-state",
|
||||
"namespace": "sessions"
|
||||
})
|
||||
|
||||
// Restore swarm state
|
||||
mcp__claude-flow__context_restore({
|
||||
"snapshotId": "sess-123"
|
||||
})
|
||||
```
|
||||
|
||||
**Fallback with npx:**
|
||||
```bash
|
||||
npx claude-flow hook session-restore --session-id "sess-123"
|
||||
```
|
||||
|
||||
### 3. Memory Types
|
||||
|
||||
**Project Memory:**
|
||||
- File relationships
|
||||
- Common edit patterns
|
||||
- Testing approaches
|
||||
- Build configurations
|
||||
|
||||
**Agent Memory:**
|
||||
- Specialization levels
|
||||
- Task success rates
|
||||
- Optimization strategies
|
||||
- Error patterns
|
||||
|
||||
**Performance Memory:**
|
||||
- Bottleneck history
|
||||
- Optimization results
|
||||
- Token usage patterns
|
||||
- Efficiency trends
|
||||
|
||||
### 4. Privacy & Control
|
||||
```javascript
|
||||
// List memory contents
|
||||
mcp__claude-flow__memory_usage({
|
||||
"action": "list",
|
||||
"namespace": "sessions"
|
||||
})
|
||||
|
||||
// Delete specific memory
|
||||
mcp__claude-flow__memory_usage({
|
||||
"action": "delete",
|
||||
"key": "session-123",
|
||||
"namespace": "sessions"
|
||||
})
|
||||
|
||||
// Backup memory
|
||||
mcp__claude-flow__memory_backup({
|
||||
"path": "./backups/memory-backup.json"
|
||||
})
|
||||
```
|
||||
|
||||
**Manual control:**
|
||||
```bash
|
||||
# View stored memory
|
||||
ls .claude-flow/memory/
|
||||
|
||||
# Disable memory
|
||||
export CLAUDE_FLOW_MEMORY_PERSIST=false
|
||||
```
|
||||
|
||||
## Benefits
|
||||
- 🧠 Contextual awareness
|
||||
- 📈 Cumulative learning
|
||||
- ⚡ Faster task completion
|
||||
- 🎯 Personalized optimization
|
||||
@@ -0,0 +1,73 @@
|
||||
# Smart Agent Auto-Spawning
|
||||
|
||||
## Purpose
|
||||
Automatically spawn the right agents at the right time without manual intervention.
|
||||
|
||||
## Auto-Spawning Triggers
|
||||
|
||||
### 1. File Type Detection
|
||||
When editing files, agents auto-spawn:
|
||||
- **JavaScript/TypeScript**: Coder agent
|
||||
- **Markdown**: Researcher agent
|
||||
- **JSON/YAML**: Analyst agent
|
||||
- **Multiple files**: Coordinator agent
|
||||
|
||||
### 2. Task Complexity
|
||||
```
|
||||
Simple task: "Fix typo"
|
||||
→ Single coordinator agent
|
||||
|
||||
Complex task: "Implement OAuth with Google"
|
||||
→ Architect + Coder + Tester + Researcher
|
||||
```
|
||||
|
||||
### 3. Dynamic Scaling
|
||||
The system monitors workload and spawns additional agents when:
|
||||
- Task queue grows
|
||||
- Complexity increases
|
||||
- Parallel opportunities exist
|
||||
|
||||
**Status Monitoring:**
|
||||
```javascript
|
||||
// Check swarm health
|
||||
mcp__claude-flow__swarm_status({
|
||||
"swarmId": "current"
|
||||
})
|
||||
|
||||
// Monitor agent performance
|
||||
mcp__claude-flow__agent_metrics({
|
||||
"agentId": "agent-123"
|
||||
})
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### MCP Tool Integration
|
||||
Uses Claude Flow MCP tools for agent coordination:
|
||||
```javascript
|
||||
// Initialize swarm with appropriate topology
|
||||
mcp__claude-flow__swarm_init({
|
||||
"topology": "mesh",
|
||||
"maxAgents": 8,
|
||||
"strategy": "auto"
|
||||
})
|
||||
|
||||
// Spawn agents based on file type
|
||||
mcp__claude-flow__agent_spawn({
|
||||
"type": "coder",
|
||||
"name": "JavaScript Handler",
|
||||
"capabilities": ["javascript", "typescript"]
|
||||
})
|
||||
```
|
||||
|
||||
### Fallback Configuration
|
||||
If MCP tools are unavailable:
|
||||
```bash
|
||||
npx claude-flow hook pre-task --auto-spawn-agents
|
||||
```
|
||||
|
||||
## Benefits
|
||||
- 🤖 Zero manual agent management
|
||||
- 🎯 Perfect agent selection
|
||||
- 📈 Dynamic scaling
|
||||
- 💾 Resource efficiency
|
||||
Reference in New Issue
Block a user