claude-meta/scripts/init-project.ps1

51 lines
1.6 KiB
PowerShell

# init-project.ps1 — Bootstrap a new project with Claude config
param(
[Parameter(Mandatory=$true)]
[string]$ProjectPath,
[Parameter(Mandatory=$true)]
[string]$ProjectName
)
$ErrorActionPreference = "Stop"
$repoRoot = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
$templateDir = Join-Path $repoRoot "templates\generic"
if (-not (Test-Path $ProjectPath)) {
Write-Host "ERROR: Project path does not exist: $ProjectPath" -ForegroundColor Red
exit 1
}
$targetClaude = Join-Path $ProjectPath ".claude"
$targetPlans = Join-Path $ProjectPath "plans"
if (Test-Path $targetClaude) {
Write-Host "WARNING: .claude/ already exists in $ProjectPath" -ForegroundColor Yellow
$response = Read-Host "Overwrite? (y/N)"
if ($response -ne "y") {
Write-Host "Aborted." -ForegroundColor Yellow
exit 0
}
}
# Copy template
Write-Host "Initializing project: $ProjectName" -ForegroundColor Cyan
Copy-Item (Join-Path $templateDir ".claude") $targetClaude -Recurse -Force
New-Item -ItemType Directory -Path $targetPlans -Force | Out-Null
# Replace placeholders
$claudeMd = Join-Path $targetClaude "CLAUDE.md"
$content = Get-Content $claudeMd -Raw
$content = $content -replace '\{\{PROJECT_NAME\}\}', $ProjectName
Set-Content $claudeMd $content -NoNewline
Write-Host ""
Write-Host "Done! Created:" -ForegroundColor Green
Write-Host " $targetClaude\CLAUDE.md" -ForegroundColor Gray
Write-Host " $targetClaude\settings.json" -ForegroundColor Gray
Write-Host " $targetPlans\" -ForegroundColor Gray
Write-Host ""
Write-Host "Next: Edit $targetClaude\CLAUDE.md with project-specific info." -ForegroundColor Cyan