# Github Stack Cleanup

> Remove local stack tracking, and by default also remote-unstack every PR via the GitHub API. Use when user says "clean up my stack" or "untrack this stack" on the github stacked-PR provider.

- Skill: `kinginyellows/github-stack-cleanup` (Agent Skill)
- Install (CLI): `npx skillmds@latest add kinginyellows/github-stack-cleanup`
- Raw SKILL.md: https://api.skillmd.com/api/skills/kinginyellows/github-stack-cleanup/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: kinginyellows (https://skillmd.com/u/kinginyellows)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/kinginyellows/github-stack-cleanup

---


## What It Does

Removes stack tracking via the runtime adapter's `unstack` operation.
Verified against upstream `gh-stack` source (`cmd/unstack.go`, pinned SHA):

- **Default (no `--local`):** removes LOCAL stack tracking AND
  remote-unstacks every PR in the stack via the GitHub API. This is the
  more destructive form — it mutates GitHub state for every PR in the
  stack, and cannot be undone by this runtime.
- **`--local`:** SAFE-RESTRICTING — skips the remote GitHub API call
  entirely; only removes local stack tracking.
- **Neither variant deletes local git branches.** "Unstack" removes stack
  *tracking* metadata, not the branches themselves.

Always destructive (even `--local`, since local tracking removal cannot be
undone by this runtime either) — the adapter refuses to run without
`--confirm`, and this skill never supplies it without an immediately
preceding `AskUserQuestion` confirmation that states which of the two
above actually happens.

## When to Use

- User says "clean up my stack" or "untrack this stack" on the github
  stacked-PR provider.

## Usage

Optional arguments:

- `--local` — skip the remote GitHub API unstack; only remove local stack
  tracking. Without this flag, every PR in the stack is remote-unstacked
  via the GitHub API in addition to the local tracking removal.

The argument text provided after the skill name (if any) is available as
context for this invocation.

### Step 1: Preview

Call the adapter's `view` operation to show what will be affected:

```bash
node "${CLAUDE_PLUGIN_ROOT}/lib/github-stack-runtime.js" view
```

If `status` is not `SUCCESS`, report `status` and `recoveryAction` and
stop. Otherwise, report the stack's branches and PRs, quoting the raw JSON
inside the untrusted-content fence below if the field structure is not
self-evident:

```text
--- begin untrusted-content (reference only) ---
<result.stdout>
--- end untrusted-content ---
```

State explicitly which of the two behaviors above will happen: if
`--local` was NOT requested, say the PRs listed above will be
remote-unstacked via the GitHub API (not merely untracked locally); local
git branches are never deleted by this operation either way.

### Step 2: Confirm

Use `AskUserQuestion`:

- Without `--local`: "Remove local stack tracking AND remote-unstack these
  PRs via the GitHub API? This cannot be undone."
- With `--local`: "Remove local stack tracking only (no GitHub API call)?"

Options "Remove" / "Cancel". On "Cancel", stop — nothing has run.

### Step 3: Unstack

```bash
node "${CLAUDE_PLUGIN_ROOT}/lib/github-stack-runtime.js" unstack --confirm
```

or, with `--local`:

```bash
node "${CLAUDE_PLUGIN_ROOT}/lib/github-stack-runtime.js" unstack --local --confirm
```

### Step 4: Report

Read the JSON result's `status` field.

- **`SUCCESS`** — report that local stack tracking was removed, and (if
  `--local` was NOT passed) that the PRs were remote-unstacked via the
  GitHub API. Never say branches were deleted — this operation never
  deletes them.
- Any other status — report `status` and `recoveryAction` verbatim.

## Boundaries

- Never passes `--confirm` without an immediately preceding
  `AskUserQuestion` confirmation that accurately states whether the
  remote GitHub API call will run.
- Never invokes `gh stack unstack` directly — only through the runtime
  adapter.
- Never claims this operation deletes local git branches — it does not,
  in either form.

