# Github Stack Amend

> Fold working-tree changes into the current branch commit and re-submit via gh stack. Use when user says "amend this" or "add this to the current PR" on the github stacked-PR provider.

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

---


## What It Does

Amends the current branch's commit with working-tree changes via plain
`git commit --amend`, then re-submits via the runtime adapter's `submit`
operation to push the update (`gh stack submit` re-pushes existing
branches).

## When to Use

- User says "amend this", "add this to the current PR", "fold this fix
  in", or has follow-up edits for an already-submitted branch on the
  github stacked-PR provider.
- Not for starting new work — use the `github-stack-submit` skill instead.

## Usage

The argument text provided after the skill name (if any) is available as
context for this invocation — if it contains a new commit message, use it
in Step 3.

### Step 1: Check State

```bash
git status --short
git diff --stat
git branch --show-current
```

If there are no uncommitted changes, tell the user and exit — there is
nothing to amend.

If the current branch is the trunk branch, warn the user that amending
trunk is dangerous and use `AskUserQuestion` to confirm before proceeding.
Options: "Amend anyway" / "Cancel". On "Cancel", stop.

### Step 2: Stage Specific Files

Do **not** use `git add .`. Enumerate the changed and untracked files
NUL-delimited into a bash array — never interpolate filenames into a
command string, since a crafted filename (containing `$(...)`, backticks,
or a leading `-`) would otherwise execute or be parsed as a flag when
staged:

```bash
mapfile -d '' -t files < <(git diff -z --name-only; git ls-files -z --others --exclude-standard)
```

Exclude `.env*` files, credential files, binaries, and build artifacts
from `files`. Then stage the remaining entries via array expansion:

```bash
git add -- "${files[@]}"
```

### Step 3: Amend

By default, keep the existing commit message:

```bash
git commit --amend --no-edit
```

If the argument text supplied a new commit message, write it to a temp
file and amend from it — never interpolate the new message into a `-m`
string, since it may contain `$(...)`, backticks, or unescaped quotes:

```bash
msgfile="$(mktemp)"
# write the new commit message to "$msgfile"
git commit --amend -F "$msgfile"
```

### Step 4: Re-submit

Call the runtime adapter to push the amended commit:

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

### Step 5: Report

Read the JSON result's `status` field.

- **`SUCCESS`** — report that the branch was amended and re-submitted.
  Quote `stdout` inside the untrusted-content fence below if it contains a
  PR link or other detail worth surfacing:

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

- Any other status — report `status` and `recoveryAction` verbatim. The
  local amend has already happened at this point even if the submit
  fails; say so explicitly.

## Boundaries

- Never amends the trunk branch without explicit `AskUserQuestion`
  confirmation.
- Never `git add .` or `git add -A` — files are staged by name only.
- Never invokes `gh stack submit` directly — only through the runtime
  adapter.

