install.ps1 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <#
  2. .SYNOPSIS
  3. Install claude-mods extensions to ~/.claude/
  4. .DESCRIPTION
  5. Copies commands, skills, agents, and rules to the global Claude Code config.
  6. Handles cleanup of deprecated items and command-to-skill migrations.
  7. .NOTES
  8. Run from the claude-mods directory:
  9. .\scripts\install.ps1
  10. #>
  11. $ErrorActionPreference = "Stop"
  12. Write-Host "================================================================" -ForegroundColor Cyan
  13. Write-Host " claude-mods Installer (Windows) " -ForegroundColor Cyan
  14. Write-Host "================================================================" -ForegroundColor Cyan
  15. Write-Host ""
  16. $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
  17. $projectRoot = Split-Path -Parent $scriptDir
  18. $claudeDir = "$env:USERPROFILE\.claude"
  19. # Ensure ~/.claude directories exist
  20. $dirs = @("commands", "skills", "agents", "rules", "output-styles")
  21. foreach ($dir in $dirs) {
  22. $path = Join-Path $claudeDir $dir
  23. if (-not (Test-Path $path)) {
  24. New-Item -ItemType Directory -Path $path -Force | Out-Null
  25. Write-Host " Created $path" -ForegroundColor Green
  26. }
  27. }
  28. # =============================================================================
  29. # DEPRECATED ITEMS - Remove these from user config
  30. # =============================================================================
  31. $deprecated = @(
  32. "$claudeDir\commands\review.md",
  33. "$claudeDir\commands\testgen.md",
  34. "$claudeDir\commands\conclave.md",
  35. "$claudeDir\commands\pulse.md",
  36. "$claudeDir\skills\conclave",
  37. "$claudeDir\skills\claude-code-templates" # Replaced by skill-creator
  38. )
  39. # Renamed skills: -patterns -> -ops (March 2026)
  40. $renamedSkills = @(
  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. foreach ($oldSkill in $renamedSkills) {
  57. $oldPath = "$claudeDir\skills\$oldSkill"
  58. if (Test-Path $oldPath) {
  59. Remove-Item -Path $oldPath -Recurse -Force
  60. $newName = $oldSkill -replace '-patterns$', '-ops'
  61. Write-Host " Removed renamed: $oldSkill (now $newName)" -ForegroundColor Red
  62. }
  63. }
  64. Write-Host "Cleaning up deprecated items..." -ForegroundColor Yellow
  65. foreach ($item in $deprecated) {
  66. if (Test-Path $item) {
  67. Remove-Item -Path $item -Recurse -Force
  68. Write-Host " Removed: $item" -ForegroundColor Red
  69. }
  70. }
  71. Write-Host ""
  72. # =============================================================================
  73. # COMMANDS - Only copy commands that have not been migrated to skills
  74. # =============================================================================
  75. Write-Host "Installing commands..." -ForegroundColor Cyan
  76. $skipCommands = @("review.md", "testgen.md")
  77. $commandsDir = Join-Path $projectRoot "commands"
  78. Get-ChildItem -Path $commandsDir -Filter "*.md" | ForEach-Object {
  79. if ($_.Name -notin $skipCommands -and $_.Name -notlike "archive*") {
  80. Copy-Item $_.FullName -Destination "$claudeDir\commands\" -Force
  81. Write-Host " $($_.Name)" -ForegroundColor Green
  82. }
  83. }
  84. Write-Host ""
  85. # =============================================================================
  86. # SKILLS - Copy all skill directories
  87. # =============================================================================
  88. Write-Host "Installing skills..." -ForegroundColor Cyan
  89. $skillsDir = Join-Path $projectRoot "skills"
  90. Get-ChildItem -Path $skillsDir -Directory | ForEach-Object {
  91. $dest = "$claudeDir\skills\$($_.Name)"
  92. if (Test-Path $dest) {
  93. Remove-Item -Path $dest -Recurse -Force
  94. }
  95. Copy-Item $_.FullName -Destination $dest -Recurse -Force
  96. Write-Host " $($_.Name)/" -ForegroundColor Green
  97. }
  98. Write-Host ""
  99. # =============================================================================
  100. # AGENTS - Copy all agent files
  101. # =============================================================================
  102. Write-Host "Installing agents..." -ForegroundColor Cyan
  103. $agentsDir = Join-Path $projectRoot "agents"
  104. Get-ChildItem -Path $agentsDir -Filter "*.md" | ForEach-Object {
  105. Copy-Item $_.FullName -Destination "$claudeDir\agents\" -Force
  106. Write-Host " $($_.Name)" -ForegroundColor Green
  107. }
  108. Write-Host ""
  109. # =============================================================================
  110. # RULES - Copy all rule files
  111. # =============================================================================
  112. Write-Host "Installing rules..." -ForegroundColor Cyan
  113. $rulesDir = Join-Path $projectRoot "rules"
  114. Get-ChildItem -Path $rulesDir -Filter "*.md" | ForEach-Object {
  115. Copy-Item $_.FullName -Destination "$claudeDir\rules\" -Force
  116. Write-Host " $($_.Name)" -ForegroundColor Green
  117. }
  118. Write-Host ""
  119. # =============================================================================
  120. # OUTPUT STYLES - Copy all output style files
  121. # =============================================================================
  122. Write-Host "Installing output styles..." -ForegroundColor Cyan
  123. $stylesDir = Join-Path $projectRoot "output-styles"
  124. if (Test-Path $stylesDir) {
  125. Get-ChildItem -Path $stylesDir -Filter "*.md" | ForEach-Object {
  126. Copy-Item $_.FullName -Destination "$claudeDir\output-styles\" -Force
  127. Write-Host " $($_.Name)" -ForegroundColor Green
  128. }
  129. }
  130. Write-Host ""
  131. # =============================================================================
  132. # SUMMARY
  133. # =============================================================================
  134. Write-Host "================================================================" -ForegroundColor Cyan
  135. Write-Host " Installation complete!" -ForegroundColor Green
  136. Write-Host "================================================================" -ForegroundColor Cyan
  137. Write-Host ""
  138. Write-Host "Restart Claude Code to load the new extensions." -ForegroundColor Yellow
  139. Write-Host ""