Use when 需要因需求重大问题而废弃/撤销当前 Spec Pack,并且必须删除对应 `.aisdlc/specs/{branch}` 目录与本地/远程分支,同时需要在执行删除前输出删除清单并要求用户二次确认。
From sdlc-dev-skillsnpx claudepluginhub zixun-github/aisdlcThis skill uses the workspace's default tool permissions.
当需求出现重大问题需要“废弃当前 spec pack”时,本技能用于安全地撤销:先执行 spec-context 获取上下文并精确定位 {FEATURE_DIR},再生成“将要删除的内容清单”,并在执行任何破坏性操作前要求用户二次确认;最后删除本地/远程分支,并清理工作区中残留的 spec pack 目录。
开始时宣布:「我正在使用 spec-pack-abandon 技能废弃当前 Spec Pack(输出删除清单并二次确认后删除目录与分支)。」
.aisdlc/specs/{CURRENT_BRANCH}/ 以及该 {CURRENT_BRANCH} 分支(本地 + 远程)。{num}-{short-name}):先切到目标 spec 分支再说;否则停止。spec-context 获取上下文,并在对话中回显 FEATURE_DIR=...(允许 (reuse))。Get-SpecContext 的 CURRENT_BRANCH 与 FEATURE_DIR。git clean -fd 这类“全盘清空”命令来图省事。本段只用于生成清单与风险提示,不执行删除。
. (Join-Path (git rev-parse --show-toplevel) "skills\spec-context\scripts\spec-common.ps1")
$context = Get-SpecContext -SkillName "spec-pack-abandon"
$FEATURE_DIR = $context.FEATURE_DIR
Write-Host ("FEATURE_DIR={0}" -f $FEATURE_DIR)
Write-Host ("CURRENT_BRANCH={0}" -f $context.CURRENT_BRANCH)
$repoRoot = $context.REPO_ROOT
$branch = $context.CURRENT_BRANCH
$featureDir = $context.FEATURE_DIR
$demoDir = Join-Path $repoRoot ("demo\prototypes\{0}" -f $branch)
$hasRemote = $false
git ls-remote --exit-code --heads origin $branch *> $null
if ($LASTEXITCODE -eq 0) { $hasRemote = $true }
$dirty = git status --porcelain
$aheadBehind = git rev-list --left-right --count ("origin/{0}...{0}" -f $branch) 2>$null
Write-Host "=== 删除清单(待确认)==="
Write-Host ("REPO_ROOT: {0}" -f $repoRoot)
Write-Host ("CURRENT_BRANCH(将删除): {0}" -f $branch)
Write-Host ("FEATURE_DIR(将删除/清理): {0}" -f $featureDir)
Write-Host ("demo/prototypes(如存在将删除/清理): {0}" -f $demoDir)
Write-Host ("远程分支 origin/{0} 是否存在: {1}" -f $branch, $hasRemote)
Write-Host ""
Write-Host "=== 工作区风险提示 ==="
if ($dirty) {
Write-Host "检测到未提交更改(将随分支删除而丢失)。git status --porcelain:"
$dirty | ForEach-Object { Write-Host (" {0}" -f $_) }
} else {
Write-Host "未检测到未提交更改。"
}
if ($aheadBehind) {
Write-Host ("与 origin/{0} 的 ahead/behind 计数(若分支未 push 可能为空/报错): {1}" -f $branch, $aheadBehind)
}
把上面生成的“删除清单”原样展示给用户,然后要求用户回复以下精确短语:
确认删除清单若用户未明确回复该短语(或提出任何疑问/修改),停止,先修正清单再继续。
本段仍然不执行删除;仅把“将要执行的命令”完整列出来作为第二次确认对象。
. (Join-Path (git rev-parse --show-toplevel) "skills\spec-context\scripts\spec-common.ps1")
$context = Get-SpecContext -SkillName "spec-pack-abandon"
$branch = $context.CURRENT_BRANCH
$featureDir = $context.FEATURE_DIR
$repoRoot = $context.REPO_ROOT
$demoDir = Join-Path $repoRoot ("demo\prototypes\{0}" -f $branch)
$hasRemote = $false
git ls-remote --exit-code --heads origin $branch *> $null
if ($LASTEXITCODE -eq 0) { $hasRemote = $true }
@"
【将要执行的删除命令(待最终确认)】
1) 切到 main(避免在被删分支上删除)
git switch main
git pull
2) 清理本地残留目录(若存在)
if (Test-Path -LiteralPath `"$featureDir`") { Remove-Item -LiteralPath `"$featureDir`" -Recurse -Force }
if (Test-Path -LiteralPath `"$demoDir`") { Remove-Item -LiteralPath `"$demoDir`" -Recurse -Force }
3) 删除本地分支
git branch -D $branch
4) 删除远程分支(若存在)
"@ | Write-Host
if ($hasRemote) {
Write-Host ("git push origin --delete {0}" -f $branch)
} else {
Write-Host ("(跳过远程删除:未检测到 origin/{0})" -f $branch)
}
要求用户在看到“将要执行的删除命令”后,回复以下精确短语:
最终确认执行删除未收到该短语前,禁止执行任何删除动作。
按“删除命令准备”里展示的命令执行即可。执行后做最小验收:
git branch --list $branch
git branch -r | Select-String ("origin/{0}" -f $branch)
Test-Path -LiteralPath $featureDir
期望:
git branch --list $branch 无输出Test-Path $featureDir 为 Falsespec-context:用“看目录/看打开文件/猜分支名”的方式拼路径。git branch -D / git push --delete / Remove-Item。git clean -fd 清空仓库:这是全盘删除,极易误伤非 spec pack 文件。Get-SpecContext.CURRENT_BRANCH 不一致都必须停止。