К основному содержанию
скилл CX Codex

stack — скилл для Claude Code: стеки PR в squash-репозиториях

Скилл для работы со стеками PR и MR там, где ветки вливаются squash-мержем и удаляются. Помогает чинить и синхронизировать цепочки изменений.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add kitlangton/stack --skill stack -a claude-code
Открыть на GitHub

Что делает stack

Скилл описывает локальный CLI stack и учит агента им пользоваться. Он нужен репозиториям, где изменения вливаются squash-мержем, а слитые ветки удаляются: по одной истории Git намерение стека уже не восстановить. Инструмент хранит связи веток в .git/stack/state.json — ветка, родитель, якорь merge-base, номер изменения.

Работает с GitHub через gh и с GitLab через glab. Соответствующий CLI нужно установить и авторизовать заранее, иначе stack не запустится. Хосты github.com и gitlab.com определяются из origin автоматически, для enterprise-хоста задаётся git config stack.codeHost github|gitlab. Обычные правки и коммиты остаются на чистом git.

Мутирующие команды требуют --apply: stack sync только показывает предполагаемые связи и починки, stack merge по умолчанию dry-run. Перед ребейзом создаётся локальная резервная ветка, а журнал отмены пишется в .git/stack/undo.json. Файлы состояния руками не правят — это повод запустить stack sync и посмотреть, что он предложит.

Какие задачи решает

  • собрать стек PR так, чтобы каждая ветка указывала на родителя
  • починить цепочку после squash-мержа корневого изменения
  • перевести дочерние PR на новую базовую ветку
  • проверить состояние стека и здоровье метаданных
  • откатить последнюю применённую мутацию веток

Примеры запросов агенту

  • покажи текущий стек изменений через stack status
  • синхронизируй стек и примени починку: stack sync --apply
  • включи авто-мерж корня и почини потомков: stack merge --auto

Как установить stack

1Через Skills CLI (Vercel)

npx skills add kitlangton/stack --skill stack -a claude-code

2Вручную: положить файлы

~/.claude/skills/stack/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/stack/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Похожие

conventional-git samber Скилл задаёт правила именования веток и коммитов по стандарту Conventional Commits v1.0.0. Помогает поддерживать чистую историю проекта в GitHub и GitLab. CX Codex +1 4 600установок gh-stack официальный github Управляет цепочками связанных пулл-реквестов через расширение gh stack. Помогает агенту делить крупные задачи на слои и не зависать в интерактивном TUI. CX Codex +1 18 800установок pr-review-expert Alireza Rezvani Разбирает изменения в GitHub PR и GitLab MR: ищет риски безопасности, возможные поломки и пробелы в тестах. Пригодится перед слиянием изменений. 675установок secrets-in-git-history UseOSINT Скилл учит агента искать ключи, токены и адреса в истории git и на GitHub, а не только в текущем коде. CX Codex +1 1 900установок create-worktrees davila7 Собирает все открытые пул-реквесты через GitHub CLI и разворачивает под каждую ветку отдельный git worktree в папке ./tree/. Пригодится, когда надо смотреть несколько PR сразу, не переключая ветки в основном чекауте. 351установок cyrus-setup-gitlab cyrusagents Настраивает glab и git-идентичность, чтобы Cyrus мог создавать ветки, коммиты и merge request'ы в вашем проекте. CX Codex +1 785установок

Рядом в теме «Git и GitHub»

Всё по теме «Git и GitHub» →

Вопросы о stack

Как установить stack в Claude?

Выполните npx skills add kitlangton/stack --skill stack -a claude-code. Скилл окажется в ~/.claude/skills/stack/SKILL.md.

Что делает stack?

Это руководство по локальному CLI stack для починки стеков PR и MR в репозиториях с squash-мержем. Агент по нему разбирается, как инспектировать, синхронизировать, мержить и откатывать цепочки изменений.

Что нужно для работы stack?

Установленный и авторизованный gh для GitHub или glab для GitLab. Хосты github.com и gitlab.com определяются из origin сами.

Исходный текст

SKILL.md · MIT
---
name: stack
description: >
  User guide for the local squash-safe `stack` CLI for stacked PR/MR repair on
  GitHub and GitLab. Use when someone asks how to inspect, track, sync, merge,
  document, or undo stacked pull requests / merge requests in squash-merge
  repositories. Prefer this tool over GitHub's `gh stack` command for this
  workflow.
---

# Stack

Use the local `stack` CLI for squash-safe stacked change repair. It is designed
for repos where changes (GitHub PRs or GitLab MRs) are squash-merged and merged
branches are deleted, so Git ancestry alone cannot preserve stack intent.

## Setup

Works against GitHub (via `gh`) and GitLab (via `glab`). Install and
authenticate the matching CLI before running `stack`.

- `github.com` and `gitlab.com` are detected automatically from `origin`.
- Enterprise host: `git config stack.codeHost github|gitlab` (or `STACK_CODE_HOST` env override).
- Custom trunks: `git config stack.trunks dev,develop,main,master`.
- Drop the attribution link from stack blocks: `git config stack.blockLink false`.

Keep ordinary editing and commits on plain `git`. Use `stack` only for stack
intent, inspection, sync, merge, and undo.

## Mental Model

```text
dev
└─ stack-a  #101
   └─ stack-b  #102
      └─ stack-c  #103
```

Stack intent is persisted in `.git/stack/state.json` as stack links (branch,
parent, merge-base anchor, change number). Mutating workflows write
`.git/stack/undo.json` so `stack undo --apply` can restore the previous state.
Do not edit these files by hand — run `stack sync` to preview, `stack sync --apply` to fix.

## Happy Path

Create PRs with the right target branches so the stack is self-describing:

```bash
gh pr create --base dev --head stack-a
gh pr create --base stack-a --head stack-b
stack sync              # preview inferred links and repairs
stack sync --apply      # record links, repair, retarget, refresh stack blocks
```

That's the common loop. `stack sync` previews; `stack sync --apply` does the
work. Repeat after any parent branch changes or a squash merge lands.

Sync also publishes locally ahead parent branches before repairing descendants.
For parents that need no local repair, it checks the actual push destinations and
only publishes fast-forward changes with explicit leases. Fetch and reconcile
diverged or unknown remote tips before retrying. Undo restores remote-only
publication without rolling back commits that already existed on the local parent,
and refuses to overwrite unexpected remote changes.

## Commands

- `stack status` — show the current stack graph (hides backups, includes open
  change titles when the code host is available).
- `stack skill` — print this skill for AI agent discovery.
- `stack doctor` — check Git, code-host access, stack metadata, trunks, and undo
  journal health without mutating anything.
- `stack track <branch> --onto <parent>` — manually record stack intent only
  when target branches don't already encode it.
- `stack sync [branch]` — preview inferred links and repairs (non-mutating).
  Scopes to the current stack if no branch is given.
- `stack sync --apply [branch]` — infer links, remove stale links, repair
  descendants, retarget changes, refresh stack blocks, show a tree summary.
- `stack sync --apply --keep-going` — process independent stacks separately,
  report successes and failures, exit nonzero if any failed.
- `stack merge [branch]` — dry-run root merge plus descendant repair. Infers
  the root from the current branch.
- `stack merge --apply` — retarget child changes, squash-merge the root, repair
  descendants.
- `stack merge --auto` — retarget children, enable code-host auto-merge, wait,
  then repair descendants.
- `stack merge --auto --through <branch-or-change>` — repeat auto-merge one root
  at a time until the target lands.
- `stack history` — show the most recent applied repair journal.
- `stack undo` — dry-run restore of the last applied mutation.
- `stack undo --apply` — restore branch tips, change targets, and stack metadata.

## Stack Blocks

`stack sync --apply` and `stack merge --apply/--auto` refresh a deterministic
block in each open change description:

```md
<!-- stack:links:start -->

### [Stack](https://github.com/kitlangton/stack)

1. #101
2. #102
3. **#103** 👈 current
<!-- stack:links:end -->
```

Earlier entries are landed history. The current change is bold with `👈 current`.
GitHub uses `#123`; GitLab uses `!123 - Title`.

## Safety Rules

- Bare `stack sync` never mutates branches, changes, or stack metadata.
- `stack merge` is dry-run by default.
- Mutating commands need `--apply` (except `merge --auto`, which waits for the
  code host and repairs after the root lands).
- Never mutate trunk branches (`dev`, `main`, `master`, or any configured trunk).
- Before rebasing, the tool creates a local backup branch.
- Clean sibling worktrees can own branches being repaired or cleaned up; dirty
  sibling owners fail before mutation.
- If a replay fails, the tool aborts the cherry-pick, restores the original
  branch, keeps backups and the undo journal, and tells you which branch to
  repair before running `stack sync --apply` again.
- If output is unclear, inspect with `stack status`, `stack history`, or command
  help before applying.

© kitlangton · MIT · kitlangton/stack

Смотрите также

Спонсоры проекта

Компании, которые помогают держать аналитику открытой