-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathquick-install.sh
More file actions
executable file
·438 lines (371 loc) · 13.8 KB
/
quick-install.sh
File metadata and controls
executable file
·438 lines (371 loc) · 13.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
#!/bin/bash
# Claude Code Essentials Quick Installer
# Run with: curl -sSL https://raw.githubusercontent.com/benjaminr/claude-code-essentials/main/quick-install.sh | bash
# Options: --clean (remove existing commands before install)
set -e # Exit on any error
# Command line options
CLEAN_INSTALL=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--clean)
CLEAN_INSTALL=true
shift
;;
-h|--help)
echo "Claude Code Essentials Quick Installer"
echo ""
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --clean Remove existing slash commands before installation"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 # Standard installation (preserves existing commands)"
echo " $0 --clean # Clean installation (removes existing commands)"
exit 0
;;
*)
print_error "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_header() {
echo ""
echo "======================================="
echo " Claude Code Essentials Quick Install"
echo "======================================="
echo ""
}
# Check prerequisites
check_requirements() {
print_status "Checking requirements..."
# Check if Claude Code is installed
if ! command -v claude &> /dev/null; then
print_error "Claude Code CLI not found. Please install Claude Code first:"
echo " Visit: https://claude.ai/code"
exit 1
fi
print_success "Claude Code CLI found"
# Check curl or wget
if ! command -v curl &> /dev/null && ! command -v wget &> /dev/null; then
print_error "Neither curl nor wget found. Please install one of them."
exit 1
fi
# Check Git
if ! command -v git &> /dev/null; then
print_warning "Git not found. Some commands may not work optimally."
else
print_success "Git found"
fi
}
# Download function with fallback
download_file() {
local url="$1"
local output="$2"
if command -v curl &> /dev/null; then
curl -sSL "$url" -o "$output"
elif command -v wget &> /dev/null; then
wget -q "$url" -O "$output"
else
print_error "No download tool available"
exit 1
fi
}
# Clean existing commands if requested
clean_existing_commands() {
if [ "$CLEAN_INSTALL" = true ]; then
print_status "Cleaning existing slash commands..."
if [ -d ~/.claude/commands ]; then
# Backup existing commands first
if [ -n "$(ls -A ~/.claude/commands 2>/dev/null)" ]; then
local backup_dir="$HOME/.claude/commands.backup.$(date +%Y%m%d_%H%M%S)"
print_status "Backing up existing commands to $backup_dir"
cp -r ~/.claude/commands "$backup_dir"
fi
# Remove existing commands
rm -rf ~/.claude/commands/*
print_success "Existing commands cleaned and backed up"
else
print_status "No existing commands to clean"
fi
fi
}
# Create directory structure
setup_directories() {
print_status "Setting up global Claude directory structure..."
# Create ~/.claude if it doesn't exist
mkdir -p ~/.claude/commands/sdd/core
mkdir -p ~/.claude/commands/sdd/orchestration
mkdir -p ~/.claude/commands/code/understand
mkdir -p ~/.claude/commands/code/improve
mkdir -p ~/.claude/commands/project
mkdir -p ~/.claude/commands/test
mkdir -p ~/.claude/commands/tools
mkdir -p ~/.claude/templates
mkdir -p ~/.claude/agents
print_success "Directory structure created"
}
# Download and install commands
install_commands() {
print_status "Downloading and installing slash commands..."
local base_url="https://raw.githubusercontent.com/benjaminr/claude-code-essentials/main/.claude/commands"
local temp_dir=$(mktemp -d)
# List of all command files with their subdirectories
local commands=(
"sdd/core/build.md" "sdd/core/design.md" "sdd/core/next.md"
"sdd/core/plan.md" "sdd/core/refine.md" "sdd/core/reset.md"
"sdd/core/review.md" "sdd/core/spec.md" "sdd/core/spec-all.md"
"sdd/core/status.md" "sdd/core/validate.md"
"sdd/orchestration/parallel.md" "sdd/orchestration/prototype.md"
"code/understand/explain.md" "code/understand/trace.md"
"code/improve/debug.md" "code/improve/refactor.md"
"project/clean.md" "project/dependencies.md" "project/document.md"
"project/init-sdd.md" "project/migrate.md" "project/optimize.md"
"project/security.md" "project/setup.md" "project/todo.md"
"test/coverage.md" "test/test.md"
"tools/api.md"
)
local downloaded=0
for cmd in "${commands[@]}"; do
local cmd_dir=$(dirname "$cmd")
local cmd_file=$(basename "$cmd")
# Create subdirectory in temp
mkdir -p "$temp_dir/$cmd_dir"
if download_file "$base_url/$cmd" "$temp_dir/$cmd" 2>/dev/null; then
# Create target directory and copy file
mkdir -p ~/.claude/commands/$cmd_dir
cp "$temp_dir/$cmd" ~/.claude/commands/$cmd
((downloaded++))
else
print_warning "Failed to download $cmd"
fi
done
print_success "Installed $downloaded slash commands"
# Cleanup
rm -rf "$temp_dir"
}
# Download and install sub-agents
install_agents() {
print_status "Downloading and installing specialized sub-agents..."
local base_url="https://raw.githubusercontent.com/benjaminr/claude-code-essentials/main/.claude/agents"
local temp_dir=$(mktemp -d)
# List of all agent files
local agents=(
"code-standards-enforcer.md"
"documentation-generator.md"
"performance-profiler.md"
"test-engineer.md"
"infra-engineer.md"
"fullstack-engineer.md"
"ai-engineer.md"
"git-workflow-assistant.md"
"design-frontend-assistant.md"
)
local downloaded=0
for agent in "${agents[@]}"; do
if download_file "$base_url/$agent" "$temp_dir/$agent" 2>/dev/null; then
cp "$temp_dir/$agent" ~/.claude/agents/
((downloaded++))
else
print_warning "Failed to download $agent"
fi
done
print_success "Installed $downloaded specialized sub-agents"
# Cleanup
rm -rf "$temp_dir"
}
# Download and install templates
install_templates() {
print_status "Installing templates..."
local base_url="https://raw.githubusercontent.com/benjaminr/claude-code-essentials/main/.claude/templates"
if download_file "$base_url/command-template.md" ~/.claude/templates/command-template.md 2>/dev/null; then
print_success "Templates installed"
else
print_warning "Failed to download templates, skipping..."
fi
}
# Download and install global CLAUDE.md
install_global_config() {
print_status "Installing global development standards..."
local config_url="https://raw.githubusercontent.com/benjaminr/claude-code-essentials/main/CLAUDE.md"
# Backup existing CLAUDE.md if it exists
if [ -f ~/.claude/CLAUDE.md ]; then
cp ~/.claude/CLAUDE.md ~/.claude/CLAUDE.md.backup
print_warning "Existing CLAUDE.md backed up to CLAUDE.md.backup"
fi
if download_file "$config_url" ~/.claude/CLAUDE.md 2>/dev/null; then
print_success "Global development standards installed"
else
print_warning "Failed to download CLAUDE.md, skipping global config..."
fi
}
# Set permissions
set_permissions() {
print_status "Setting permissions..."
find ~/.claude/commands -name "*.md" -exec chmod 644 {} \; 2>/dev/null || true
find ~/.claude/templates -name "*.md" -exec chmod 644 {} \; 2>/dev/null || true
find ~/.claude/agents -name "*.md" -exec chmod 644 {} \; 2>/dev/null || true
chmod 644 ~/.claude/CLAUDE.md 2>/dev/null || true
print_success "Permissions set"
}
# Verify installation
verify_installation() {
print_status "Verifying installation..."
# Check if commands were installed
if [ -f ~/.claude/commands/sdd/core/spec.md ]; then
print_success "Core commands installed successfully"
else
print_error "Installation verification failed"
exit 1
fi
# Check if agents were installed
if [ -f ~/.claude/agents/code-standards-enforcer.md ]; then
print_success "Sub-agents installed successfully"
else
print_warning "Sub-agents installation may have failed"
fi
# Count installed commands and agents
local command_count=$(find ~/.claude/commands -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
local agent_count=$(find ~/.claude/agents -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
print_success "Total commands available: $command_count"
print_success "Total sub-agents available: $agent_count"
}
# Show next steps
show_next_steps() {
echo ""
echo "🎉 Installation Complete!"
echo ""
if [ "$CLEAN_INSTALL" = true ]; then
echo "✨ Clean installation completed - all old commands replaced"
echo ""
fi
echo "Next steps:"
echo " 1. Navigate to any project directory"
echo " 2. Run: /init-sdd"
echo " 3. Start your first spec: /spec feature-name \"Description\""
echo ""
echo "Available commands (organised by category):"
echo " 📋 SDD Core: /spec, /design, /plan, /build, /validate, /next"
echo " 🔄 SDD Orchestration: /parallel, /prototype"
echo " 🔍 Code Understanding: /explain, /trace"
echo " 🛠️ Code Improvement: /debug, /refactor"
echo " 📦 Project Management: /clean, /dependencies, /document, /setup"
echo " 🧪 Testing: /test, /coverage"
echo " ⚡ Tools: /api"
echo ""
echo "🤖 9 Specialized Sub-Agents Available:"
echo " • Code Standards Enforcer - Pedantic quality control"
echo " • Documentation Generator - Dual-layer documentation"
echo " • Performance Profiler - Proactive optimization"
echo " • Test Engineer - Strategic test coverage"
echo " • Infrastructure Engineer - AWS + Terraform"
echo " • Full-Stack Engineer - Next.js + FastAPI"
echo " • AI Engineer - Full-spectrum ML/AI"
echo " • Git Workflow Assistant - GitHub Flow"
echo " • Design & Frontend Assistant - Mobile-first design"
echo ""
echo "Access sub-agents with: /agents (to manage) or mention them in requests"
echo "Documentation: Each command includes built-in help and examples"
echo "Global config: ~/.claude/CLAUDE.md"
echo ""
if [ "$CLEAN_INSTALL" = true ]; then
echo "💾 Previous commands backed up in ~/.claude/commands.backup.*"
echo ""
fi
echo "Repository: https://github.com/benjaminr/claude-code-essentials"
echo ""
}
# Install from local directory
install_local() {
print_status "Installing from local directory..."
# Copy all commands
if [ -d ".claude/commands" ]; then
# Create subdirectories first
mkdir -p ~/.claude/commands/sdd/{core,orchestration}
mkdir -p ~/.claude/commands/code/{understand,improve}
mkdir -p ~/.claude/commands/{project,test,tools}
cp -r .claude/commands/* ~/.claude/commands/
local command_count=$(find .claude/commands -name "*.md" | wc -l | tr -d ' ')
print_success "Installed $command_count slash commands"
else
print_error "Commands directory not found. Are you in the correct directory?"
exit 1
fi
# Copy all agents
if [ -d ".claude/agents" ]; then
cp -r .claude/agents/* ~/.claude/agents/
local agent_count=$(find .claude/agents -name "*.md" | wc -l | tr -d ' ')
print_success "Installed $agent_count specialized sub-agents"
else
print_warning "No agents directory found, skipping..."
fi
# Copy templates
if [ -d ".claude/templates" ]; then
cp -r .claude/templates/* ~/.claude/templates/
print_success "Templates installed"
else
print_warning "No templates directory found, skipping..."
fi
# Copy global CLAUDE.md
if [ -f "CLAUDE.md" ]; then
# Backup existing CLAUDE.md if it exists
if [ -f ~/.claude/CLAUDE.md ]; then
cp ~/.claude/CLAUDE.md ~/.claude/CLAUDE.md.backup
print_warning "Existing CLAUDE.md backed up to CLAUDE.md.backup"
fi
cp CLAUDE.md ~/.claude/CLAUDE.md
print_success "Global development standards installed"
else
print_warning "CLAUDE.md not found, skipping global config..."
fi
}
# Main installation flow
main() {
print_header
# Show clean install notice
if [ "$CLEAN_INSTALL" = true ]; then
print_status "Clean installation mode enabled"
fi
check_requirements
clean_existing_commands
setup_directories
# Check if running locally
if [ -f "README.md" ] && [ -d ".claude" ]; then
print_status "Local installation detected"
install_local
else
print_status "Remote installation"
install_commands
install_agents
install_templates
install_global_config
fi
set_permissions
verify_installation
show_next_steps
}
# Run installation
main "$@"