spec-pack-abandon
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesespec-pack-abandon(废弃/撤销 Spec Pack:清单 + 二次确认 + 删除分支)
spec-pack-abandon (Discard/Revoke Spec Pack: List + Double Confirmation + Branch Deletion)
概览
Overview
当需求出现重大问题需要“废弃当前 spec pack”时,本技能用于安全地撤销:先用 精确定位 ,再生成“将要删除的内容清单”,并在执行任何破坏性操作前要求用户二次确认;最后删除本地/远程分支,并清理工作区中残留的 spec pack 目录。
spec-context{FEATURE_DIR}开始时宣布:「我正在使用 spec-pack-abandon 技能废弃当前 Spec Pack(输出删除清单并二次确认后删除目录与分支)。」
When there are major issues with requirements that require "discarding the current spec pack", this skill is used for secure revocation: first use to accurately locate , then generate a "list of content to be deleted", and ask the user for double confirmation before performing any destructive operations; finally delete the local/remote branches and clean up the remaining spec pack directories in the workspace.
spec-context{FEATURE_DIR}Announce at the beginning: "I am using the spec-pack-abandon skill to discard the current Spec Pack (the directory and branch will be deleted after outputting the deletion list and double confirmation)."
何时使用 / 不使用
When to Use / Not to Use
- 使用时机
- 需求/约束出现重大问题,决定废弃当前 spec pack(不再继续澄清/设计/实现)。
- 你需要删除:以及该
.aisdlc/specs/{CURRENT_BRANCH}/分支(本地 + 远程)。{CURRENT_BRANCH}
- 不要用在
- 你只是想“回退某个提交”或“重做需求文档”:优先用正常 git 回退/新提交,而不是删分支。
- 当前不在 spec 分支(分支名不符合 ):先切到目标 spec 分支再说;否则停止。
{num}-{short-name}
- Usage Scenarios
- Major issues occur in requirements/constraints, and it is decided to discard the current spec pack (no longer continue clarification/design/implementation).
- You need to delete: and the
.aisdlc/specs/{CURRENT_BRANCH}/branch (local + remote).{CURRENT_BRANCH}
- Do Not Use When
- You just want to "roll back a commit" or "redo the requirement document": prioritize normal git rollback/new commits instead of deleting branches.
- You are not currently on a spec branch (branch name does not conform to ): switch to the target spec branch first; otherwise stop.
{num}-{short-name}
硬规则(必须遵守)
Hard Rules (Must Be Followed)
- REQUIRED SUB-SKILL:先满足 门禁并在对话中回显
spec-context(允许FEATURE_DIR=...)。(reuse) - 禁止猜路径/猜分支:只能使用 的
Get-SpecContext与CURRENT_BRANCH。FEATURE_DIR - 必须输出删除清单:在任何删除命令前,先输出“将要删除的内容清单”(目录/分支/远程分支存在性/未提交更改概览)。
- 必须二次确认:
- 第一次确认:用户确认“删除清单无误”。
- 第二次确认:用户确认“即将执行的具体删除命令无误”。
- 两次确认都必须要求用户回复精确短语(见下文)。
- 禁止默认丢弃整个工作区:不得建议/执行 这类“全盘清空”命令来图省事。
git clean -fd - 遇到任何验证失败就停止:不得继续给出“直接删”的命令。
- REQUIRED SUB-SKILL: First meet the access control and echo
spec-contextin the conversation (allowFEATURE_DIR=...).(reuse) - Prohibit guessing paths/branches: Only use and
CURRENT_BRANCHfromFEATURE_DIR.Get-SpecContext - Must output deletion list: Before any deletion command, first output the "list of content to be deleted" (directory/branch/remote branch existence/overview of uncommitted changes).
- Must double confirm:
- First confirmation: The user confirms that "the deletion list is correct".
- Second confirmation: The user confirms that "the specific deletion command to be executed is correct".
- Both confirmations require the user to reply with exact phrases (see below).
- Prohibit discarding the entire workspace by default: Do not suggest/execute "full cleanup" commands like to save trouble.
git clean -fd - Stop when any verification fails: Do not continue to give "direct deletion" commands.
删除清单生成(PowerShell)
Deletion List Generation (PowerShell)
本段只用于生成清单与风险提示,不执行删除。
powershell
. (Join-Path (git rev-parse --show-toplevel) "skills\spec-context\scripts\spec-common.ps1")
$context = Get-SpecContext
$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)
}This section is only used for generating list and risk prompts, no deletion is performed.
powershell
. (Join-Path (git rev-parse --show-toplevel) "skills\spec-context\scripts\spec-common.ps1")
$context = Get-SpecContext
$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 "=== Deletion List (Pending Confirmation) ==="
Write-Host ("REPO_ROOT: {0}" -f $repoRoot)
Write-Host ("CURRENT_BRANCH (to be deleted): {0}" -f $branch)
Write-Host ("FEATURE_DIR (to be deleted/cleaned): {0}" -f $featureDir)
Write-Host ("demo/prototypes (to be deleted/cleaned if exists): {0}" -f $demoDir)
Write-Host ("Whether remote branch origin/{0} exists: {1}" -f $branch, $hasRemote)
Write-Host ""
Write-Host "=== Workspace Risk Prompt ==="
if ($dirty) {
Write-Host "Uncommitted changes detected (will be lost when the branch is deleted). git status --porcelain:"
$dirty | ForEach-Object { Write-Host (" {0}" -f $_) }
} else {
Write-Host "No uncommitted changes detected."
}
if ($aheadBehind) {
Write-Host ("Ahead/behind count with origin/{0} (may be empty/error if the branch is not pushed): {1}" -f $branch, $aheadBehind)
}第一次确认(必须)
First Confirmation (Mandatory)
把上面生成的“删除清单”原样展示给用户,然后要求用户回复以下精确短语:
- 第一次确认短语:
确认删除清单
若用户未明确回复该短语(或提出任何疑问/修改),停止,先修正清单再继续。
Display the "deletion list" generated above to the user as it is, then ask the user to reply with the following exact phrase:
- First confirmation phrase:
确认删除清单
If the user does not explicitly reply with this phrase (or raises any questions/modifications), stop, correct the list before continuing.
删除命令准备(只在第一次确认后展示)
Deletion Command Preparation (Only Displayed After First Confirmation)
本段仍然不执行删除;仅把“将要执行的命令”完整列出来作为第二次确认对象。
powershell
. (Join-Path (git rev-parse --show-toplevel) "skills\spec-context\scripts\spec-common.ps1")
$context = Get-SpecContext
$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)
}
This section still does not perform deletion; only lists the "commands to be executed" in full as the object of the second confirmation.
powershell
. (Join-Path (git rev-parse --show-toplevel) "skills\spec-context\scripts\spec-common.ps1")
$context = Get-SpecContext
$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 }
@"
【Deletion commands to be executed (pending final confirmation)】
1) Switch to main (avoid deleting while on the branch to be deleted)
git switch main
git pull
2) Clean up local residual directories (if exist)
if (Test-Path -LiteralPath `"$featureDir`") { Remove-Item -LiteralPath `"$featureDir`" -Recurse -Force }
if (Test-Path -LiteralPath `"$demoDir`") { Remove-Item -LiteralPath `"$demoDir`" -Recurse -Force }
3) Delete local branch
git branch -D $branch
4) Delete remote branch (if exists)
"@ | Write-Host
if ($hasRemote) {
Write-Host ("git push origin --delete {0}" -f $branch)
} else {
Write-Host ("(Skip remote deletion: origin/{0} not detected)" -f $branch)
}
第二次确认(必须)
Second Confirmation (Mandatory)
要求用户在看到“将要执行的删除命令”后,回复以下精确短语:
- 第二次确认短语:
最终确认执行删除
未收到该短语前,禁止执行任何删除动作。
Ask the user to reply with the following exact phrase after seeing the "deletion commands to be executed":
- Second confirmation phrase:
最终确认执行删除
Before receiving this phrase, prohibit performing any deletion actions.
执行删除(只在二次确认后)
Perform Deletion (Only After Double Confirmation)
按“删除命令准备”里展示的命令执行即可。执行后做最小验收:
powershell
git branch --list $branch
git branch -r | Select-String ("origin/{0}" -f $branch)
Test-Path -LiteralPath $featureDir期望:
- 无输出
git branch --list $branch - 远程分支查询无匹配(若你执行了远程删除)
- 为
Test-Path $featureDirFalse
Just execute the commands shown in "Deletion Command Preparation". Perform minimal acceptance after execution:
powershell
git branch --list $branch
git branch -r | Select-String ("origin/{0}" -f $branch)
Test-Path -LiteralPath $featureDirExpected results:
- has no output
git branch --list $branch - No match for remote branch query (if you performed remote deletion)
- returns
Test-Path $featureDirFalse
常见错误(出现即按硬规则停止)
Common Errors (Stop According to Hard Rules Immediately When Occur)
- 跳过 :用“看目录/看打开文件/猜分支名”的方式拼路径。
spec-context - 不出清单就删:直接给 /
git branch -D/git push --delete。Remove-Item - 只确认一次:用户说“删吧”不等于完成二次确认门禁。
- 用 清空仓库:这是全盘删除,极易误伤非 spec pack 文件。
git clean -fd - 删 main / 删错误分支:任何分支名与 不一致都必须停止。
Get-SpecContext.CURRENT_BRANCH
- Skip : Splice paths by "looking at directories/looking at open files/guessing branch names".
spec-context - Delete without outputting list: Directly give /
git branch -D/git push --deletecommands.Remove-Item - Only confirm once: The user saying "delete it" does not equal completing the double confirmation access control.
- Clear the repository with : This is a full disk deletion, which is very easy to accidentally injure non-spec pack files.
git clean -fd - Delete main / delete wrong branch: You must stop if any branch name is inconsistent with .
Get-SpecContext.CURRENT_BRANCH