一键导入
restack
Propagate a branch's changes down its stacked children by merging the updated parent into each stacked branch, in order from base to tip.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Propagate a branch's changes down its stacked children by merging the updated parent into each stacked branch, in order from base to tip.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Build or modify a Sculptor extension — a runtime ESM module loaded into the Sculptor UI. Use when asked to write an extension (or "plugin") for Sculptor, add a panel, overlay, workspace widget, home view, or settings UI to Sculptor, or to iterate on an extension with `sculpt extension`. Works from any repo; this file is a self-contained reference (the Sculptor source code is optional).
Interact with Sculptor programmatically using the sculpt CLI. Use this skill when using `sculpt`, or when designing or planning a workflow that would benefit from understanding the structural capabilities of `sculpt` (workspaces, agents, isolation, and how code flows between them).
Live, hot-reloading preview of the Sculptor WEB frontend from a phone or any browser, served through the OpenHost nginx /proxy front. ONLY relevant when running INSIDE the openhost-deployed Sculptor (the container fronted by nginx on :5050, reachable at https://sculptor.<zone>/) — NOT for local or Electron dev. Frontend-only: it reuses the single shared backend, so it previews UI/frontend changes, not a per-workspace backend. Invoke when iterating on the web UI and wanting to see it live in a browser through the OpenHost SSO front.
How this OpenHost-hosted Sculptor environment works — storage and what survives restarts, where/how to add repositories and authorize gh, and the /proxy/<port>/ capability for previewing loopback web apps from a browser. ONLY relevant when running inside an OpenHost deployment (detect via the OPENHOST_* env vars, e.g. OPENHOST_APP_NAME). Ships with the deploy image and is refreshed every release.
Test a pull request by creating a shallow clone at the PR's commit and launching Sculptor. Use when you need to test changes from a specific PR in isolation.
QA the Sculptor mobile web UI on a real iOS Simulator, driven headlessly from a Mac. A single CLI boots a notched iPhone, launches the local frontend server (parsing its port — no hardcoding), opens the app in MobileSafari, taps/swipes via idb, and screenshots each step. Includes the Add-to-Home-Screen standalone flow — the only way to verify notch / status-bar / home-indicator safe-area rendering (env(safe-area-inset-*) is 0 everywhere except real iOS). Use when visually verifying mobile/responsive changes on an iPhone.
| name | restack |
| description | Propagate a branch's changes down its stacked children by merging the updated parent into each stacked branch, in order from base to tip. |
| when_to_use | Invoke when you've changed an earlier branch in a stack (created via /sculptor-experimental:stack) and want those commits to flow into the branches stacked on top of it — e.g. "update the stack", "restack", "propagate my changes up the stack", or after committing a fix on a base branch that the later branches build on. It merges each parent's new commits into its children so every branch in the stack ends up with the proper state. |
| user_invocable | true |
ARGUMENTS: $ARGUMENTS
Propagate the current branch's changes into the branches stacked on top of it.
Each stacked branch was created off — and targets — its parent (that's what
/sculptor-experimental:stack sets up), so "propagating" means merging each
parent's updated tip into its child, in order from base to tip.
This is a merge-based restack: it brings the parent's new commits into each
child with a merge commit. It does not rewrite history, so no force-push is
needed and open MRs/PRs keep their commits and review threads. The merge also
keeps each child's scoped diff correct — after merging parent P into child C,
the diff of C against P is exactly C's own changes.
This skill uses the sculpt CLI and operates directly on the shared on-disk git
repo. The agent shell already has SCULPT_WORKSPACE_ID (current workspace) and
SCULPT_PROJECT_ID set.
$ARGUMENTS is optional. It may name a different root branch to propagate from;
if empty, propagate from the current branch.
Restacking only works in worktree workspaces. Every branch in the stack lives
in its own git worktree sharing one on-disk .git, which is what lets this
skill resolve and merge them locally. From a clone or in-place workspace the
stacked branches aren't locally resolvable.
sculpt workspace show "$SCULPT_WORKSPACE_ID" --json | jq -r .strategy
If the result is not WORKTREE, stop and tell the user (using their strategy
name):
Restacking isn't supported from a
<strategy>workspace — the stacked branches aren't locally resolvable. Restack from a worktree workspace instead.
Only proceed if the strategy is WORKTREE.
Resolve the root branch — the branch whose changes you're propagating
down. Use $ARGUMENTS if it names a branch; otherwise the current branch:
git rev-parse --abbrev-ref HEAD
List the project's workspaces (stdout is clean JSON; the human-readable preamble goes to stderr):
sculpt workspace list --json
Each item has id, strategy, source_branch, target_branch,
requested_branch_name, and is_deleted.
Build the stack graph. A workspace C is a stacked child of branch P
when all of:
C.is_deleted is false and C.strategy == "WORKTREE",C.requested_branch_name is set (this is C's own branch), andC.target_branch, with any leading remote prefix stripped, equals P.The target may be stored either bare (my-branch) or remote-qualified
(origin/my-branch) — strip a leading origin/ (or other remote) before
comparing. Starting from the root branch, collect its children, then their
children, and so on, recording edges (parent_branch, child_branch) in
base→tip order (parents before children). Guard against cycles and against
a branch listing itself as its own parent.
Map each branch in the stack to its on-disk worktree path:
git worktree list --porcelain
Match on branch name (strip the refs/heads/ prefix). Skip — with a warning —
any stacked branch that has no live worktree (e.g. its workspace was deleted);
also skip its descendants, since their parent can't be resolved.
If the root has no stacked children, report that nothing is stacked on it and stop.
Show the user the discovered stack as a tree (root at the bottom of the stack, descendants above) before changing anything.
Root branch must be committed. Only committed work propagates. In the current worktree:
git status --porcelain
If non-empty, list the affected paths and ask via the AskUserQuestion tool
(mcp__sculptor__ask_user_question) whether to commit them first (infer a concise
message and run git add -A && git commit -m "<msg>", surfacing the message), or
proceed propagating only the already-committed work, or abort.
Dirty stacked branches. A merge won't run cleanly on a dirty tree. Check each child's worktree:
git -C "<child-worktree>" status --porcelain
If any stacked branch is dirty, do not pick a policy yourself — list the dirty
branches and ask the user how to resolve via the AskUserQuestion tool
(mcp__sculptor__ask_user_question), offering at least:
git -C <wt> stash push -u before that branch's merge,
git -C <wt> stash pop after (warn that the pop can itself conflict).Note any stacked workspace with an actively-running agent: merging under a busy agent can disrupt its working tree. The dirty check guards uncommitted work, but flag busy agents so the user can pause them if needed.
Process edges in base→tip order, so each parent is finalized before its children.
For each edge (P, C) (where <C-worktree> is C's worktree path), merge the
parent's current tip into the child:
git -C "<C-worktree>" merge --no-edit "<P>"
Because edges are processed top-down, by the time you merge P into C the
parent P has already received everything below it, so C transitively gets the
whole chain's changes. git merge brings in only what C doesn't already have
(it merges from the current merge-base), so there's no duplication.
Already up to date — git reports "Already up to date."; record C as unchanged (nothing new below it).
Merged — record C's new merge-commit SHA.
Conflict — abort and don't leave a half-finished merge:
git -C "<C-worktree>" merge --abort
Mark C as conflicted, skip all of C's descendants (their parent didn't update), and continue with branches not under C.
If "Stash & re-apply" was chosen for a dirty branch, stash before its merge and pop after (report if the pop conflicts).
Summarize the result as a tree, with per-branch status:
git -C <wt> merge <P>) so the user can resolve it.Merging does not rewrite history, so the updated branches need no force-push —
a normal git push from each branch's workspace adds the new merge commit to its
MR/PR when the user is ready. Leave pushing to them.