# Install Cursor subagents from this repository (native Windows PowerShell). # Also works in PowerShell on macOS/Linux if desired. [CmdletBinding()] param( [switch]$All, [string]$Category = "", [switch]$Local, [switch]$Global, [switch]$UninstallAll, [switch]$Help ) $ErrorActionPreference = "Stop" function Show-Help { @" Usage: .\install-agents.ps1 [options] Options: -All Install all agents -Category Install one category (e.g. 04-quality-security) -Local Install into current project (.cursor\agents) -Global Install globally (~/.cursor/agents) [default] -UninstallAll Remove agents previously installed from this repo -Help Show help Examples: .\install-agents.ps1 -All .\install-agents.ps1 -Category 04-quality-security .\install-agents.ps1 -All -Local .\install-agents.ps1 -UninstallAll "@ } if ($Help) { Show-Help exit 0 } $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path $CategoriesDir = Join-Path $ScriptDir "categories" $GlobalAgentsDir = Join-Path $env:USERPROFILE ".cursor\agents" $LocalAgentsDir = Join-Path (Get-Location) ".cursor\agents" if (-not (Test-Path $CategoriesDir)) { Write-Host "Error: categories/ not found next to this script." -ForegroundColor Red exit 1 } $Mode = if ($Local) { "local" } else { "global" } $Interactive = -not ($All -or $Category -or $UninstallAll) function Get-TargetDir { if ($Mode -eq "local") { return $LocalAgentsDir } return $GlobalAgentsDir } function Get-Categories { Get-ChildItem -Path $CategoriesDir -Directory | Sort-Object Name | ForEach-Object { $_.Name } } function Get-AllAgentFiles { Get-ChildItem -Path $CategoriesDir -Directory | ForEach-Object { Get-ChildItem -Path $_.FullName -Filter "*.md" -File | Where-Object { $_.Name -ne "README.md" } } | Sort-Object FullName } function Get-CategoryAgentFiles([string]$CatName) { $dir = Join-Path $CategoriesDir $CatName if (-not (Test-Path $dir)) { throw "Category not found: $CatName" } Get-ChildItem -Path $dir -Filter "*.md" -File | Where-Object { $_.Name -ne "README.md" } | Sort-Object Name } function Install-Files($files) { $dest = Get-TargetDir New-Item -ItemType Directory -Force -Path $dest | Out-Null $count = 0 foreach ($f in $files) { Copy-Item -Path $f.FullName -Destination (Join-Path $dest $f.Name) -Force $count++ } Write-Host "Installed $count agent(s) → $dest" -ForegroundColor Green } function Uninstall-AllFromRepo { $dest = Get-TargetDir if (-not (Test-Path $dest)) { Write-Host "Nothing to uninstall: $dest does not exist." -ForegroundColor Yellow return } $removed = 0 foreach ($f in Get-AllAgentFiles) { $target = Join-Path $dest $f.Name if (Test-Path $target) { Remove-Item -Force $target $removed++ } } Write-Host "Removed $removed agent file(s) from $dest" -ForegroundColor Green } if ($Interactive) { Write-Host "Cursor Subagents Installer" -ForegroundColor Cyan Write-Host "" Write-Host "Install mode:" Write-Host " 1) Global — all Cursor projects (~/.cursor/agents)" Write-Host " 2) Local — current project only (.cursor/agents)" $modeChoice = Read-Host "Choice [1]" if ($modeChoice -eq "2") { $Mode = "local" } else { $Mode = "global" } Write-Host "" Write-Host "What to install:" Write-Host " 1) All agents" Write-Host " 2) One category" Write-Host " 3) Uninstall all agents from this repo" $actionChoice = Read-Host "Choice [1]" switch ($actionChoice) { "3" { $UninstallAll = $true } "2" { $cats = @(Get-Categories) Write-Host "" Write-Host "Categories:" for ($i = 0; $i -lt $cats.Count; $i++) { Write-Host (" {0,2}) {1}" -f ($i + 1), $cats[$i]) } $catNum = [int](Read-Host "Category number") if ($catNum -lt 1 -or $catNum -gt $cats.Count) { Write-Host "Invalid category." -ForegroundColor Red exit 1 } $Category = $cats[$catNum - 1] } default { $All = $true } } } if ($UninstallAll) { Uninstall-AllFromRepo exit 0 } if ($All) { Install-Files (Get-AllAgentFiles) } elseif ($Category) { try { Install-Files (Get-CategoryAgentFiles $Category) } catch { Write-Host $_.Exception.Message -ForegroundColor Red Write-Host "Available:" Get-Categories | ForEach-Object { Write-Host " $_" } exit 1 } } else { Write-Host "Nothing to do. Use -All, -Category, or run without args for interactive mode." -ForegroundColor Red Show-Help exit 1 } Write-Host "" Write-Host "Restart Cursor (or open a new Agent chat) so new subagents are picked up." -ForegroundColor Yellow