install.sh 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. )
  38. # Renamed skills: -patterns -> -ops (March 2026)
  39. renamed_skills=(
  40. cli-patterns
  41. mcp-patterns
  42. python-async-patterns
  43. python-cli-patterns
  44. python-database-patterns
  45. python-fastapi-patterns
  46. python-observability-patterns
  47. python-pytest-patterns
  48. python-typing-patterns
  49. rest-patterns
  50. security-patterns
  51. sql-patterns
  52. tailwind-patterns
  53. testing-patterns
  54. )
  55. for old_skill in "${renamed_skills[@]}"; do
  56. old_path="$CLAUDE_DIR/skills/$old_skill"
  57. if [ -d "$old_path" ]; then
  58. rm -rf "$old_path"
  59. echo -e " ${RED}Removed renamed: $old_skill (now ${old_skill%-patterns}-ops)${NC}"
  60. fi
  61. done
  62. for item in "${deprecated_items[@]}"; do
  63. if [ -e "$item" ]; then
  64. rm -rf "$item"
  65. echo -e " ${RED}Removed: $item${NC}"
  66. fi
  67. done
  68. echo ""
  69. # =============================================================================
  70. # COMMANDS - Only copy commands that haven't been migrated to skills
  71. # =============================================================================
  72. echo -e "${BLUE}Installing commands...${NC}"
  73. # Commands that should NOT be copied (migrated to skills)
  74. skip_commands=("review.md" "testgen.md")
  75. for file in "$PROJECT_ROOT/commands"/*.md; do
  76. [ -f "$file" ] || continue
  77. filename=$(basename "$file")
  78. # Skip migrated commands
  79. skip=false
  80. for skip_cmd in "${skip_commands[@]}"; do
  81. if [ "$filename" = "$skip_cmd" ]; then
  82. skip=true
  83. break
  84. fi
  85. done
  86. # Skip archive directory contents
  87. [[ "$file" == *"/archive/"* ]] && continue
  88. if [ "$skip" = false ]; then
  89. cp "$file" "$CLAUDE_DIR/commands/"
  90. echo -e " ${GREEN}$filename${NC}"
  91. fi
  92. done
  93. echo ""
  94. # =============================================================================
  95. # SKILLS - Copy all skill directories
  96. # =============================================================================
  97. echo -e "${BLUE}Installing skills...${NC}"
  98. for skill_dir in "$PROJECT_ROOT/skills"/*/; do
  99. [ -d "$skill_dir" ] || continue
  100. skill_name=$(basename "$skill_dir")
  101. # Remove existing and copy fresh
  102. rm -rf "$CLAUDE_DIR/skills/$skill_name"
  103. cp -r "$skill_dir" "$CLAUDE_DIR/skills/"
  104. echo -e " ${GREEN}$skill_name/${NC}"
  105. done
  106. echo ""
  107. # =============================================================================
  108. # AGENTS - Copy all agent files
  109. # =============================================================================
  110. echo -e "${BLUE}Installing agents...${NC}"
  111. for file in "$PROJECT_ROOT/agents"/*.md; do
  112. [ -f "$file" ] || continue
  113. cp "$file" "$CLAUDE_DIR/agents/"
  114. echo -e " ${GREEN}$(basename "$file")${NC}"
  115. done
  116. echo ""
  117. # =============================================================================
  118. # RULES - Copy all rule files
  119. # =============================================================================
  120. echo -e "${BLUE}Installing rules...${NC}"
  121. for file in "$PROJECT_ROOT/rules"/*.md; do
  122. [ -f "$file" ] || continue
  123. cp "$file" "$CLAUDE_DIR/rules/"
  124. echo -e " ${GREEN}$(basename "$file")${NC}"
  125. done
  126. echo ""
  127. # =============================================================================
  128. # OUTPUT STYLES - Copy all output style files
  129. # =============================================================================
  130. echo -e "${BLUE}Installing output styles...${NC}"
  131. if [ -d "$PROJECT_ROOT/output-styles" ]; then
  132. for file in "$PROJECT_ROOT/output-styles"/*.md; do
  133. [ -f "$file" ] || continue
  134. cp "$file" "$CLAUDE_DIR/output-styles/"
  135. echo -e " ${GREEN}$(basename "$file")${NC}"
  136. done
  137. fi
  138. echo ""
  139. # =============================================================================
  140. # SUMMARY
  141. # =============================================================================
  142. echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"
  143. echo -e " ${GREEN}Installation complete!${NC}"
  144. echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"
  145. echo ""
  146. echo -e "${YELLOW}Restart Claude Code to load the new extensions.${NC}"
  147. echo ""