claude-flow-novice 1.5.1 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/architecture/system-architect.md +3 -44
- package/.claude/agents/benchmarking-tests/test-agent-code-heavy.md +747 -0
- package/.claude/agents/benchmarking-tests/test-agent-metadata.md +181 -0
- package/.claude/agents/benchmarking-tests/test-agent-minimal.md +67 -0
- package/.claude/agents/data/ml/data-ml-model.md +5 -119
- package/.claude/agents/development/backend/dev-backend-api.md +4 -115
- package/.claude/agents/devops/ci-cd/ops-cicd-github.md +4 -114
- package/.claude/agents/documentation/api-docs/docs-api-openapi.md +4 -113
- package/.claude/agents/github/multi-repo-swarm.md +1 -28
- package/.claude/agents/github/pr-manager.md +1 -29
- package/.claude/agents/github/project-board-sync.md +1 -32
- package/.claude/agents/github/release-manager.md +1 -32
- package/.claude/agents/github/release-swarm.md +1 -33
- package/.claude/agents/github/repo-architect.md +1 -34
- package/.claude/agents/github/swarm-issue.md +1 -26
- package/.claude/agents/github/swarm-pr.md +1 -30
- package/.claude/agents/github/sync-coordinator.md +1 -30
- package/.claude/agents/github/workflow-automation.md +1 -31
- package/.claude/agents/neural/neural-pattern-agent.md +2 -50
- package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +6 -142
- package/.claude/agents/sublinear/consciousness-evolution-agent.md +2 -18
- package/.claude/agents/sublinear/matrix-solver-agent.md +2 -16
- package/.claude/agents/sublinear/nanosecond-scheduler-agent.md +2 -19
- package/.claude/agents/sublinear/pagerank-agent.md +2 -19
- package/.claude/agents/sublinear/phi-calculator-agent.md +2 -19
- package/.claude/agents/sublinear/psycho-symbolic-agent.md +2 -19
- package/.claude/agents/sublinear/sublinear.md +2 -1
- package/.claude/agents/sublinear/temporal-advantage-agent.md +2 -16
- package/.claude/agents/testing/e2e/playwright-agent.md +7 -0
- package/.claude-flow-novice/.claude/agents/architecture/system-architect.md +3 -44
- package/.claude-flow-novice/.claude/agents/benchmarking-tests/test-agent-code-heavy.md +747 -0
- package/.claude-flow-novice/.claude/agents/benchmarking-tests/test-agent-metadata.md +181 -0
- package/.claude-flow-novice/.claude/agents/benchmarking-tests/test-agent-minimal.md +67 -0
- package/.claude-flow-novice/.claude/agents/data/ml/data-ml-model.md +5 -119
- package/.claude-flow-novice/.claude/agents/development/backend/dev-backend-api.md +4 -115
- package/.claude-flow-novice/.claude/agents/devops/ci-cd/ops-cicd-github.md +4 -114
- package/.claude-flow-novice/.claude/agents/documentation/api-docs/docs-api-openapi.md +4 -113
- package/.claude-flow-novice/.claude/agents/github/multi-repo-swarm.md +1 -28
- package/.claude-flow-novice/.claude/agents/github/pr-manager.md +1 -29
- package/.claude-flow-novice/.claude/agents/github/project-board-sync.md +1 -32
- package/.claude-flow-novice/.claude/agents/github/release-manager.md +1 -32
- package/.claude-flow-novice/.claude/agents/github/release-swarm.md +1 -33
- package/.claude-flow-novice/.claude/agents/github/repo-architect.md +1 -34
- package/.claude-flow-novice/.claude/agents/github/swarm-issue.md +1 -26
- package/.claude-flow-novice/.claude/agents/github/swarm-pr.md +1 -30
- package/.claude-flow-novice/.claude/agents/github/sync-coordinator.md +1 -30
- package/.claude-flow-novice/.claude/agents/github/workflow-automation.md +1 -31
- package/.claude-flow-novice/.claude/agents/neural/neural-pattern-agent.md +2 -50
- package/.claude-flow-novice/.claude/agents/specialized/mobile/spec-mobile-react-native.md +6 -142
- package/.claude-flow-novice/.claude/agents/sublinear/consciousness-evolution-agent.md +2 -18
- package/.claude-flow-novice/.claude/agents/sublinear/matrix-solver-agent.md +2 -16
- package/.claude-flow-novice/.claude/agents/sublinear/nanosecond-scheduler-agent.md +2 -19
- package/.claude-flow-novice/.claude/agents/sublinear/pagerank-agent.md +2 -19
- package/.claude-flow-novice/.claude/agents/sublinear/phi-calculator-agent.md +2 -19
- package/.claude-flow-novice/.claude/agents/sublinear/psycho-symbolic-agent.md +2 -19
- package/.claude-flow-novice/.claude/agents/sublinear/sublinear.md +2 -1
- package/.claude-flow-novice/.claude/agents/sublinear/temporal-advantage-agent.md +2 -16
- package/.claude-flow-novice/.claude/agents/testing/e2e/playwright-agent.md +7 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/CLAUDE.md +188 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/claude-flow-universal +81 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/claude-flow.bat +18 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/claude-flow.ps1 +24 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/claude-md.js +982 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/analysis/bottleneck-detect.md +162 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/automation/auto-agent.md +122 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/coordination/swarm-init.md +85 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/github/github-swarm.md +121 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/helpers/standard-checkpoint-hooks.sh +179 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/hooks/notification.md +113 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/hooks/post-command.md +116 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/hooks/post-edit.md +117 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/hooks/post-task.md +112 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/hooks/pre-command.md +113 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/hooks/pre-edit.md +113 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/hooks/pre-search.md +112 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/hooks/pre-task.md +111 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/hooks/session-end.md +118 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/hooks/session-restore.md +118 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/commands/hooks/session-start.md +117 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/coordination-md.js +340 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/coordination.md +16 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/enhanced-templates.js +2347 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/github-safe-enhanced.js +331 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/github-safe.js +106 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/memory-bank-md.js +259 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/memory-bank.md +16 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/readme-files.js +72 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/safe-hook-patterns.js +430 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/settings.json +109 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/settings.json.enhanced +35 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/sparc-modes.js +1401 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +188 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/claude-flow-universal +81 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/claude-flow.bat +18 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/claude-flow.ps1 +24 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/claude-md.js +982 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/analysis/bottleneck-detect.md +162 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/automation/auto-agent.md +122 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/coordination/swarm-init.md +85 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/github/github-swarm.md +121 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/helpers/standard-checkpoint-hooks.sh +179 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/hooks/notification.md +113 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/hooks/post-command.md +116 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/hooks/post-edit.md +117 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/hooks/post-task.md +112 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/hooks/pre-command.md +113 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md +113 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md +112 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md +111 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/hooks/session-end.md +118 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/hooks/session-restore.md +118 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/commands/hooks/session-start.md +117 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/coordination-md.js +340 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/coordination.md +16 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +2347 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +331 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/github-safe.js +106 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +259 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/readme-files.js +72 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +430 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/settings.json +109 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/sparc-modes.js +1401 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +432 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/verification-claude-md.js +432 -0
- package/.claude-flow-novice/dist/src/slash-commands/benchmark-prompts.js +281 -0
- package/CLAUDE.md +1 -1
- package/package.json +3 -3
- package/src/cli/simple-commands/init/index.js +39 -4
- package/src/cli/simple-commands/init/templates/CLAUDE.md +8 -10
- package/src/slash-commands/benchmark-prompts.js +281 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Memory Bank
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This file serves as a persistent memory bank for important project context that should be retained across sessions.
|
|
5
|
+
|
|
6
|
+
## Project Context
|
|
7
|
+
<!-- Add project-specific information here -->
|
|
8
|
+
|
|
9
|
+
## Key Decisions
|
|
10
|
+
<!-- Document important decisions and their rationale -->
|
|
11
|
+
|
|
12
|
+
## Code Patterns
|
|
13
|
+
<!-- Document established patterns and conventions -->
|
|
14
|
+
|
|
15
|
+
## Session History
|
|
16
|
+
<!-- Track significant session outcomes -->
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// readme-files.js - README templates for various directories
|
|
2
|
+
|
|
3
|
+
export function createAgentsReadme() {
|
|
4
|
+
return `# Agent Memory Storage
|
|
5
|
+
|
|
6
|
+
## Purpose
|
|
7
|
+
This directory stores agent-specific memory data, configurations, and persistent state information for individual Claude agents in the orchestration system.
|
|
8
|
+
|
|
9
|
+
## Structure
|
|
10
|
+
Each agent gets its own subdirectory for isolated memory storage:
|
|
11
|
+
|
|
12
|
+
\`\`\`
|
|
13
|
+
memory/agents/
|
|
14
|
+
├── agent_001/
|
|
15
|
+
│ ├── state.json # Agent state and configuration
|
|
16
|
+
│ ├── knowledge.md # Agent-specific knowledge base
|
|
17
|
+
│ ├── tasks.json # Completed and active tasks
|
|
18
|
+
│ └── calibration.json # Agent-specific calibrations
|
|
19
|
+
├── agent_002/
|
|
20
|
+
│ └── ...
|
|
21
|
+
└── shared/
|
|
22
|
+
├── common_knowledge.md # Shared knowledge across agents
|
|
23
|
+
└── global_config.json # Global agent configurations
|
|
24
|
+
\`\`\`
|
|
25
|
+
|
|
26
|
+
## Usage Guidelines
|
|
27
|
+
1. **Agent Isolation**: Each agent should only read/write to its own directory
|
|
28
|
+
2. **Shared Resources**: Use the \`shared/\` directory for cross-agent information
|
|
29
|
+
3. **State Persistence**: Update state.json whenever agent status changes
|
|
30
|
+
4. **Knowledge Sharing**: Document discoveries in knowledge.md files
|
|
31
|
+
5. **Cleanup**: Remove directories for terminated agents periodically
|
|
32
|
+
|
|
33
|
+
## Last Updated
|
|
34
|
+
${new Date().toISOString()}
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function createSessionsReadme() {
|
|
39
|
+
return `# Session Memory Storage
|
|
40
|
+
|
|
41
|
+
## Purpose
|
|
42
|
+
This directory stores session-based memory data, conversation history, and contextual information for development sessions using the Claude-Flow orchestration system.
|
|
43
|
+
|
|
44
|
+
## Structure
|
|
45
|
+
Sessions are organized by date and session ID for easy retrieval:
|
|
46
|
+
|
|
47
|
+
\`\`\`
|
|
48
|
+
memory/sessions/
|
|
49
|
+
├── 2024-01-10/
|
|
50
|
+
│ ├── session_001/
|
|
51
|
+
│ │ ├── metadata.json # Session metadata and configuration
|
|
52
|
+
│ │ ├── conversation.md # Full conversation history
|
|
53
|
+
│ │ ├── decisions.md # Key decisions and rationale
|
|
54
|
+
│ │ ├── artifacts/ # Generated files and outputs
|
|
55
|
+
│ │ └── coordination_state/ # Coordination system snapshots
|
|
56
|
+
│ └── ...
|
|
57
|
+
└── shared/
|
|
58
|
+
├── patterns.md # Common session patterns
|
|
59
|
+
└── templates/ # Session template files
|
|
60
|
+
\`\`\`
|
|
61
|
+
|
|
62
|
+
## Usage Guidelines
|
|
63
|
+
1. **Session Isolation**: Each session gets its own directory
|
|
64
|
+
2. **Metadata Completeness**: Always fill out session metadata
|
|
65
|
+
3. **Conversation Logging**: Document all significant interactions
|
|
66
|
+
4. **Artifact Organization**: Structure generated files clearly
|
|
67
|
+
5. **State Preservation**: Snapshot coordination state regularly
|
|
68
|
+
|
|
69
|
+
## Last Updated
|
|
70
|
+
${new Date().toISOString()}
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe Hook Patterns - Templates for safe Claude Code hook configurations
|
|
3
|
+
*
|
|
4
|
+
* These patterns prevent infinite loops that could cost thousands of dollars
|
|
5
|
+
* by avoiding recursive hook execution when hooks call 'claude' commands.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* DANGEROUS PATTERN - DO NOT USE
|
|
10
|
+
* This creates an infinite loop that can cost thousands of dollars!
|
|
11
|
+
*/
|
|
12
|
+
export const DANGEROUS_PATTERN_EXAMPLE = {
|
|
13
|
+
name: 'DANGEROUS: Stop hook calling claude command',
|
|
14
|
+
description: '❌ NEVER USE THIS - Creates infinite recursion loop',
|
|
15
|
+
pattern: {
|
|
16
|
+
hooks: {
|
|
17
|
+
Stop: [
|
|
18
|
+
{
|
|
19
|
+
matcher: '',
|
|
20
|
+
hooks: [
|
|
21
|
+
{
|
|
22
|
+
type: 'command',
|
|
23
|
+
command: 'claude -c -p "Update all changes to history.md"',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
problems: [
|
|
31
|
+
'🚨 Creates infinite loop: Stop → claude command → Stop → claude command...',
|
|
32
|
+
'💰 Can cost $3600+ per day by bypassing rate limits',
|
|
33
|
+
'🚫 Makes system unresponsive',
|
|
34
|
+
'⚡ No built-in protection in Claude Code',
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* SAFE PATTERN 1: Flag-based updates
|
|
40
|
+
* Set a flag instead of calling claude directly
|
|
41
|
+
*/
|
|
42
|
+
export const SAFE_FLAG_PATTERN = {
|
|
43
|
+
name: 'Safe Pattern: Flag-based updates',
|
|
44
|
+
description: '✅ Set flag when update needed, run manually',
|
|
45
|
+
pattern: {
|
|
46
|
+
hooks: {
|
|
47
|
+
Stop: [
|
|
48
|
+
{
|
|
49
|
+
matcher: '',
|
|
50
|
+
hooks: [
|
|
51
|
+
{
|
|
52
|
+
type: 'command',
|
|
53
|
+
command:
|
|
54
|
+
'bash -c \'echo "History update needed at $(date)" > ~/.claude/needs_update && echo "📝 History update flagged. Run: claude -c -p \\"Update history.md\\""\'',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
benefits: [
|
|
62
|
+
'✅ No recursion - just sets a flag',
|
|
63
|
+
'💰 Zero risk of infinite API calls',
|
|
64
|
+
'🔄 User controls when update runs',
|
|
65
|
+
'📝 Clear instructions for manual execution',
|
|
66
|
+
],
|
|
67
|
+
usage: [
|
|
68
|
+
'1. Hook sets flag when update is needed',
|
|
69
|
+
'2. User sees notification',
|
|
70
|
+
'3. User manually runs: claude -c -p "Update history.md"',
|
|
71
|
+
'4. Update runs once safely',
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* SAFE PATTERN 2: PostToolUse hooks instead of Stop hooks
|
|
77
|
+
* React to specific tool usage rather than session end
|
|
78
|
+
*/
|
|
79
|
+
export const SAFE_POST_TOOL_PATTERN = {
|
|
80
|
+
name: 'Safe Pattern: PostToolUse hooks',
|
|
81
|
+
description: '✅ React to specific file operations instead of Stop events',
|
|
82
|
+
pattern: {
|
|
83
|
+
hooks: {
|
|
84
|
+
PostToolUse: [
|
|
85
|
+
{
|
|
86
|
+
matcher: 'Write|Edit|MultiEdit',
|
|
87
|
+
hooks: [
|
|
88
|
+
{
|
|
89
|
+
type: 'command',
|
|
90
|
+
command: "echo 'File modified: {file}' >> ~/.claude/modifications.log",
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
benefits: [
|
|
98
|
+
'✅ Only triggers on actual file changes',
|
|
99
|
+
'🎯 More precise than Stop hooks',
|
|
100
|
+
'📝 Logs specific modifications',
|
|
101
|
+
'🔄 No risk of Stop hook recursion',
|
|
102
|
+
],
|
|
103
|
+
usage: [
|
|
104
|
+
'1. Triggers only when files are written/edited',
|
|
105
|
+
'2. Logs the specific file that was modified',
|
|
106
|
+
'3. Can be used for change tracking',
|
|
107
|
+
'4. Safe to use with any logging command',
|
|
108
|
+
],
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* SAFE PATTERN 3: Conditional execution with skip-hooks
|
|
113
|
+
* Check for hook context before executing claude commands
|
|
114
|
+
*/
|
|
115
|
+
export const SAFE_CONDITIONAL_PATTERN = {
|
|
116
|
+
name: 'Safe Pattern: Conditional execution with context check',
|
|
117
|
+
description: '✅ Check if running in hook context before calling claude',
|
|
118
|
+
pattern: {
|
|
119
|
+
hooks: {
|
|
120
|
+
Stop: [
|
|
121
|
+
{
|
|
122
|
+
matcher: '',
|
|
123
|
+
hooks: [
|
|
124
|
+
{
|
|
125
|
+
type: 'command',
|
|
126
|
+
command:
|
|
127
|
+
'bash -c \'if [ -z "$CLAUDE_HOOK_CONTEXT" ]; then claude -c -p "Update history.md" --skip-hooks; else echo "Skipping update - in hook context"; fi\'',
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
benefits: [
|
|
135
|
+
'✅ Checks hook context before execution',
|
|
136
|
+
'🛡️ Uses --skip-hooks flag for safety',
|
|
137
|
+
'🔄 Prevents recursive hook calls',
|
|
138
|
+
'📊 Provides clear feedback',
|
|
139
|
+
],
|
|
140
|
+
usage: [
|
|
141
|
+
'1. Checks CLAUDE_HOOK_CONTEXT environment variable',
|
|
142
|
+
'2. Only runs claude if not in hook context',
|
|
143
|
+
'3. Uses --skip-hooks to prevent triggering more hooks',
|
|
144
|
+
'4. Shows clear message when skipping',
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* SAFE PATTERN 4: Batch processing with scheduled execution
|
|
150
|
+
* Accumulate changes and process them on a schedule
|
|
151
|
+
*/
|
|
152
|
+
export const SAFE_BATCH_PATTERN = {
|
|
153
|
+
name: 'Safe Pattern: Batch processing with scheduled execution',
|
|
154
|
+
description: '✅ Accumulate changes and process them separately',
|
|
155
|
+
pattern: {
|
|
156
|
+
hooks: {
|
|
157
|
+
Stop: [
|
|
158
|
+
{
|
|
159
|
+
matcher: '',
|
|
160
|
+
hooks: [
|
|
161
|
+
{
|
|
162
|
+
type: 'command',
|
|
163
|
+
command: 'echo "$(date): Session ended" >> ~/.claude/session_log.txt',
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
additionalSetup: {
|
|
171
|
+
cronJob: '# Add to crontab (run every hour):\n# 0 * * * * /path/to/update-history.sh',
|
|
172
|
+
updateScript: `#!/bin/bash
|
|
173
|
+
# update-history.sh - Safe batch update script
|
|
174
|
+
LOCK_FILE="~/.claude/update.lock"
|
|
175
|
+
LOG_FILE="~/.claude/session_log.txt"
|
|
176
|
+
|
|
177
|
+
# Check if update is already running
|
|
178
|
+
if [ -f "$LOCK_FILE" ]; then
|
|
179
|
+
echo "Update already in progress"
|
|
180
|
+
exit 1
|
|
181
|
+
fi
|
|
182
|
+
|
|
183
|
+
# Create lock file
|
|
184
|
+
touch "$LOCK_FILE"
|
|
185
|
+
|
|
186
|
+
# Check if there are new sessions to process
|
|
187
|
+
if [ -f "$LOG_FILE" ] && [ -s "$LOG_FILE" ]; then
|
|
188
|
+
echo "Processing accumulated changes..."
|
|
189
|
+
claude -c -p "Update history.md with recent session data" --skip-hooks
|
|
190
|
+
|
|
191
|
+
# Archive the log
|
|
192
|
+
mv "$LOG_FILE" "~/.claude/session_log_$(date +%Y%m%d_%H%M%S).txt"
|
|
193
|
+
fi
|
|
194
|
+
|
|
195
|
+
# Remove lock file
|
|
196
|
+
rm "$LOCK_FILE"`,
|
|
197
|
+
},
|
|
198
|
+
benefits: [
|
|
199
|
+
'✅ No risk of recursion',
|
|
200
|
+
'⏰ Scheduled processing prevents overload',
|
|
201
|
+
'🔒 Lock file prevents concurrent updates',
|
|
202
|
+
'📦 Batches multiple sessions efficiently',
|
|
203
|
+
],
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* SAFE PATTERN 5: Database/file-based queue system
|
|
208
|
+
* Use external queue for processing commands
|
|
209
|
+
*/
|
|
210
|
+
export const SAFE_QUEUE_PATTERN = {
|
|
211
|
+
name: 'Safe Pattern: Queue-based command processing',
|
|
212
|
+
description: '✅ Queue commands for external processing',
|
|
213
|
+
pattern: {
|
|
214
|
+
hooks: {
|
|
215
|
+
Stop: [
|
|
216
|
+
{
|
|
217
|
+
matcher: '',
|
|
218
|
+
hooks: [
|
|
219
|
+
{
|
|
220
|
+
type: 'command',
|
|
221
|
+
command:
|
|
222
|
+
'echo \'{"command": "update-history", "timestamp": "\'$(date -Iseconds)\'", "session": "\'$CLAUDE_SESSION_ID\'"}\' >> ~/.claude/command_queue.jsonl',
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
processor: `#!/usr/bin/env python3
|
|
230
|
+
# queue-processor.py - Safe command queue processor
|
|
231
|
+
import json
|
|
232
|
+
import subprocess
|
|
233
|
+
import time
|
|
234
|
+
import os
|
|
235
|
+
from pathlib import Path
|
|
236
|
+
|
|
237
|
+
QUEUE_FILE = Path.home() / '.claude' / 'command_queue.jsonl'
|
|
238
|
+
PROCESSING_INTERVAL = 300 # 5 minutes
|
|
239
|
+
|
|
240
|
+
def process_queue():
|
|
241
|
+
if not QUEUE_FILE.exists():
|
|
242
|
+
return
|
|
243
|
+
|
|
244
|
+
# Read and clear queue atomically
|
|
245
|
+
with open(QUEUE_FILE, 'r') as f:
|
|
246
|
+
lines = f.readlines()
|
|
247
|
+
|
|
248
|
+
# Clear the queue
|
|
249
|
+
QUEUE_FILE.unlink()
|
|
250
|
+
|
|
251
|
+
# Process commands
|
|
252
|
+
for line in lines:
|
|
253
|
+
try:
|
|
254
|
+
cmd_data = json.loads(line.strip())
|
|
255
|
+
if cmd_data['command'] == 'update-history':
|
|
256
|
+
print(f"Processing history update for session {cmd_data['session']}")
|
|
257
|
+
subprocess.run([
|
|
258
|
+
'claude', '-c', '-p', 'Update history.md', '--skip-hooks'
|
|
259
|
+
], check=True)
|
|
260
|
+
time.sleep(2) # Rate limiting
|
|
261
|
+
except Exception as e:
|
|
262
|
+
print(f"Error processing command: {e}")
|
|
263
|
+
|
|
264
|
+
if __name__ == '__main__':
|
|
265
|
+
while True:
|
|
266
|
+
try:
|
|
267
|
+
process_queue()
|
|
268
|
+
time.sleep(PROCESSING_INTERVAL)
|
|
269
|
+
except KeyboardInterrupt:
|
|
270
|
+
break`,
|
|
271
|
+
benefits: [
|
|
272
|
+
'✅ Complete separation of hook and claude execution',
|
|
273
|
+
'⏰ Rate limited processing',
|
|
274
|
+
'🔄 Handles multiple queued commands',
|
|
275
|
+
'🛡️ No risk of infinite loops',
|
|
276
|
+
],
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Get all safe patterns for documentation generation
|
|
281
|
+
*/
|
|
282
|
+
export const ALL_SAFE_PATTERNS = [
|
|
283
|
+
SAFE_FLAG_PATTERN,
|
|
284
|
+
SAFE_POST_TOOL_PATTERN,
|
|
285
|
+
SAFE_CONDITIONAL_PATTERN,
|
|
286
|
+
SAFE_BATCH_PATTERN,
|
|
287
|
+
SAFE_QUEUE_PATTERN,
|
|
288
|
+
];
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Generate safe hooks documentation
|
|
292
|
+
*/
|
|
293
|
+
export function generateSafeHooksGuide() {
|
|
294
|
+
return `# 🛡️ Safe Hook Patterns for Claude Code
|
|
295
|
+
|
|
296
|
+
⚠️ **CRITICAL WARNING**: Stop hooks that call 'claude' commands create infinite loops that can cost thousands of dollars per day!
|
|
297
|
+
|
|
298
|
+
## 🚨 DANGEROUS PATTERN (NEVER USE)
|
|
299
|
+
|
|
300
|
+
${DANGEROUS_PATTERN_EXAMPLE.description}
|
|
301
|
+
|
|
302
|
+
\`\`\`json
|
|
303
|
+
${JSON.stringify(DANGEROUS_PATTERN_EXAMPLE.pattern, null, 2)}
|
|
304
|
+
\`\`\`
|
|
305
|
+
|
|
306
|
+
**Problems:**
|
|
307
|
+
${DANGEROUS_PATTERN_EXAMPLE.problems.map((p) => `- ${p}`).join('\n')}
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## ✅ SAFE PATTERNS
|
|
312
|
+
|
|
313
|
+
${ALL_SAFE_PATTERNS.map(
|
|
314
|
+
(pattern) => `
|
|
315
|
+
### ${pattern.name}
|
|
316
|
+
|
|
317
|
+
${pattern.description}
|
|
318
|
+
|
|
319
|
+
**Configuration:**
|
|
320
|
+
\`\`\`json
|
|
321
|
+
${JSON.stringify(pattern.pattern, null, 2)}
|
|
322
|
+
\`\`\`
|
|
323
|
+
|
|
324
|
+
**Benefits:**
|
|
325
|
+
${pattern.benefits.map((b) => `- ${b}`).join('\n')}
|
|
326
|
+
|
|
327
|
+
${
|
|
328
|
+
pattern.usage
|
|
329
|
+
? `**Usage:**
|
|
330
|
+
${pattern.usage.map((u, i) => `${i + 1}. ${u}`).join('\n')}`
|
|
331
|
+
: ''
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
${
|
|
335
|
+
pattern.additionalSetup
|
|
336
|
+
? `**Additional Setup:**
|
|
337
|
+
${
|
|
338
|
+
pattern.additionalSetup.cronJob
|
|
339
|
+
? `
|
|
340
|
+
**Cron Job:**
|
|
341
|
+
\`\`\`bash
|
|
342
|
+
${pattern.additionalSetup.cronJob}
|
|
343
|
+
\`\`\`
|
|
344
|
+
`
|
|
345
|
+
: ''
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
${
|
|
349
|
+
pattern.additionalSetup.updateScript
|
|
350
|
+
? `
|
|
351
|
+
**Update Script:**
|
|
352
|
+
\`\`\`bash
|
|
353
|
+
${pattern.additionalSetup.updateScript}
|
|
354
|
+
\`\`\`
|
|
355
|
+
`
|
|
356
|
+
: ''
|
|
357
|
+
}`
|
|
358
|
+
: ''
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
${
|
|
362
|
+
pattern.processor
|
|
363
|
+
? `
|
|
364
|
+
**Queue Processor:**
|
|
365
|
+
\`\`\`python
|
|
366
|
+
${pattern.processor}
|
|
367
|
+
\`\`\`
|
|
368
|
+
`
|
|
369
|
+
: ''
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
`,
|
|
374
|
+
).join('')}
|
|
375
|
+
|
|
376
|
+
## 🚀 Quick Migration Guide
|
|
377
|
+
|
|
378
|
+
### If you currently have this DANGEROUS pattern:
|
|
379
|
+
\`\`\`json
|
|
380
|
+
{
|
|
381
|
+
"hooks": {
|
|
382
|
+
"Stop": [{"hooks": [{"type": "command", "command": "claude -c -p 'Update history'"}]}]
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
\`\`\`
|
|
386
|
+
|
|
387
|
+
### Replace with this SAFE pattern:
|
|
388
|
+
\`\`\`json
|
|
389
|
+
{
|
|
390
|
+
"hooks": {
|
|
391
|
+
"Stop": [{"hooks": [{"type": "command", "command": "touch ~/.claude/needs_update && echo 'Run: claude -c -p \"Update history\"'"}]}]
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
\`\`\`
|
|
395
|
+
|
|
396
|
+
## 🛡️ Hook Safety Tools
|
|
397
|
+
|
|
398
|
+
Use claude-flow's built-in safety tools:
|
|
399
|
+
|
|
400
|
+
\`\`\`bash
|
|
401
|
+
# Check your configuration for dangerous patterns
|
|
402
|
+
claude-flow-novice hook-safety validate
|
|
403
|
+
|
|
404
|
+
# Enable safe mode (skips all hooks)
|
|
405
|
+
claude-flow-novice hook-safety safe-mode
|
|
406
|
+
|
|
407
|
+
# Check current safety status
|
|
408
|
+
claude-flow-novice hook-safety status
|
|
409
|
+
|
|
410
|
+
# Reset circuit breakers if triggered
|
|
411
|
+
claude-flow-novice hook-safety reset
|
|
412
|
+
\`\`\`
|
|
413
|
+
|
|
414
|
+
## 📚 Additional Resources
|
|
415
|
+
|
|
416
|
+
- Issue #166: https://github.com/ruvnet/claude-flow/issues/166
|
|
417
|
+
- Claude Code Hooks Documentation: https://docs.anthropic.com/en/docs/claude-code/hooks
|
|
418
|
+
- Reddit Discussion: https://www.reddit.com/r/ClaudeAI/comments/1ltvi6x/anyone_else_accidentally_create_an_infinite_loop/
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
**Remember**: When in doubt, use flag-based patterns or PostToolUse hooks instead of Stop hooks!
|
|
423
|
+
`;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export default {
|
|
427
|
+
DANGEROUS_PATTERN_EXAMPLE,
|
|
428
|
+
ALL_SAFE_PATTERNS,
|
|
429
|
+
generateSafeHooksGuide,
|
|
430
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"CLAUDE_FLOW_AUTO_COMMIT": "false",
|
|
4
|
+
"CLAUDE_FLOW_AUTO_PUSH": "false",
|
|
5
|
+
"CLAUDE_FLOW_HOOKS_ENABLED": "true",
|
|
6
|
+
"CLAUDE_FLOW_TELEMETRY_ENABLED": "true",
|
|
7
|
+
"CLAUDE_FLOW_REMOTE_EXECUTION": "true",
|
|
8
|
+
"CLAUDE_FLOW_CHECKPOINTS_ENABLED": "true"
|
|
9
|
+
},
|
|
10
|
+
"permissions": {
|
|
11
|
+
"allow": [
|
|
12
|
+
"Bash(npx claude-flow-novice *)",
|
|
13
|
+
"Bash(npm run lint)",
|
|
14
|
+
"Bash(npm run test:*)",
|
|
15
|
+
"Bash(npm test *)",
|
|
16
|
+
"Bash(git status)",
|
|
17
|
+
"Bash(git diff *)",
|
|
18
|
+
"Bash(git log *)",
|
|
19
|
+
"Bash(git add *)",
|
|
20
|
+
"Bash(git commit *)",
|
|
21
|
+
"Bash(git push)",
|
|
22
|
+
"Bash(git config *)",
|
|
23
|
+
"Bash(git tag *)",
|
|
24
|
+
"Bash(git branch *)",
|
|
25
|
+
"Bash(git checkout *)",
|
|
26
|
+
"Bash(git stash *)",
|
|
27
|
+
"Bash(jq *)",
|
|
28
|
+
"Bash(node *)",
|
|
29
|
+
"Bash(which *)",
|
|
30
|
+
"Bash(pwd)",
|
|
31
|
+
"Bash(ls *)"
|
|
32
|
+
],
|
|
33
|
+
"deny": ["Bash(rm -rf /)", "Bash(curl * | bash)", "Bash(wget * | sh)", "Bash(eval *)"]
|
|
34
|
+
},
|
|
35
|
+
"hooks": {
|
|
36
|
+
"PreToolUse": [
|
|
37
|
+
{
|
|
38
|
+
"matcher": "Bash",
|
|
39
|
+
"hooks": [
|
|
40
|
+
{
|
|
41
|
+
"type": "command",
|
|
42
|
+
"command": "cat | jq -r '.tool_input.command // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks pre-command --command '{}' --validate-safety true --prepare-resources true"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"matcher": "Write|Edit|MultiEdit",
|
|
48
|
+
"hooks": [
|
|
49
|
+
{
|
|
50
|
+
"type": "command",
|
|
51
|
+
"command": "cat | jq -r '.tool_input.file_path // .tool_input.path // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks pre-edit --file '{}' --auto-assign-agents true --load-context true"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"PostToolUse": [
|
|
57
|
+
{
|
|
58
|
+
"matcher": "Bash",
|
|
59
|
+
"hooks": [
|
|
60
|
+
{
|
|
61
|
+
"type": "command",
|
|
62
|
+
"command": "cat | jq -r '.tool_input.command // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks post-command --command '{}' --track-metrics true --store-results true"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"matcher": "Write|Edit|MultiEdit",
|
|
68
|
+
"hooks": [
|
|
69
|
+
{
|
|
70
|
+
"type": "command",
|
|
71
|
+
"command": "cat | jq -r '.tool_input.file_path // .tool_input.path // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks post-edit --file '{}' --format true --update-memory true"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"PreCompact": [
|
|
77
|
+
{
|
|
78
|
+
"matcher": "manual",
|
|
79
|
+
"hooks": [
|
|
80
|
+
{
|
|
81
|
+
"type": "command",
|
|
82
|
+
"command": "/bin/bash -c 'INPUT=$(cat); CUSTOM=$(echo \"$INPUT\" | jq -r \".custom_instructions // \\\"\\\"\"); echo \"🔄 PreCompact Guidance:\"; echo \"📋 IMPORTANT: Review CLAUDE.md in project root for:\"; echo \" • 54 available agents and concurrent usage patterns\"; echo \" • Swarm coordination strategies (hierarchical, mesh, adaptive)\"; echo \" • SPARC methodology workflows with batchtools optimization\"; echo \" • Critical concurrent execution rules (GOLDEN RULE: 1 MESSAGE = ALL OPERATIONS)\"; if [ -n \"$CUSTOM\" ]; then echo \"🎯 Custom compact instructions: $CUSTOM\"; fi; echo \"✅ Ready for compact operation\"'"
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"matcher": "auto",
|
|
88
|
+
"hooks": [
|
|
89
|
+
{
|
|
90
|
+
"type": "command",
|
|
91
|
+
"command": "/bin/bash -c 'echo \"🔄 Auto-Compact Guidance (Context Window Full):\"; echo \"📋 CRITICAL: Before compacting, ensure you understand:\"; echo \" • All 54 agents available in .claude/agents/ directory\"; echo \" • Concurrent execution patterns from CLAUDE.md\"; echo \" • Batchtools optimization for 300% performance gains\"; echo \" • Swarm coordination strategies for complex tasks\"; echo \"⚡ Apply GOLDEN RULE: Always batch operations in single messages\"; echo \"✅ Auto-compact proceeding with full agent context\"'"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"Stop": [
|
|
97
|
+
{
|
|
98
|
+
"hooks": [
|
|
99
|
+
{
|
|
100
|
+
"type": "command",
|
|
101
|
+
"command": "npx claude-flow@alpha hooks session-end --generate-summary true --persist-state true --export-metrics true"
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"includeCoAuthoredBy": true,
|
|
108
|
+
"enabledMcpjsonServers": ["claude-flow", "ruv-swarm"]
|
|
109
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"pre-task": ".claude/commands/hooks/pre-task.md",
|
|
4
|
+
"post-task": ".claude/commands/hooks/post-task.md",
|
|
5
|
+
"pre-edit": ".claude/commands/hooks/pre-edit.md",
|
|
6
|
+
"post-edit": ".claude/commands/hooks/post-edit.md",
|
|
7
|
+
"session-start": ".claude/commands/hooks/session-start.md",
|
|
8
|
+
"session-end": ".claude/commands/hooks/session-end.md"
|
|
9
|
+
},
|
|
10
|
+
"permissions": {
|
|
11
|
+
"allow": ["mcp__ruv-swarm", "mcp__claude-flow"],
|
|
12
|
+
"autoApprove": {
|
|
13
|
+
"mcp__ruv-swarm": ["*"],
|
|
14
|
+
"mcp__claude-flow": ["*"]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"mcpServers": {
|
|
18
|
+
"claude-flow": {
|
|
19
|
+
"command": "npx",
|
|
20
|
+
"args": ["claude-flow@alpha", "mcp", "start"],
|
|
21
|
+
"type": "stdio"
|
|
22
|
+
},
|
|
23
|
+
"ruv-swarm": {
|
|
24
|
+
"command": "npx",
|
|
25
|
+
"args": ["ruv-swarm@latest", "mcp", "start"],
|
|
26
|
+
"type": "stdio"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"features": {
|
|
30
|
+
"hooks": true,
|
|
31
|
+
"mcpIntegration": true,
|
|
32
|
+
"autoCompletion": true,
|
|
33
|
+
"commandPalette": true
|
|
34
|
+
}
|
|
35
|
+
}
|