SuperAPI AI Directory

spec-pack-abandon

Deployment & operations

View repository

Updated 10-16 02:12

About this skill

spec-pack-abandon (abandon/revoke Spec Pack: list + second confirmation + delete branches)

Overview

When a major problem arises with the requirements and the "current spec pack" needs to be abandoned, this skill is used tosafely revoke: first run spec-context to get context and precisely locate {FEATURE_DIR}, then generate a "list of contents to be deleted", and before executing any destructive operation require the user'ssecond confirmation; finally delete the local/remote branches and clean up the residual spec pack directory in the workspace.

At the start, announce:"I am using the spec-pack-abandon skill to abandon the current Spec Pack (output the deletion list, obtain second confirmation, then delete the directory and branches)."

When to use / not use

  • When to use
    • A major problem arises with the requirements/constraints, and you decide to abandon the current spec pack (no longer continue clarification/design/implementation).
    • You need to delete:.aisdlc/specs/{CURRENT_BRANCH}/ and that {CURRENT_BRANCH} branch (local + remote).
  • Do not use when
    • You merely want to "roll back a certain commit" or "redo the requirements document": prefer normal git rollback/new commit rather than deleting branches.
    • You are currently not on a spec branch (the branch name does not conform to {num}-{short-name}): switch to the target spec branch first; otherwiseStop。

Hard rules (must be followed)

  • REQUIRED SUB-SKILL: currently executing spec-context to get context, and echo in the conversation FEATURE_DIR=...(allowed (reuse))。
  • Guessing paths/branches is prohibited: only use Get-SpecContext 's CURRENT_BRANCH and FEATURE_DIR。
  • A deletion list must be output: before any deletion command, first output the "list of contents to be deleted" (directories/branches/remote branch existence/overview of uncommitted changes).
  • A second confirmation is required:
    • First confirmation: the user confirms that "the deletion list is correct".
    • Second confirmation: the user confirms that "the specific deletion commands about to be executed are correct".
    • Both confirmations must require the user to reply withexact phrases(see below).
  • Discarding the entire workspace by default is prohibited: you must not suggest/execute git clean -fd such "wipe everything" commands just to take the easy way out.
  • Stop on any validation failure: you must not continue to give "just delete" commands.

Deletion list generation (PowerShell)

This section is only used togenerate the list and risk warnings, and does not execute deletion.

. (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)
}

First confirmation (required)

Show the "deletion list" generated above to the user as-is, then require the user to reply with the following exact phrase:

  • First confirmation phrase:确认删除清单

If the user does not explicitly reply with that phrase (or raises any question/modification),Stop, correct the list first before continuing.

Deletion command preparation (shown only after the first confirmation)

This section still does not perform deletion; it only lists the "commands to be executed" in full as the object of the second confirmation.

. (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)
}

Second confirmation (mandatory)

Require the user, after seeing the "deletion commands to be executed", to reply with the following exact phrase:

  • Second confirmation phrase:最终确认执行删除

Before that phrase is received,it is prohibited toexecute any deletion action.

Execute deletion (only after second confirmation)

Simply execute the commands shown in "Deletion command preparation". After execution, do a minimal acceptance check:

git branch --list $branch
git branch -r | Select-String ("origin/{0}" -f $branch)
Test-Path -LiteralPath $featureDir

Expected:

  • git branch --list $branch no output
  • The remote branch query has no match (if you performed a remote deletion)
  • Test-Path $featureDir is False

Common errors (if any occur, stop according to the hard rules)

  • Skip spec-context: piecing together the path by "looking at the directory/looking at open files/guessing the branch name".
  • Deleting without producing a list: directly giving git branch -D / git push --delete / Remove-Item。
  • Confirming only once: the user saying "just delete it" does not equal completing the second confirmation gate.
  • Using git clean -fd to empty the repository: this is a full wipe and can very easily damage files that are not part of the spec pack.
  • Deleting main / deleting the wrong branch: any branch name that is inconsistent with Get-SpecContext.CURRENT_BRANCH must be stopped.