SuperAPI AI Directory

spec-pack-abandon

General & other

View repository

Updated 10-16 08:49

About this skill

spec-pack-abandon (Abandon/Revoke Spec Pack: list + two-step 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 execute spec-context to obtain context and precisely locate {FEATURE_DIR}, then generate a "list of contents to be deleted", and before performing any destructive operation require the user toconfirm twice; 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 and delete the directory and branches after two-step confirmation)."

When to use / when not to 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:.aidlc/specs/{CURRENT_BRANCH}/ and that {CURRENT_BRANCH} branch (local + remote).
  • Do not use when
    • You only want to "revert a certain commit" or "redo the requirements document": prefer normal git revert/new commit rather than deleting branches.
    • Currently not on a spec branch (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 obtain context, and echo in the conversation FEATURE_DIR=...(allowing (reuse))。
  • Do not guess paths/branches: you may only use Get-SpecContext 's CURRENT_BRANCH and FEATURE_DIR。
  • The deletion list must be output: before any deletion command, first output the "list of contents to be deleted" (directory/branches/remote branch existence/overview of uncommitted changes).
  • Two-step confirmation is required:
    • First confirmation: the user confirms "the deletion list is correct".
    • Second confirmation: the user confirms "the specific deletion commands about to be executed are correct".
    • Both confirmations must require the user to reply with theexact phrase(see below).
  • Do not discard the entire workspace by default: you must not suggest/execute git clean -fd commands like "wipe everything" just to save effort.
  • Stop on any validation failure: you must not continue giving commands to "just delete".

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 and then continue.

Deletion command preparation (shown only after the first confirmation)

This section still does not perform deletion; it only lists the "commands about 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 (required)

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

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

Before receiving that phrase,forbiddento execute any deletion action.

Execute deletion (only after second confirmation)

Just execute the commands shown in "Deletion command preparation". After execution, do minimal acceptance checks:

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

Expected:

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

Common errors (stop per hard rules if any occur)

  • Skipping spec-context: assembling paths by "looking at directories/looking at open files/guessing branch names".
  • 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 clear the repository: this is a full wipe and very likely to accidentally damage files that are not the spec pack.
  • Deleting main / deleting the wrong branch: any branch name inconsistent with Get-SpecContext.CURRENT_BRANCH must stop.