install.sh 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #!/usr/bin/env bash
  2. #
  3. # claude-mods Installer (Linux/macOS)
  4. # Copies commands, skills, agents, and rules to ~/.claude/
  5. # Handles cleanup of deprecated items and command-to-skill migrations.
  6. #
  7. # Usage: ./scripts/install.sh
  8. set -e
  9. BLUE='\033[0;34m'
  10. GREEN='\033[0;32m'
  11. YELLOW='\033[1;33m'
  12. RED='\033[0;31m'
  13. NC='\033[0m'
  14. echo -e "${BLUE}╔══════════════════════════════════════════════════════════════╗${NC}"
  15. echo -e "${BLUE}║ claude-mods Installer (Unix) ║${NC}"
  16. echo -e "${BLUE}╚══════════════════════════════════════════════════════════════╝${NC}"
  17. echo ""
  18. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  19. PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
  20. CLAUDE_DIR="$HOME/.claude"
  21. # Ensure ~/.claude directories exist
  22. for dir in commands skills agents rules output-styles; do
  23. mkdir -p "$CLAUDE_DIR/$dir"
  24. done
  25. # =============================================================================
  26. # DEPRECATED ITEMS - Remove these from user's config
  27. # =============================================================================
  28. echo -e "${YELLOW}Cleaning up deprecated items...${NC}"
  29. deprecated_items=(
  30. # Removed commands (migrated to skills or deleted)
  31. "$CLAUDE_DIR/commands/review.md" # Migrated to skill
  32. "$CLAUDE_DIR/commands/testgen.md" # Migrated to skill
  33. "$CLAUDE_DIR/commands/conclave.md" # Deprecated
  34. "$CLAUDE_DIR/commands/pulse.md" # Now a skill only
  35. # Removed skills
  36. "$CLAUDE_DIR/skills/conclave" # Deprecated
  37. "$CLAUDE_DIR/skills/claude-code-templates" # Replaced by skill-creator
  38. )
  39. # Renamed skills: -patterns -> -ops (March 2026)
  40. renamed_skills=(
  41. cli-patterns
  42. mcp-patterns
  43. python-async-patterns
  44. python-cli-patterns
  45. python-database-patterns
  46. python-fastapi-patterns
  47. python-observability-patterns
  48. python-pytest-patterns
  49. python-typing-patterns
  50. rest-patterns
  51. security-patterns
  52. sql-patterns
  53. tailwind-patterns
  54. testing-patterns
  55. )
  56. for old_skill in "${renamed_skills[@]}"; do
  57. old_path="$CLAUDE_DIR/skills/$old_skill"
  58. if [ -d "$old_path" ]; then
  59. rm -rf "$old_path"
  60. echo -e " ${RED}Removed renamed: $old_skill (now ${old_skill%-patterns}-ops)${NC}"
  61. fi
  62. done
  63. for item in "${deprecated_items[@]}"; do
  64. if [ -e "$item" ]; then
  65. rm -rf "$item"
  66. echo -e " ${RED}Removed: $item${NC}"
  67. fi
  68. done
  69. echo ""
  70. # =============================================================================
  71. # COMMANDS - Only copy commands that haven't been migrated to skills
  72. # =============================================================================
  73. echo -e "${BLUE}Installing commands...${NC}"
  74. # Commands that should NOT be copied (migrated to skills)
  75. skip_commands=("review.md" "testgen.md")
  76. for file in "$PROJECT_ROOT/commands"/*.md; do
  77. [ -f "$file" ] || continue
  78. filename=$(basename "$file")
  79. # Skip migrated commands
  80. skip=false
  81. for skip_cmd in "${skip_commands[@]}"; do
  82. if [ "$filename" = "$skip_cmd" ]; then
  83. skip=true
  84. break
  85. fi
  86. done
  87. # Skip archive directory contents
  88. [[ "$file" == *"/archive/"* ]] && continue
  89. if [ "$skip" = false ]; then
  90. cp "$file" "$CLAUDE_DIR/commands/"
  91. echo -e " ${GREEN}$filename${NC}"
  92. fi
  93. done
  94. echo ""
  95. # =============================================================================
  96. # SKILLS - Copy all skill directories
  97. # =============================================================================
  98. echo -e "${BLUE}Installing skills...${NC}"
  99. for skill_dir in "$PROJECT_ROOT/skills"/*/; do
  100. [ -d "$skill_dir" ] || continue
  101. skill_name=$(basename "$skill_dir")
  102. # Remove existing and copy fresh
  103. rm -rf "$CLAUDE_DIR/skills/$skill_name"
  104. cp -r "$skill_dir" "$CLAUDE_DIR/skills/"
  105. echo -e " ${GREEN}$skill_name/${NC}"
  106. done
  107. echo ""
  108. # =============================================================================
  109. # AGENTS - Copy all agent files
  110. # =============================================================================
  111. echo -e "${BLUE}Installing agents...${NC}"
  112. for file in "$PROJECT_ROOT/agents"/*.md; do
  113. [ -f "$file" ] || continue
  114. cp "$file" "$CLAUDE_DIR/agents/"
  115. echo -e " ${GREEN}$(basename "$file")${NC}"
  116. done
  117. echo ""
  118. # =============================================================================
  119. # RULES - Copy all rule files
  120. # =============================================================================
  121. echo -e "${BLUE}Installing rules...${NC}"
  122. for file in "$PROJECT_ROOT/rules"/*.md; do
  123. [ -f "$file" ] || continue
  124. cp "$file" "$CLAUDE_DIR/rules/"
  125. echo -e " ${GREEN}$(basename "$file")${NC}"
  126. done
  127. echo ""
  128. # =============================================================================
  129. # OUTPUT STYLES - Copy all output style files
  130. # =============================================================================
  131. echo -e "${BLUE}Installing output styles...${NC}"
  132. if [ -d "$PROJECT_ROOT/output-styles" ]; then
  133. for file in "$PROJECT_ROOT/output-styles"/*.md; do
  134. [ -f "$file" ] || continue
  135. cp "$file" "$CLAUDE_DIR/output-styles/"
  136. echo -e " ${GREEN}$(basename "$file")${NC}"
  137. done
  138. fi
  139. echo ""
  140. # =============================================================================
  141. # SUMMARY
  142. # =============================================================================
  143. echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"
  144. echo -e " ${GREEN}Installation complete!${NC}"
  145. echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"
  146. echo ""
  147. echo -e "${YELLOW}Restart Claude Code to load the new extensions.${NC}"
  148. echo ""