claude-all-config 2.0.0

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.
Files changed (167) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE.md +70 -0
  3. package/README.md +133 -0
  4. package/VERSION +1 -0
  5. package/agents/accessibility-reviewer.md +96 -0
  6. package/agents/ai-prompt-optimizer.md +94 -0
  7. package/agents/api-tester.md +102 -0
  8. package/agents/code-generator.md +94 -0
  9. package/agents/code-reviewer.md +47 -0
  10. package/agents/component-generator.md +102 -0
  11. package/agents/doc-generator.md +91 -0
  12. package/agents/migration-generator.md +94 -0
  13. package/agents/performance-analyzer.md +90 -0
  14. package/agents/proactive-mode.md +91 -0
  15. package/agents/readme-generator.md +101 -0
  16. package/agents/security-auditor.md +86 -0
  17. package/agents/terraform-generator.md +94 -0
  18. package/agents/test-generator.md +76 -0
  19. package/bin/agentrouter.json +36 -0
  20. package/bin/ai-chat +20 -0
  21. package/bin/antigravity.json +76 -0
  22. package/bin/api-manager +340 -0
  23. package/bin/claude-launcher +19 -0
  24. package/bin/claude-master +15 -0
  25. package/bin/claude_master.py +295 -0
  26. package/bin/cohere.json +7 -0
  27. package/bin/deepseek.json +44 -0
  28. package/bin/gemini.json +56 -0
  29. package/bin/glm.json +21 -0
  30. package/bin/groq.json +41 -0
  31. package/bin/minimax.json +26 -0
  32. package/bin/mistral.json +7 -0
  33. package/bin/moonshot.json +7 -0
  34. package/bin/ollama.json +36 -0
  35. package/bin/openai.json +46 -0
  36. package/bin/openrouter.json +38 -0
  37. package/bin/perplexity.json +12 -0
  38. package/bin/qwen.json +7 -0
  39. package/bin/switch-provider +73 -0
  40. package/bin/test.json +7 -0
  41. package/bin/xai.json +41 -0
  42. package/claude-all +2707 -0
  43. package/claude-config.json +340 -0
  44. package/claude-suite/REFACTORING_SUMMARY.md +88 -0
  45. package/claude-suite/auth/.antigravity_proxy.py +78 -0
  46. package/claude-suite/auth/__pycache__/openai_auth.cpython-312.pyc +0 -0
  47. package/claude-suite/auth/gemini_auth.py +80 -0
  48. package/claude-suite/auth/openai_auth.py +138 -0
  49. package/claude-suite/backups/claude-all-before-refactor +1075 -0
  50. package/claude-suite/backups/claude-all.backup +840 -0
  51. package/claude-suite/backups/claude-all.original +840 -0
  52. package/claude-suite/models/add-model-manual.sh +588 -0
  53. package/claude-suite/models/add-model.sh +114 -0
  54. package/claude-suite/models/model-switcher.sh +69 -0
  55. package/claude-suite/providers/claude-glm +89 -0
  56. package/claude-suite/providers/claude-glm-wrapper.sh +55 -0
  57. package/claude-suite/providers/claude-minimax +12 -0
  58. package/claude-suite/providers/claude-smart +132 -0
  59. package/claude-suite/providers/xai_chat.sh +56 -0
  60. package/claude-suite/utils/__pycache__/claude_master.cpython-312.pyc +0 -0
  61. package/claude-suite/utils/antigravity_proxy_server.py +168 -0
  62. package/claude-suite/utils/claude-all-help.txt +83 -0
  63. package/claude-suite/utils/claude_master.py +408 -0
  64. package/commands/brainstorm.md +5 -0
  65. package/commands/execute-plan.md +5 -0
  66. package/commands/write-plan.md +5 -0
  67. package/docs/ANTIGRAVITY-SETUP.md +176 -0
  68. package/docs/AUTH_CREDENTIALS.md +54 -0
  69. package/docs/NPM-INSTALLATION.md +166 -0
  70. package/hooks/hooks.json +15 -0
  71. package/hooks/run-hook.cmd +19 -0
  72. package/hooks/session-start.sh +52 -0
  73. package/install.sh +155 -0
  74. package/mcp.json +34 -0
  75. package/model/perplexity.json +12 -0
  76. package/package.json +69 -0
  77. package/plugins/README.md +47 -0
  78. package/plugins/installed_plugins.json +317 -0
  79. package/plugins/known_marketplaces.json +10 -0
  80. package/plugins/marketplace-info/marketplace.json +517 -0
  81. package/postinstall.js +100 -0
  82. package/scripts/antigravity_proxy_server.py +168 -0
  83. package/scripts/get_gemini_api_key.py +96 -0
  84. package/scripts/setup_antigravity_auth.py +171 -0
  85. package/skills/api-development/SKILL.md +11 -0
  86. package/skills/api-development/openapi/api-documentation.yaml +108 -0
  87. package/skills/brainstorming/SKILL.md +54 -0
  88. package/skills/code-quality/SKILL.md +196 -0
  89. package/skills/condition-based-waiting/SKILL.md +120 -0
  90. package/skills/condition-based-waiting/example.ts +158 -0
  91. package/skills/database-development/SKILL.md +11 -0
  92. package/skills/database-development/migrations/migration.template.sql +49 -0
  93. package/skills/defense-in-depth/SKILL.md +127 -0
  94. package/skills/deployment/SKILL.md +11 -0
  95. package/skills/deployment/ci-cd/github-actions.yml +95 -0
  96. package/skills/deployment/docker/Dockerfile.template +39 -0
  97. package/skills/dispatching-parallel-agents/SKILL.md +180 -0
  98. package/skills/documentation-generation/SKILL.md +8 -0
  99. package/skills/documentation-generation/templates/README.template.md +60 -0
  100. package/skills/error-handling/SKILL.md +267 -0
  101. package/skills/executing-plans/SKILL.md +76 -0
  102. package/skills/finishing-a-development-branch/SKILL.md +200 -0
  103. package/skills/frontend-design/frontend-design/SKILL.md +42 -0
  104. package/skills/integration-testing/SKILL.md +13 -0
  105. package/skills/integration-testing/examples/contract-test.py +317 -0
  106. package/skills/integration-testing/examples/e2e-test.js +147 -0
  107. package/skills/integration-testing/examples/test-isolation.md +94 -0
  108. package/skills/logging-monitoring/SKILL.md +66 -0
  109. package/skills/mobile-development/SKILL.md +11 -0
  110. package/skills/mobile-development/responsive/responsive.css +80 -0
  111. package/skills/performance-optimization/SKILL.md +9 -0
  112. package/skills/performance-optimization/profiling/profile.template.js +21 -0
  113. package/skills/receiving-code-review/SKILL.md +209 -0
  114. package/skills/refactoring/SKILL.md +11 -0
  115. package/skills/refactoring/code-smells/common-smells.md +115 -0
  116. package/skills/requesting-code-review/SKILL.md +105 -0
  117. package/skills/requesting-code-review/code-reviewer.md +146 -0
  118. package/skills/root-cause-tracing/SKILL.md +174 -0
  119. package/skills/root-cause-tracing/find-polluter.sh +63 -0
  120. package/skills/security-review/SKILL.md +11 -0
  121. package/skills/security-review/checklists/owasp-checklist.md +31 -0
  122. package/skills/sharing-skills/SKILL.md +194 -0
  123. package/skills/subagent-driven-development/SKILL.md +240 -0
  124. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +20 -0
  125. package/skills/subagent-driven-development/implementer-prompt.md +78 -0
  126. package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  127. package/skills/systematic-debugging/CREATION-LOG.md +119 -0
  128. package/skills/systematic-debugging/SKILL.md +295 -0
  129. package/skills/systematic-debugging/test-academic.md +14 -0
  130. package/skills/systematic-debugging/test-pressure-1.md +58 -0
  131. package/skills/systematic-debugging/test-pressure-2.md +68 -0
  132. package/skills/systematic-debugging/test-pressure-3.md +69 -0
  133. package/skills/test-driven-development/SKILL.md +364 -0
  134. package/skills/testing-anti-patterns/SKILL.md +302 -0
  135. package/skills/testing-skills-with-subagents/SKILL.md +387 -0
  136. package/skills/testing-skills-with-subagents/examples/CLAUDE_MD_TESTING.md +189 -0
  137. package/skills/ui-ux-review/SKILL.md +13 -0
  138. package/skills/ui-ux-review/checklists/ux-heuristics.md +61 -0
  139. package/skills/using-git-worktrees/SKILL.md +213 -0
  140. package/skills/using-superpowers/SKILL.md +101 -0
  141. package/skills/verification-before-completion/SKILL.md +139 -0
  142. package/skills/writing-plans/SKILL.md +116 -0
  143. package/skills/writing-skills/SKILL.md +622 -0
  144. package/skills/writing-skills/anthropic-best-practices.md +1150 -0
  145. package/skills/writing-skills/graphviz-conventions.dot +172 -0
  146. package/skills/writing-skills/persuasion-principles.md +187 -0
  147. package/update.sh +36 -0
  148. package/utils/check-superpowers.sh +114 -0
  149. package/utils/claude-branding.md +166 -0
  150. package/utils/config.js +185 -0
  151. package/utils/custom-claude-config.sh +89 -0
  152. package/utils/custom-claude-hooks.md +129 -0
  153. package/utils/custom-claude-lib.js +222 -0
  154. package/utils/customize-claude-ui.sh +162 -0
  155. package/utils/fix-claude-integration.sh +133 -0
  156. package/utils/help.js +125 -0
  157. package/utils/install-curl.ps1 +135 -0
  158. package/utils/install-curl.sh +525 -0
  159. package/utils/install-superpowers.js +411 -0
  160. package/utils/install.js +298 -0
  161. package/utils/install.sh +182 -0
  162. package/utils/postinstall.js +63 -0
  163. package/utils/rename-claude.sh +96 -0
  164. package/utils/uninstall-superpowers.js +273 -0
  165. package/utils/uninstall.ps1 +136 -0
  166. package/utils/uninstall.sh +163 -0
  167. package/utils/update.sh +160 -0
@@ -0,0 +1,185 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * 🤖 Claude-All Configuration Manager
5
+ */
6
+
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const readline = require('readline');
10
+
11
+ class ConfigManager {
12
+ constructor() {
13
+ this.homeDir = require('os').homedir();
14
+ this.configDir = path.join(this.homeDir, '.claude-all', 'config');
15
+ this.configFile = path.join(this.configDir, 'config.json');
16
+ this.rl = readline.createInterface({
17
+ input: process.stdin,
18
+ output: process.stdout
19
+ });
20
+ }
21
+
22
+ async question(prompt) {
23
+ return new Promise((resolve) => {
24
+ this.rl.question(prompt, resolve);
25
+ });
26
+ }
27
+
28
+ loadConfig() {
29
+ if (fs.existsSync(this.configFile)) {
30
+ return JSON.parse(fs.readFileSync(this.configFile, 'utf8'));
31
+ }
32
+ return this.getDefaultConfig();
33
+ }
34
+
35
+ getDefaultConfig() {
36
+ return {
37
+ version: "8.1.0",
38
+ providers: {
39
+ minimax: {
40
+ name: "MiniMax",
41
+ enabled: true,
42
+ endpoint: "https://api.minimax.chat/v1",
43
+ models: ["abab6.5", "abab6.5s", "abab5.5"],
44
+ api_key: ""
45
+ },
46
+ gemini: {
47
+ name: "Google Gemini",
48
+ enabled: true,
49
+ endpoint: "https://generativelanguage.googleapis.com/v1beta",
50
+ models: ["gemini-pro", "gemini-pro-vision"],
51
+ api_key: ""
52
+ },
53
+ openai: {
54
+ name: "OpenAI",
55
+ enabled: true,
56
+ endpoint: "https://api.openai.com/v1",
57
+ models: ["gpt-4", "gpt-3.5-turbo"],
58
+ api_key: ""
59
+ },
60
+ groq: {
61
+ name: "Groq",
62
+ enabled: true,
63
+ endpoint: "https://api.groq.com/openai/v1",
64
+ models: ["llama-3.1-70b-versatile", "mixtral-8x7b-32768"],
65
+ api_key: ""
66
+ }
67
+ },
68
+ ui: {
69
+ theme: "default",
70
+ auto_save: true,
71
+ history_size: 1000
72
+ },
73
+ default_provider: "minimax"
74
+ };
75
+ }
76
+
77
+ async setupProvider(providerName, providerConfig) {
78
+ console.log(`\n🔧 Configuring ${providerConfig.name}...`);
79
+
80
+ const enable = await this.question(`Enable ${providerConfig.name}? (Y/n): `);
81
+ providerConfig.enabled = enable.toLowerCase() !== 'n';
82
+
83
+ if (providerConfig.enabled) {
84
+ const apiKey = await this.question('Enter API key (leave empty for environment variable): ');
85
+ providerConfig.api_key = apiKey;
86
+
87
+ if (providerConfig.models.length > 1) {
88
+ console.log('Available models:');
89
+ providerConfig.models.forEach((model, i) => {
90
+ console.log(` ${i + 1}. ${model}`);
91
+ });
92
+
93
+ const modelChoice = await this.question('Select model (number or name): ');
94
+ providerConfig.default_model = providerConfig.models[modelChoice - 1] || modelChoice;
95
+ }
96
+ }
97
+ }
98
+
99
+ async interactiveSetup() {
100
+ console.log('🤖 Claude-All Configuration Setup');
101
+ console.log('==================================');
102
+
103
+ let config = this.loadConfig();
104
+
105
+ for (const [key, provider] of Object.entries(config.providers)) {
106
+ await this.setupProvider(key, provider);
107
+ }
108
+
109
+ // Set default provider
110
+ const enabledProviders = Object.entries(config.providers)
111
+ .filter(([_, p]) => p.enabled)
112
+ .map(([k, _]) => k);
113
+
114
+ if (enabledProviders.length > 0) {
115
+ console.log('\nAvailable providers:');
116
+ enabledProviders.forEach((p, i) => {
117
+ console.log(` ${i + 1}. ${config.providers[p].name}`);
118
+ });
119
+
120
+ const defaultChoice = await this.question('Select default provider (number): ');
121
+ config.default_provider = enabledProviders[defaultChoice - 1];
122
+ }
123
+
124
+ // UI settings
125
+ console.log('\n🎨 UI Configuration');
126
+ const theme = await this.question('Theme (default/dark/light): ') || 'default';
127
+ config.ui.theme = theme;
128
+
129
+ const autoSave = await this.question('Enable auto-save? (Y/n): ');
130
+ config.ui.auto_save = autoSave.toLowerCase() !== 'n';
131
+
132
+ // Save configuration
133
+ fs.writeFileSync(this.configFile, JSON.stringify(config, null, 2));
134
+
135
+ console.log('\n✅ Configuration saved!');
136
+ console.log(`📁 Location: ${this.configFile}`);
137
+ }
138
+
139
+ showCurrentConfig() {
140
+ const config = this.loadConfig();
141
+
142
+ console.log('⚙️ Current Configuration');
143
+ console.log('========================');
144
+ console.log(`Version: ${config.version}`);
145
+ console.log(`Default Provider: ${config.default_provider}`);
146
+ console.log('');
147
+
148
+ console.log('🔌 Providers:');
149
+ for (const [key, provider] of Object.entries(config.providers)) {
150
+ const status = provider.enabled ? '✅' : '❌';
151
+ const keyStatus = provider.api_key ? '🔑' : '❌';
152
+ console.log(` ${status} ${keyStatus} ${provider.name}`);
153
+ if (provider.default_model) {
154
+ console.log(` Default: ${provider.default_model}`);
155
+ }
156
+ }
157
+
158
+ console.log('\n🎨 UI Settings:');
159
+ console.log(` Theme: ${config.ui.theme}`);
160
+ console.log(` Auto-save: ${config.ui.auto_save ? 'Enabled' : 'Disabled'}`);
161
+ }
162
+
163
+ async run() {
164
+ const mode = process.argv[2] || 'interactive';
165
+
166
+ if (mode === 'show') {
167
+ this.showCurrentConfig();
168
+ } else if (mode === 'interactive') {
169
+ await this.interactiveSetup();
170
+ } else {
171
+ console.log('Usage: npm run config [show|interactive]');
172
+ console.log(' show - Show current configuration');
173
+ console.log(' interactive - Interactive setup wizard');
174
+ }
175
+ }
176
+ }
177
+
178
+ if (require.main === module) {
179
+ const config = new ConfigManager();
180
+ config.run().finally(() => {
181
+ config.rl.close();
182
+ });
183
+ }
184
+
185
+ module.exports = ConfigManager;
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Custom Claude Configuration Script
4
+ # Add custom permissions and features to Claude
5
+
6
+ echo "🔧 Configuring Custom Claude Features..."
7
+
8
+ CLAUDE_DIR="$HOME/.claude"
9
+ SETTINGS_FILE="$CLAUDE_DIR/settings.json"
10
+
11
+ # Backup original settings
12
+ cp "$SETTINGS_FILE" "$SETTINGS_FILE.backup.$(date +%Y%m%d)"
13
+
14
+ # Add custom permissions for enhanced functionality
15
+ cat << 'EOF' > /tmp/custom_permissions.json
16
+ {
17
+ "permissions": {
18
+ "allow": [
19
+ "Bash(*/node_modules/.bin/*)",
20
+ "Bash(*/dist/*)",
21
+ "Bash(python3 -m venv*)",
22
+ "Bash(docker compose*)",
23
+ "Bash(kubectl*)",
24
+ "Bash(helm*)",
25
+ "Bash(terraform*)",
26
+ "Bash(aws*)",
27
+ "Bash(gcloud*)",
28
+ "Bash(az*)",
29
+ "WebFetch(domain:*api.*)",
30
+ "WebFetch(domain:*docs.*)",
31
+ "WebFetch(domain:*raw.githubusercontent.com)",
32
+ "Bash(jest*)",
33
+ "Bash(python3 -m pytest*)",
34
+ "Bash(python3 -m pip install*)",
35
+ "Bash(yarn*)",
36
+ "Bash(pnpm*)",
37
+ "Bash(npx --yes*)",
38
+ "Bash(cargo*)",
39
+ "Bash(rustc*)"
40
+ ]
41
+ },
42
+ "env": {
43
+ "CLAUDE_CONTEXT_SIZE": "200000",
44
+ "CLAUDE_TEMPERATURE": "0.7",
45
+ "CLAUDE_MAX_TOKENS": "8192",
46
+ "CLAUDE_ENABLE_TOOLS": "true"
47
+ },
48
+ "features": {
49
+ "enhanced_file_history": true,
50
+ "project_context": true,
51
+ "auto_save_session": true,
52
+ "debug_mode": false,
53
+ "custom_templates": true
54
+ }
55
+ }
56
+ EOF
57
+
58
+ # Merge with existing settings
59
+ node -e "
60
+ const fs = require('fs');
61
+ const settings = JSON.parse(fs.readFileSync('$SETTINGS_FILE', 'utf8'));
62
+ const custom = JSON.parse(fs.readFileSync('/tmp/custom_permissions.json', 'utf8'));
63
+
64
+ // Merge permissions
65
+ settings.permissions.allow = [...new Set([...settings.permissions.allow, ...custom.permissions.allow])];
66
+
67
+ // Add or update env
68
+ settings.env = {...settings.env, ...custom.env};
69
+
70
+ // Add features
71
+ settings.features = {...settings.features, ...custom.features};
72
+
73
+ fs.writeFileSync('$SETTINGS_FILE', JSON.stringify(settings, null, 2));
74
+ console.log('Settings updated successfully!');
75
+ "
76
+
77
+ # Clean up
78
+ rm -f /tmp/custom_permissions.json
79
+
80
+ echo "✅ Custom Claude configuration updated!"
81
+ echo ""
82
+ echo "📋 Added Features:"
83
+ echo " • Extended CLI tool permissions (npm, yarn, pnpm, cargo, etc.)"
84
+ echo " • Cloud provider CLI support (aws, gcloud, az)"
85
+ echo " • Enhanced API fetching capabilities"
86
+ echo " • Testing framework support (jest, pytest)"
87
+ echo " • Docker/Kubernetes support"
88
+ echo " • Custom environment variables"
89
+ echo " • Feature flags for enhanced functionality"
@@ -0,0 +1,129 @@
1
+ # Custom Claude Hooks Guide
2
+
3
+ ## Available Hook Events
4
+
5
+ ### 1. SessionStart Hook
6
+ Already implemented for Superpowers. Location: `~/.claude/hooks/session-start.sh`
7
+
8
+ ### 2. PreToolUse Hook
9
+ Triggered before any tool is used.
10
+
11
+ **Example: `~/.claude/hooks/pre-tool-use.sh`**
12
+ ```bash
13
+ #!/bin/bash
14
+ # Log all tool usage
15
+ echo "$(date): Using tool $1 with args: $2" >> ~/.claude/tool-usage.log
16
+ ```
17
+
18
+ ### 3. PostToolUse Hook
19
+ Triggered after tool execution.
20
+
21
+ **Example: `~/.claude/hooks/post-tool-use.sh`**
22
+ ```bash
23
+ #!/bin/bash
24
+ # Auto-commit changes after file operations
25
+ if [[ "$1" == "Write" || "$1" == "Edit" ]]; then
26
+ git add -A 2>/dev/null || true
27
+ fi
28
+ ```
29
+
30
+ ### 4. SessionEnd Hook
31
+ Triggered when Claude session ends.
32
+
33
+ **Example: `~/.claude/hooks/session-end.sh`**
34
+ ```bash
35
+ #!/bin/bash
36
+ # Clean up temporary files
37
+ rm -rf /tmp/claude-* 2>/dev/null || true
38
+ # Save session summary
39
+ echo "Session ended at $(date)" >> ~/.claude/session-history.log
40
+ ```
41
+
42
+ ### 5. UserPromptSubmit Hook
43
+ Triggered before processing user input.
44
+
45
+ **Example: `~/.claude/hooks/user-prompt-submit.sh`**
46
+ ```bash
47
+ #!/bin/bash
48
+ # Auto-correct common typos
49
+ echo "$1" | sed 's/claude-all/claude/g'
50
+ ```
51
+
52
+ ### 6. Stop Hook
53
+ Triggered on graceful shutdown.
54
+
55
+ **Example: `~/.claude/hooks/stop.sh`**
56
+ ```bash
57
+ #!/bin/bash
58
+ # Backup important files
59
+ cp ~/.claude/history.jsonl ~/.claude/backups/history-$(date +%Y%m%d).jsonl
60
+ ```
61
+
62
+ ## Installing Custom Hooks
63
+
64
+ 1. Create hook script in `~/.claude/hooks/`
65
+ 2. Make it executable: `chmod +x hook-name.sh`
66
+ 3. Update hooks.json:
67
+
68
+ ```json
69
+ {
70
+ "hooks": {
71
+ "SessionStart": "session-start.sh",
72
+ "PreToolUse": "pre-tool-use.sh",
73
+ "PostToolUse": "post-tool-use.sh",
74
+ "SessionEnd": "session-end.sh",
75
+ "UserPromptSubmit": "user-prompt-submit.sh",
76
+ "Stop": "stop.sh"
77
+ }
78
+ }
79
+ ```
80
+
81
+ ## Hook Return Format
82
+
83
+ Hooks should return JSON output:
84
+
85
+ ```json
86
+ {
87
+ "hookSpecificOutput": {
88
+ "hookEventName": "EventName",
89
+ "additionalContext": "Additional context for Claude",
90
+ "modifications": {
91
+ "settings": {...},
92
+ "environment": {...}
93
+ }
94
+ }
95
+ }
96
+ ```
97
+
98
+ ## Advanced Hook Ideas
99
+
100
+ ### Auto-Save Hook
101
+ ```bash
102
+ # Auto-save work every 10 minutes
103
+ #!/bin/bash
104
+ if [[ $(($(date +%s) % 600)) -lt 5 ]]; then
105
+ echo "Auto-saving session..."
106
+ # Add save logic here
107
+ fi
108
+ ```
109
+
110
+ ### Context Enhancement Hook
111
+ ```bash
112
+ # Add project context
113
+ if [[ -f "project.md" ]]; then
114
+ echo -e "\n<project-context>\n$(cat project.md)\n</project-context>"
115
+ fi
116
+ ```
117
+
118
+ ### Performance Monitoring Hook
119
+ ```bash
120
+ # Log performance metrics
121
+ echo "$(date),$1,$(($(date +%s%N)/1000000))" >> ~/.claude/performance.log
122
+ ```
123
+
124
+ ## Security Notes
125
+
126
+ - Hooks run with your user permissions
127
+ - Validate all hook inputs
128
+ - Avoid executing arbitrary commands from hook input
129
+ - Keep hooks simple and focused
@@ -0,0 +1,222 @@
1
+ // Custom Claude Library Functions
2
+ // Save to ~/.claude/lib/custom-utils.js
3
+
4
+ // Utility functions for Claude to use
5
+ module.exports = {
6
+ // File operations
7
+ async countLines(filePath) {
8
+ const fs = require('fs').promises;
9
+ try {
10
+ const content = await fs.readFile(filePath, 'utf8');
11
+ return content.split('\n').length;
12
+ } catch (error) {
13
+ return 0;
14
+ }
15
+ },
16
+
17
+ // Project analysis
18
+ async analyzeProject(directory) {
19
+ const fs = require('fs').promises;
20
+ const path = require('path');
21
+
22
+ const stats = {
23
+ files: 0,
24
+ directories: 0,
25
+ extensions: {},
26
+ totalLines: 0
27
+ };
28
+
29
+ async function walk(dir) {
30
+ const items = await fs.readdir(dir);
31
+ for (const item of items) {
32
+ const fullPath = path.join(dir, item);
33
+ const stat = await fs.stat(fullPath);
34
+
35
+ if (stat.isDirectory()) {
36
+ stats.directories++;
37
+ await walk(fullPath);
38
+ } else {
39
+ stats.files++;
40
+ const ext = path.extname(item).toLowerCase();
41
+ stats.extensions[ext] = (stats.extensions[ext] || 0) + 1;
42
+
43
+ // Count lines for text files
44
+ const textExtensions = ['.js', '.ts', '.py', '.java', '.cpp', '.c', '.md', '.txt', '.json', '.yaml', '.yml'];
45
+ if (textExtensions.includes(ext)) {
46
+ stats.totalLines += await this.countLines(fullPath);
47
+ }
48
+ }
49
+ }
50
+ }
51
+
52
+ await walk(directory);
53
+ return stats;
54
+ },
55
+
56
+ // Generate project summary
57
+ generateProjectSummary(stats) {
58
+ const sortedExts = Object.entries(stats.extensions)
59
+ .sort((a, b) => b[1] - a[1])
60
+ .slice(0, 5)
61
+ .map(([ext, count]) => `${ext} (${count})`)
62
+ .join(', ');
63
+
64
+ return `
65
+ Project Analysis:
66
+ - Files: ${stats.files}
67
+ - Directories: ${stats.directories}
68
+ - Total Lines: ${stats.totalLines}
69
+ - Top Extensions: ${sortedExts}
70
+ `.trim();
71
+ },
72
+
73
+ // Template generators
74
+ generateReadme(projectName, type = 'general') {
75
+ const templates = {
76
+ api: `# ${projectName} API
77
+
78
+ ## Installation
79
+ \`\`\`bash
80
+ npm install
81
+ \`\`\`
82
+
83
+ ## Usage
84
+ \`\`\`javascript
85
+ const API = require('${projectName}');
86
+ const api = new API();
87
+ \`\`\`
88
+
89
+ ## Endpoints
90
+ - GET /api/items
91
+ - POST /api/items
92
+ - PUT /api/items/:id
93
+ - DELETE /api/items/:id
94
+ `,
95
+
96
+ cli: `# ${projectName} CLI Tool
97
+
98
+ ## Installation
99
+ \`\`\`bash
100
+ npm install -g ${projectName}
101
+ \`\`\`
102
+
103
+ ## Usage
104
+ \`\`\`bash
105
+ ${projectName} --help
106
+ ${projectName} --version
107
+ \`\`\`
108
+ `,
109
+
110
+ general: `# ${projectName}
111
+
112
+ ## Description
113
+ TODO: Add project description
114
+
115
+ ## Installation
116
+ \`\`\`bash
117
+ npm install
118
+ \`\`\`
119
+
120
+ ## Usage
121
+ TODO: Add usage instructions
122
+ `
123
+ };
124
+
125
+ return templates[type] || templates.general;
126
+ },
127
+
128
+ // Git helpers
129
+ async getGitStats() {
130
+ const { exec } = require('child_process');
131
+ const { promisify } = require('util');
132
+ const execAsync = promisify(exec);
133
+
134
+ try {
135
+ const [hash, branch, commits] = await Promise.all([
136
+ execAsync('git rev-parse HEAD').then(r => r.stdout.trim()),
137
+ execAsync('git rev-parse --abbrev-ref HEAD').then(r => r.stdout.trim()),
138
+ execAsync('git rev-list --count HEAD').then(r => parseInt(r.stdout.trim()))
139
+ ]);
140
+
141
+ return { hash: hash.substring(0, 7), branch, commits };
142
+ } catch {
143
+ return null;
144
+ }
145
+ },
146
+
147
+ // Environment helpers
148
+ detectEnvironment() {
149
+ const env = {
150
+ node: typeof process !== 'undefined',
151
+ browser: typeof window !== 'undefined',
152
+ deno: typeof Deno !== 'undefined'
153
+ };
154
+
155
+ if (env.node) {
156
+ env.packageManager = fs.existsSync('yarn.lock') ? 'yarn' :
157
+ fs.existsSync('pnpm-lock.yaml') ? 'pnpm' : 'npm';
158
+ }
159
+
160
+ return env;
161
+ },
162
+
163
+ // Code quality checks
164
+ async checkCodeQuality(directory) {
165
+ const fs = require('fs').promises;
166
+ const issues = [];
167
+
168
+ async function checkFile(filePath) {
169
+ const content = await fs.readFile(filePath, 'utf8');
170
+
171
+ // Check for console.log statements
172
+ if (content.includes('console.log')) {
173
+ issues.push(`${filePath}: Contains console.log statements`);
174
+ }
175
+
176
+ // Check for TODO comments
177
+ if (content.includes('TODO:') || content.includes('FIXME:')) {
178
+ issues.push(`${filePath}: Contains TODO/FIXME comments`);
179
+ }
180
+
181
+ // Check for long lines (> 120 characters)
182
+ const lines = content.split('\n');
183
+ lines.forEach((line, i) => {
184
+ if (line.length > 120) {
185
+ issues.push(`${filePath}:${i + 1}: Line too long (${line.length} chars)`);
186
+ }
187
+ });
188
+ }
189
+
190
+ // Scan JavaScript/TypeScript files
191
+ const jsFiles = await this.findFiles(directory, ['.js', '.ts']);
192
+ await Promise.all(jsFiles.map(checkFile));
193
+
194
+ return issues;
195
+ },
196
+
197
+ // File system helpers
198
+ async findFiles(directory, extensions) {
199
+ const fs = require('fs').promises;
200
+ const path = require('path');
201
+ const results = [];
202
+
203
+ async function walk(dir) {
204
+ const items = await fs.readdir(dir);
205
+ for (const item of items) {
206
+ if (item.startsWith('.')) continue;
207
+
208
+ const fullPath = path.join(dir, item);
209
+ const stat = await fs.stat(fullPath);
210
+
211
+ if (stat.isDirectory()) {
212
+ await walk(fullPath);
213
+ } else if (extensions.includes(path.extname(item))) {
214
+ results.push(fullPath);
215
+ }
216
+ }
217
+ }
218
+
219
+ await walk(directory);
220
+ return results;
221
+ }
222
+ };