[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KM0C6MMDMQWH73CMWTPCY2":3,"skill-same:01M6KM0C6MMDMQWH73CMWTPCY2":82},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":28,"publishedAt":49,"linkOnly":50,"markdownContent":51,"markdownBody":52,"frontMatter":53,"refName":55,"commitSha":56,"skillDirectory":57,"forksCount":58,"repositoryHtmlUrl":59,"repositoryHomepageUrl":6,"ownerHtmlUrl":60,"ownerBlogUrl":6,"ownerDescription":61,"updatedAt":62,"install":63,"resources":75},"01M6KM0C6MMDMQWH73CMWTPCY2","code-gt-restack-resolve",null,"Restack the current Graphite stack with conflict resolution — downstack by default, full stack on explicit request. Auto-merge mechanically-safe conflicts (verified with project checks), escalate ambiguous ones. Use for 'restack and resolve conflicts', 'intelligent\u002Fauto restack', 'full restack', 'whole-stack restack', 'downstack restack', or a restack expected to conflict.","nseng-ai\u002Fns","nseng-ai","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F273792438?v=4","01M6KKN105A07WPV2TZKZXZGQF","nseng.ai","01M6KKN14MDSR9VF9739AWXG8M",2,"MIT","https:\u002F\u002Fgithub.com\u002Fnseng-ai\u002Fns\u002Fblob\u002Fmaster\u002Fskills\u002Finternal\u002Fcode\u002Fcode-gt-restack-resolve\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48],"code","code gt restack resolve","resolution","merge","request","expected","for","true","with","escalate","graphite","stack","conflict","project","full stack","conflicts","default","conflict resolution","auto","use","2026-11-10 10:12:30",false,"---\nname: code-gt-restack-resolve\ndisable-model-invocation: true\ndescription: \"Restack the current Graphite stack with conflict resolution — downstack by default, full stack on explicit request. Auto-merge mechanically-safe conflicts (verified with project checks), escalate ambiguous ones. Use for 'restack and resolve conflicts', 'intelligent\u002Fauto restack', 'full restack', 'whole-stack restack', 'downstack restack', or a restack expected to conflict.\"\n---\n\n# code-gt-restack-resolve\n\nDrive a Graphite restack semi-autonomously with an explicit **scope**:\n**downstack** (ancestors + current) by default, or **full stack** when the\nuser explicitly asks for the whole stack.\n\nThis skill is a **parent-session driver**: the main agent session owns the\nrestack workflow — preflight, scope, slot consolidation, starting or resuming\nthe loop, interpreting subagent reports, user-facing escalation, final\nvalidation, and gt-specific bail-outs. Each individual conflict stop is\ndelegated to one fresh, same-worktree subagent that follows the engine skill,\n**`code-resolve-merge-conflicts`**\n(`skills\u002Fincubating\u002Fcode\u002Fcode-resolve-merge-conflicts\u002FSKILL.md`), with the **Engine parameters**\nbelow. Do not restate or improvise per-file resolution policy here.\n\nIt also defers to **`code-graphite`** for the `gt` mental model, stack navigation,\nand the \"Recovering from Interrupted Rebase\" section.\n\n## Harness entry points\n\n- **Pi users:** `\u002Fcode:gt-restack-resolve` is the single command entry point.\n  The Pi command is a thin deterministic wrapper: it checks for an interrupted\n  rebase, runs plain `gt restack` when safe, and invokes this skill only when\n  conflict resolution is needed.\n- **Claude Code, Codex, and other harnesses:** invoke this skill directly. Do\n  not depend on the Pi wrapper. Follow the workflow below from the current\n  repository state: if no rebase is in progress, start the selected restack;\n  if a restack\u002Frebase is already interrupted, resume from that state.\n\n## Engine parameters\n\nThe driver facts the engine consumes — continue command, extra bail-out\ncondition (any conflict in a branch **outside the selected scope**, e.g. an\nupstack branch during downstack scope or a sibling\u002Funrelated stack during any\nscope), escalation channel (`return-to-parent`; an escalating subagent leaves\nthe rebase stopped, returns the engine's structured payload, and does not run\n`gt continue`) — travel in the **Agent prompt template** below, which is their\nsingle source. Model selection lives in **Subagent model routing**.\n\nParent-facing post-completion checks: `git status` is clean;\n`ns slot gt exec stack-branches --format json` answers structured topology;\n`gt log` \u002F `gt ls` may be used only as visual confirmation.\n\n\u003C!-- TEMPORARY (TS toolchain rollout) — remove once the oxlint\u002Foxfmt\u002Fnative-tsc\n     toolchain commits have fully landed and no longer sit unrebased under\n     active stacks. -->\n\n## TEMPORARY: TS toolchain-rollout conflicts\n\nWhile the TypeScript toolchain rollout (pnpm 11 \u002F oxlint \u002F oxfmt \u002F native-tsc)\nis still propagating through stacks, restacks hit a recurring conflict shape: a\n**formatting-only** oxfmt reflow of the *old* code replays onto a base that\ngained real feature logic on the same statements. The operative resolution rule\nlives in the TEMPORARY block of the **Agent prompt template** below and travels\nverbatim in every conflict subagent's prompt; it is the only auto-resolution the\ndriver may apply without escalating.\n\n## Scope and non-goals\n\n- **Scope must be explicit.** Default to **downstack** for generic restack\n  requests; use **full** only when the user explicitly asks for the whole\n  stack or confirms a prompt.\n- **A single-PR (or tip) stack has no scope decision** — see the single-PR rule\n  in **Choose scope**.\n- **Full scope:** operate on the current Graphite stack as `gt restack` does\n  (ancestors + current + descendants) — not every stack in the repo. It may\n  rewrite upstack descendants, which is why it requires explicit intent.\n- **Downstack scope:** operate on the chain trunk → current (ancestors +\n  current). Upstack is not touched.\n- **Never** `gt submit` \u002F push \u002F land.\n- **Never** touch sibling stacks. Upstack descendants are in scope only for a\n  full restack.\n- **Never** `gt abort` without explicit confirmation (engine abort policy).\n\n## Workflow\n\n### 0. Verify inherited interruption context\n\nThe Pi wrapper may invoke this skill with one of two authoritative context\nstatements: structured full-scope preflight already reported\n`rebaseInProgress=true`, or full-scope preflight passed and the wrapper then ran\n`gt restack` without completing cleanly. Treat either statement as inherited\nevidence that must be refreshed, not as permission to assume repository state.\n\nBefore normal preflight, run `git status` as the `code-graphite` skill's interrupted\nrebase context reset requires. Skip preflight only when that fresh status\nconfirms a rebase is still in progress (including a rebase stopped at unmerged\nconflicts). In that confirmed wrapper path:\n\n- set `RESTACK_SCOPE=full`, because the wrapper always requests full semantics;\n- do not run `ns slot gt exec restack-preflight` again;\n- do not start another `gt restack`;\n- jump directly to the **Loop** and continue from the observed state.\n\nIf fresh status does not confirm an interrupted rebase, the wrapper context is\nstale or the failed command did not stop a rebase. Fall back to **Preflight and\nscope facts**. Never start another `gt restack` solely because the handoff says\nthe fast path failed; only the normal preflight and scope workflow may authorize\na new start.\n\nDirect skill invocations without either wrapper context always begin with\nnormal preflight. User prose that merely speculates about a conflict is not\nwrapper context and does not bypass preflight.\n\n### 1. Preflight and scope facts\n\nUnless step 0 confirmed a wrapper-originated interrupted rebase, first map the\nrequest to `REQUESTED_SCOPE`: generic or ambiguous restack intent is\n`downstack`; explicit whole-stack intent is `full`. Gather all cleanliness,\ntracking, interrupted-rebase, topology, and Slot occupancy facts in one call:\n\n```bash\nns slot gt exec restack-preflight --scope \u003Cfull|downstack> --format json\n```\n\nAlways replace the placeholder explicitly: generic requests pass\n`--scope downstack`; explicit whole-stack requests pass `--scope full`. Pass\nthe scope even when it matches the command's own default.\n\nInterpret the Clinkr envelope before acting:\n\n- `status: \"ok\"` carries usable preflight `data`, including the expected resume\n  state `rebaseInProgress: true`: an in-progress rebase in the current worktree\n  is an ok\u002Fexit-0 answer, not a blocked result, even though the tree is dirty\n  and the rebase appears in `slotConflicts`.\n- A nonzero `status: \"negative\"` is an expected blocked\u002Fprecondition result\n  (untracked branch, dirty tree without a current rebase, foreign Slot\n  conflicts, on-trunk) and still carries usable `data`; inspect it rather than\n  treating the exit code alone as a command failure.\n- `status: \"failure\"`, missing\u002Funparseable JSON, or malformed\u002Fmissing required\n  fields is not usable preflight evidence. Stop and report the envelope\u002Ferror;\n  do not restack or free slots.\n\nThe stable `data` fields are:\n\n- `clean`: whether the current worktree has no uncommitted changes;\n- `tracked`: whether the current branch is present in Graphite metadata;\n- `rebaseInProgress`: whether the current worktree is already in a rebase;\n- `hasUpstackChildren`: whether full scope differs from downstack scope;\n- `requestedScope` and `effectiveScope`: the explicit request and the scope the\n  helper could inspect (`full` collapses to `downstack` at a tip);\n- `branches`: all in-scope branches, bottom-to-top, including current;\n- `slotConflicts`: in-scope occupancy\u002Frebase conflicts; each entry identifies\n  its branch and type and gives the conflicting path in `worktreePath` (plus\n  operation\u002FSlot details when applicable);\n- `warnings`: non-fatal topology\u002Fmetadata warnings to surface and account for.\n\nIf `rebaseInProgress` is true, do **not** start a new restack or free stack\nslots. Jump straight to the **Loop** at the resolve step, following the\n`code-graphite` skill's \"Recovering from Interrupted Rebase (Context Reset)\"\nsection. Otherwise, if `tracked` is false, stop with the helper's `gt track`\nguidance. If `clean` is false, stop and ask the user to commit or stash first.\nReview all warnings before continuing.\n\n### 2. Choose scope\n\nSet `RESTACK_SCOPE` from the explicit request and the returned scope facts before\nrunning any restack command.\n\n| User intent                                                                                | Scope                 | Slot consolidation command          | Restack command          |\n| ------------------------------------------------------------------------------------------ | --------------------- | ----------------------------------- | ------------------------ |\n| Generic \"restack and resolve\", \"restack\", \"intelligent\u002Fauto restack\", or ambiguous request | `downstack` (default) | `ns slot gt free-stack --downstack` | `gt restack --downstack` |\n| Explicit \"full restack\", \"whole-stack restack\", \"restack everything\", or confirmed prompt  | `full`                | `ns slot gt free-stack`             | `gt restack`             |\n\nRules:\n\n- **Single-PR \u002F tip stacks: never ask about scope.** When\n  `hasUpstackChildren` is false, full and downstack are the **same** operation:\n  skip the scope question entirely and run plain `gt restack` (no `--downstack`\n  needed — the result is identical). There are no upstack slots to free either,\n  so skip the consolidation prompt too unless `slotConflicts` reports an\n  in-scope **ancestor** in another worktree.\n- When in doubt, ask — **but only when scope actually changes the outcome**\n  (i.e., the current branch has upstack descendants).\n- Do not auto-checkout to the tip. Run the command from the user's current\n  branch unless they explicitly ask to move first.\n\n### 3. Multi-slot consolidation\n\nIn this repo a stack's branches can be checked out across multiple worktree\n**slots**, which locks them against rebasing. A restack can fail when another\nslot has a branch in the selected scope checked out, so run the slot\nconsolidation command from the **Choose scope** table before looping.\n\nUse `slotConflicts` from preflight to identify the worktree path and branch that\nmust be released. In the single-PR \u002F tip case, skip this step per the single-PR\nrule in **Choose scope**, unless an in-scope ancestor conflict is reported.\n\nThe `ns slot gt free-stack` command is **mutating**: it releases matching slots by\ndetaching them at trunk — `--format json` is a machine-readable record of what\nwas freed, not a dry-run. If the user has not already authorized freeing stack\nslots, ask before running it.\n\n### 4. Loop\n\nIf no rebase is currently in progress, start the restack with the command\nchosen in **Choose scope**. If a rebase is already interrupted, skip the start\ncommand and continue from the current conflict state.\n\nAfter starting or resuming, run `git status` in the parent session to identify\nthe current state. In the happy path, the count invariant is: **one conflict\nstop = one engine run = one `gt continue` = one subagent**. Escalation adds a\nparent user round-trip and a follow-up subagent for that same stop.\n\nWhile the restack is stopped at conflicts:\n\n1. Launch exactly one fresh, same-worktree subagent for the current conflict\n   stop using the **Agent prompt template** below and the **Subagent model\n   routing** policy below. Do not launch conflict subagents in parallel; the\n   current `gt continue` determines whether another conflict stop exists.\n2. Await that subagent completely before launching any other subagent.\n3. Inspect the subagent's final text\u002Fstatus, then re-run `git status` in the\n   parent session. Do not blindly trust the final text.\n4. Do not propagate an unverified behavior diagnosis or pre-existing failure\n   claim as fact. If a subagent reports `behavior_evidence: unverified` or\n   `preexisting_failure_evidence: unverified`, either independently verify the\n   claim before using it as context\u002Fwhitelist, or preserve the `unverified`\n   label when asking the user, launching the next subagent, or summarizing.\n   Unverified claims cannot become failure whitelists.\n5. Branch on the observed outcome:\n   - **advanced:** `gt continue` succeeded but the restack stopped again on a\n     later conflict. Loop and launch a new subagent for that next stop.\n   - **completed:** the restack completed. Proceed to **Done**.\n   - **escalation:** ask the user in the parent conversation using the returned\n     payload. Then launch a fresh follow-up subagent for the same stop, seeded\n     with the user's decision, to apply the resolution, stage files, run\n     `gt continue`, and report back. Re-run `git status` again afterward.\n   - **bail:** stop and summarize what was resolved, what remains, and the\n     exact command\u002Fstate stopped at.\n\nIf `git status` shows no rebase in progress and no conflicts after the initial\nrestack command returns successfully, proceed directly to **Done**.\n\n### Subagent model routing\n\nConflict-resolution subagents edit code in an interrupted rebase and decide\nwhether a merge is mechanically safe. They are implementation subagents, not\nbounded classification or review helpers, so do not route them to the\ncheap\u002Ffast model tier.\n\nWhen the harness supports per-dispatch model selection, request the model below\nfor these restack conflict subagents. Concrete examples:\n\n- Claude Code: launch the `Agent` conflict-resolution subagent on Opus\n  (use the Claude Code `opus` selector available in the current installation).\n- OpenAI Codex-backed Pi: call `subagent` with `agent: \"task\"` and set `model` to\n  `openai-codex\u002Fgpt-5.6-sol:high` (or the local equivalent Sol model pattern).\n- Anthropic-backed Pi: call `subagent` with `agent: \"task\"` and set `model` to\n  the current `claude-opus` model (or the local equivalent Opus model pattern).\n\nIf per-dispatch model selection is unavailable, continue with the session's\ncurrent model but mention that no explicit smart model could be requested.\n\n### Agent prompt template\n\nUse this structure for each sequential conflict-resolution subagent. Fill in\n`RESTACK_SCOPE` from **Choose scope** and include any user decision when this is\na follow-up subagent after escalation.\n\n```text\nYou are resolving one conflict stop for a Graphite restack that is already in\nprogress in this same worktree.\n\nOrchestrator-decided facts:\n- RESTACK_SCOPE: \u003Cfull|downstack>\n- Continue command: gt continue\n- Extra bail-out condition: any conflict in a branch outside RESTACK_SCOPE\n- Escalation channel: return-to-parent\n\nFollow skills\u002Fincubating\u002Fcode\u002Fcode-resolve-merge-conflicts\u002FSKILL.md as the conflict-resolution\nengine with those driver parameters.\n\nTEMPORARY (TS toolchain rollout): if a conflict is purely a formatting-only\noxfmt\u002Ftoolchain reflow of the OLD code shape replaying onto a base that gained\nreal feature logic on the same statements, resolve it deterministically by\nKEEPING the base (HEAD) logic verbatim, discarding the reverted incoming code,\nthen re-applying formatting by running `just ts-format-fix` (not by\nhand-wrapping). This is the only \"keep + reformat\" auto-resolution allowed; any\nconflict where the incoming side carries genuine logic still escalates.\n\nAgent-decided work:\n- Inspect git status and identify the current stopped commit and conflicted\n  files.\n- Classify conflict regions using only the engine's safe categories.\n- Edit only conflict regions, except generated files as allowed by the engine.\n- Run the engine verification gate and conflict-marker sweep.\n- Stage resolved files.\n- Run gt continue if and only if verification passes and no escalation or\n  bail-out condition blocks it.\n- After gt continue, inspect git status only enough to classify the outcome.\n\nHard constraints:\n- Do not prompt the user.\n- Do not abort the rebase\u002Frestack.\n- Do not resolve conflicts outside the current conflict stop.\n- Run gt continue at most once. This is an audit boundary: if that continue\n  reaches a new conflict stop, do not resolve it; return outcome=advanced with\n  the new repository state.\n- Do not use whole-file checkout except for generated files as allowed by the\n  engine.\n\nOutput contract: end with this delimited result block, filling every line for\nall outcomes:\n--- CONFLICT SUBAGENT RESULT ---\noutcome: advanced | completed | escalation | bail\nfiles_resolved: \u003Cpaths or none>\nsafe_categories_used: \u003Ccategories or none>\nverification: \u003Ccommands and pass\u002Ffail results>\ngt_continue_ran: yes | no\ntraceability_check: \u003Cbase|incoming|intent-diff|mechanical-propagation|mixed; note \"no novel logic\" or describe any novel logic>\nbehavior_evidence: \u003Cnot_applicable | observed: \u003Ccommand + concise output> | unverified: \u003Creason>>\npreexisting_failure_evidence: \u003Cnot_applicable | observed: \u003Cbase_sha + command + concise output> | unverified: \u003Creason>>\nsummary: \u003Cconcise summary>\n\nFor outcome=escalation, also include:\naffected_file: \u003Cpath>\nboth_sides: \u003Cconcise conflict-region summary or quoted snippets>\nintent_diff_summary: \u003Cwhat the incoming commit intended>\nproposed_resolution: \u003Cproposal and reasoning>\nwhy_outside_safe_set: \u003Creason>\ncurrent_repository_state: \u003Cgit status summary>\n--- END CONFLICT SUBAGENT RESULT ---\n```\n\n### 5. Done\n\nWhen the selected restack command reports there is nothing left to restack:\n\n- Run a final `git status` (clean) and `ns slot gt exec stack-branches --format json`\n  for structured topology confirmation. `gt log` \u002F `gt ls` may be shown as\n  human visual confirmation only.\n- Regenerate any auto-generated files that were touched (per\n  `code-resolve-merge-conflicts` step 7) and stage\u002Fcommit them as appropriate.\n- For a **full-scope** restack, the final-verification rule is binary: if any\n  conflict was resolved anywhere in the restack, run a final scoped\n  verification from the stack tip after the restack completes; if the whole\n  restack replayed conflict-free, skip it. This covers upstack branches that\n  replayed without conflicts but now sit atop resolved code. Use the engine's\n  step-4 check rule\n  (`code-resolve-merge-conflicts`, \"Verify before continuing\"), scoped by the\n  file types conflicted across the whole restack.\n\n### 6. Bail-out\n\nThe engine's bail-out policy applies, plus this driver's extra condition from\n**Engine parameters** (a conflict outside the selected scope). Summarize per\nthe engine: what was resolved, what remains, and the exact command\u002Fstate you\nstopped at.\n","# code-gt-restack-resolve\n\nDrive a Graphite restack semi-autonomously with an explicit **scope**:\n**downstack** (ancestors + current) by default, or **full stack** when the\nuser explicitly asks for the whole stack.\n\nThis skill is a **parent-session driver**: the main agent session owns the\nrestack workflow — preflight, scope, slot consolidation, starting or resuming\nthe loop, interpreting subagent reports, user-facing escalation, final\nvalidation, and gt-specific bail-outs. Each individual conflict stop is\ndelegated to one fresh, same-worktree subagent that follows the engine skill,\n**`code-resolve-merge-conflicts`**\n(`skills\u002Fincubating\u002Fcode\u002Fcode-resolve-merge-conflicts\u002FSKILL.md`), with the **Engine parameters**\nbelow. Do not restate or improvise per-file resolution policy here.\n\nIt also defers to **`code-graphite`** for the `gt` mental model, stack navigation,\nand the \"Recovering from Interrupted Rebase\" section.\n\n## Harness entry points\n\n- **Pi users:** `\u002Fcode:gt-restack-resolve` is the single command entry point.\n  The Pi command is a thin deterministic wrapper: it checks for an interrupted\n  rebase, runs plain `gt restack` when safe, and invokes this skill only when\n  conflict resolution is needed.\n- **Claude Code, Codex, and other harnesses:** invoke this skill directly. Do\n  not depend on the Pi wrapper. Follow the workflow below from the current\n  repository state: if no rebase is in progress, start the selected restack;\n  if a restack\u002Frebase is already interrupted, resume from that state.\n\n## Engine parameters\n\nThe driver facts the engine consumes — continue command, extra bail-out\ncondition (any conflict in a branch **outside the selected scope**, e.g. an\nupstack branch during downstack scope or a sibling\u002Funrelated stack during any\nscope), escalation channel (`return-to-parent`; an escalating subagent leaves\nthe rebase stopped, returns the engine's structured payload, and does not run\n`gt continue`) — travel in the **Agent prompt template** below, which is their\nsingle source. Model selection lives in **Subagent model routing**.\n\nParent-facing post-completion checks: `git status` is clean;\n`ns slot gt exec stack-branches --format json` answers structured topology;\n`gt log` \u002F `gt ls` may be used only as visual confirmation.\n\n\u003C!-- TEMPORARY (TS toolchain rollout) — remove once the oxlint\u002Foxfmt\u002Fnative-tsc\n     toolchain commits have fully landed and no longer sit unrebased under\n     active stacks. -->\n\n## TEMPORARY: TS toolchain-rollout conflicts\n\nWhile the TypeScript toolchain rollout (pnpm 11 \u002F oxlint \u002F oxfmt \u002F native-tsc)\nis still propagating through stacks, restacks hit a recurring conflict shape: a\n**formatting-only** oxfmt reflow of the *old* code replays onto a base that\ngained real feature logic on the same statements. The operative resolution rule\nlives in the TEMPORARY block of the **Agent prompt template** below and travels\nverbatim in every conflict subagent's prompt; it is the only auto-resolution the\ndriver may apply without escalating.\n\n## Scope and non-goals\n\n- **Scope must be explicit.** Default to **downstack** for generic restack\n  requests; use **full** only when the user explicitly asks for the whole\n  stack or confirms a prompt.\n- **A single-PR (or tip) stack has no scope decision** — see the single-PR rule\n  in **Choose scope**.\n- **Full scope:** operate on the current Graphite stack as `gt restack` does\n  (ancestors + current + descendants) — not every stack in the repo. It may\n  rewrite upstack descendants, which is why it requires explicit intent.\n- **Downstack scope:** operate on the chain trunk → current (ancestors +\n  current). Upstack is not touched.\n- **Never** `gt submit` \u002F push \u002F land.\n- **Never** touch sibling stacks. Upstack descendants are in scope only for a\n  full restack.\n- **Never** `gt abort` without explicit confirmation (engine abort policy).\n\n## Workflow\n\n### 0. Verify inherited interruption context\n\nThe Pi wrapper may invoke this skill with one of two authoritative context\nstatements: structured full-scope preflight already reported\n`rebaseInProgress=true`, or full-scope preflight passed and the wrapper then ran\n`gt restack` without completing cleanly. Treat either statement as inherited\nevidence that must be refreshed, not as permission to assume repository state.\n\nBefore normal preflight, run `git status` as the `code-graphite` skill's interrupted\nrebase context reset requires. Skip preflight only when that fresh status\nconfirms a rebase is still in progress (including a rebase stopped at unmerged\nconflicts). In that confirmed wrapper path:\n\n- set `RESTACK_SCOPE=full`, because the wrapper always requests full semantics;\n- do not run `ns slot gt exec restack-preflight` again;\n- do not start another `gt restack`;\n- jump directly to the **Loop** and continue from the observed state.\n\nIf fresh status does not confirm an interrupted rebase, the wrapper context is\nstale or the failed command did not stop a rebase. Fall back to **Preflight and\nscope facts**. Never start another `gt restack` solely because the handoff says\nthe fast path failed; only the normal preflight and scope workflow may authorize\na new start.\n\nDirect skill invocations without either wrapper context always begin with\nnormal preflight. User prose that merely speculates about a conflict is not\nwrapper context and does not bypass preflight.\n\n### 1. Preflight and scope facts\n\nUnless step 0 confirmed a wrapper-originated interrupted rebase, first map the\nrequest to `REQUESTED_SCOPE`: generic or ambiguous restack intent is\n`downstack`; explicit whole-stack intent is `full`. Gather all cleanliness,\ntracking, interrupted-rebase, topology, and Slot occupancy facts in one call:\n\n```bash\nns slot gt exec restack-preflight --scope \u003Cfull|downstack> --format json\n```\n\nAlways replace the placeholder explicitly: generic requests pass\n`--scope downstack`; explicit whole-stack requests pass `--scope full`. Pass\nthe scope even when it matches the command's own default.\n\nInterpret the Clinkr envelope before acting:\n\n- `status: \"ok\"` carries usable preflight `data`, including the expected resume\n  state `rebaseInProgress: true`: an in-progress rebase in the current worktree\n  is an ok\u002Fexit-0 answer, not a blocked result, even though the tree is dirty\n  and the rebase appears in `slotConflicts`.\n- A nonzero `status: \"negative\"` is an expected blocked\u002Fprecondition result\n  (untracked branch, dirty tree without a current rebase, foreign Slot\n  conflicts, on-trunk) and still carries usable `data`; inspect it rather than\n  treating the exit code alone as a command failure.\n- `status: \"failure\"`, missing\u002Funparseable JSON, or malformed\u002Fmissing required\n  fields is not usable preflight evidence. Stop and report the envelope\u002Ferror;\n  do not restack or free slots.\n\nThe stable `data` fields are:\n\n- `clean`: whether the current worktree has no uncommitted changes;\n- `tracked`: whether the current branch is present in Graphite metadata;\n- `rebaseInProgress`: whether the current worktree is already in a rebase;\n- `hasUpstackChildren`: whether full scope differs from downstack scope;\n- `requestedScope` and `effectiveScope`: the explicit request and the scope the\n  helper could inspect (`full` collapses to `downstack` at a tip);\n- `branches`: all in-scope branches, bottom-to-top, including current;\n- `slotConflicts`: in-scope occupancy\u002Frebase conflicts; each entry identifies\n  its branch and type and gives the conflicting path in `worktreePath` (plus\n  operation\u002FSlot details when applicable);\n- `warnings`: non-fatal topology\u002Fmetadata warnings to surface and account for.\n\nIf `rebaseInProgress` is true, do **not** start a new restack or free stack\nslots. Jump straight to the **Loop** at the resolve step, following the\n`code-graphite` skill's \"Recovering from Interrupted Rebase (Context Reset)\"\nsection. Otherwise, if `tracked` is false, stop with the helper's `gt track`\nguidance. If `clean` is false, stop and ask the user to commit or stash first.\nReview all warnings before continuing.\n\n### 2. Choose scope\n\nSet `RESTACK_SCOPE` from the explicit request and the returned scope facts before\nrunning any restack command.\n\n| User intent                                                                                | Scope                 | Slot consolidation command          | Restack command          |\n| ------------------------------------------------------------------------------------------ | --------------------- | ----------------------------------- | ------------------------ |\n| Generic \"restack and resolve\", \"restack\", \"intelligent\u002Fauto restack\", or ambiguous request | `downstack` (default) | `ns slot gt free-stack --downstack` | `gt restack --downstack` |\n| Explicit \"full restack\", \"whole-stack restack\", \"restack everything\", or confirmed prompt  | `full`                | `ns slot gt free-stack`             | `gt restack`             |\n\nRules:\n\n- **Single-PR \u002F tip stacks: never ask about scope.** When\n  `hasUpstackChildren` is false, full and downstack are the **same** operation:\n  skip the scope question entirely and run plain `gt restack` (no `--downstack`\n  needed — the result is identical). There are no upstack slots to free either,\n  so skip the consolidation prompt too unless `slotConflicts` reports an\n  in-scope **ancestor** in another worktree.\n- When in doubt, ask — **but only when scope actually changes the outcome**\n  (i.e., the current branch has upstack descendants).\n- Do not auto-checkout to the tip. Run the command from the user's current\n  branch unless they explicitly ask to move first.\n\n### 3. Multi-slot consolidation\n\nIn this repo a stack's branches can be checked out across multiple worktree\n**slots**, which locks them against rebasing. A restack can fail when another\nslot has a branch in the selected scope checked out, so run the slot\nconsolidation command from the **Choose scope** table before looping.\n\nUse `slotConflicts` from preflight to identify the worktree path and branch that\nmust be released. In the single-PR \u002F tip case, skip this step per the single-PR\nrule in **Choose scope**, unless an in-scope ancestor conflict is reported.\n\nThe `ns slot gt free-stack` command is **mutating**: it releases matching slots by\ndetaching them at trunk — `--format json` is a machine-readable record of what\nwas freed, not a dry-run. If the user has not already authorized freeing stack\nslots, ask before running it.\n\n### 4. Loop\n\nIf no rebase is currently in progress, start the restack with the command\nchosen in **Choose scope**. If a rebase is already interrupted, skip the start\ncommand and continue from the current conflict state.\n\nAfter starting or resuming, run `git status` in the parent session to identify\nthe current state. In the happy path, the count invariant is: **one conflict\nstop = one engine run = one `gt continue` = one subagent**. Escalation adds a\nparent user round-trip and a follow-up subagent for that same stop.\n\nWhile the restack is stopped at conflicts:\n\n1. Launch exactly one fresh, same-worktree subagent for the current conflict\n   stop using the **Agent prompt template** below and the **Subagent model\n   routing** policy below. Do not launch conflict subagents in parallel; the\n   current `gt continue` determines whether another conflict stop exists.\n2. Await that subagent completely before launching any other subagent.\n3. Inspect the subagent's final text\u002Fstatus, then re-run `git status` in the\n   parent session. Do not blindly trust the final text.\n4. Do not propagate an unverified behavior diagnosis or pre-existing failure\n   claim as fact. If a subagent reports `behavior_evidence: unverified` or\n   `preexisting_failure_evidence: unverified`, either independently verify the\n   claim before using it as context\u002Fwhitelist, or preserve the `unverified`\n   label when asking the user, launching the next subagent, or summarizing.\n   Unverified claims cannot become failure whitelists.\n5. Branch on the observed outcome:\n   - **advanced:** `gt continue` succeeded but the restack stopped again on a\n     later conflict. Loop and launch a new subagent for that next stop.\n   - **completed:** the restack completed. Proceed to **Done**.\n   - **escalation:** ask the user in the parent conversation using the returned\n     payload. Then launch a fresh follow-up subagent for the same stop, seeded\n     with the user's decision, to apply the resolution, stage files, run\n     `gt continue`, and report back. Re-run `git status` again afterward.\n   - **bail:** stop and summarize what was resolved, what remains, and the\n     exact command\u002Fstate stopped at.\n\nIf `git status` shows no rebase in progress and no conflicts after the initial\nrestack command returns successfully, proceed directly to **Done**.\n\n### Subagent model routing\n\nConflict-resolution subagents edit code in an interrupted rebase and decide\nwhether a merge is mechanically safe. They are implementation subagents, not\nbounded classification or review helpers, so do not route them to the\ncheap\u002Ffast model tier.\n\nWhen the harness supports per-dispatch model selection, request the model below\nfor these restack conflict subagents. Concrete examples:\n\n- Claude Code: launch the `Agent` conflict-resolution subagent on Opus\n  (use the Claude Code `opus` selector available in the current installation).\n- OpenAI Codex-backed Pi: call `subagent` with `agent: \"task\"` and set `model` to\n  `openai-codex\u002Fgpt-5.6-sol:high` (or the local equivalent Sol model pattern).\n- Anthropic-backed Pi: call `subagent` with `agent: \"task\"` and set `model` to\n  the current `claude-opus` model (or the local equivalent Opus model pattern).\n\nIf per-dispatch model selection is unavailable, continue with the session's\ncurrent model but mention that no explicit smart model could be requested.\n\n### Agent prompt template\n\nUse this structure for each sequential conflict-resolution subagent. Fill in\n`RESTACK_SCOPE` from **Choose scope** and include any user decision when this is\na follow-up subagent after escalation.\n\n```text\nYou are resolving one conflict stop for a Graphite restack that is already in\nprogress in this same worktree.\n\nOrchestrator-decided facts:\n- RESTACK_SCOPE: \u003Cfull|downstack>\n- Continue command: gt continue\n- Extra bail-out condition: any conflict in a branch outside RESTACK_SCOPE\n- Escalation channel: return-to-parent\n\nFollow skills\u002Fincubating\u002Fcode\u002Fcode-resolve-merge-conflicts\u002FSKILL.md as the conflict-resolution\nengine with those driver parameters.\n\nTEMPORARY (TS toolchain rollout): if a conflict is purely a formatting-only\noxfmt\u002Ftoolchain reflow of the OLD code shape replaying onto a base that gained\nreal feature logic on the same statements, resolve it deterministically by\nKEEPING the base (HEAD) logic verbatim, discarding the reverted incoming code,\nthen re-applying formatting by running `just ts-format-fix` (not by\nhand-wrapping). This is the only \"keep + reformat\" auto-resolution allowed; any\nconflict where the incoming side carries genuine logic still escalates.\n\nAgent-decided work:\n- Inspect git status and identify the current stopped commit and conflicted\n  files.\n- Classify conflict regions using only the engine's safe categories.\n- Edit only conflict regions, except generated files as allowed by the engine.\n- Run the engine verification gate and conflict-marker sweep.\n- Stage resolved files.\n- Run gt continue if and only if verification passes and no escalation or\n  bail-out condition blocks it.\n- After gt continue, inspect git status only enough to classify the outcome.\n\nHard constraints:\n- Do not prompt the user.\n- Do not abort the rebase\u002Frestack.\n- Do not resolve conflicts outside the current conflict stop.\n- Run gt continue at most once. This is an audit boundary: if that continue\n  reaches a new conflict stop, do not resolve it; return outcome=advanced with\n  the new repository state.\n- Do not use whole-file checkout except for generated files as allowed by the\n  engine.\n\nOutput contract: end with this delimited result block, filling every line for\nall outcomes:\n--- CONFLICT SUBAGENT RESULT ---\noutcome: advanced | completed | escalation | bail\nfiles_resolved: \u003Cpaths or none>\nsafe_categories_used: \u003Ccategories or none>\nverification: \u003Ccommands and pass\u002Ffail results>\ngt_continue_ran: yes | no\ntraceability_check: \u003Cbase|incoming|intent-diff|mechanical-propagation|mixed; note \"no novel logic\" or describe any novel logic>\nbehavior_evidence: \u003Cnot_applicable | observed: \u003Ccommand + concise output> | unverified: \u003Creason>>\npreexisting_failure_evidence: \u003Cnot_applicable | observed: \u003Cbase_sha + command + concise output> | unverified: \u003Creason>>\nsummary: \u003Cconcise summary>\n\nFor outcome=escalation, also include:\naffected_file: \u003Cpath>\nboth_sides: \u003Cconcise conflict-region summary or quoted snippets>\nintent_diff_summary: \u003Cwhat the incoming commit intended>\nproposed_resolution: \u003Cproposal and reasoning>\nwhy_outside_safe_set: \u003Creason>\ncurrent_repository_state: \u003Cgit status summary>\n--- END CONFLICT SUBAGENT RESULT ---\n```\n\n### 5. Done\n\nWhen the selected restack command reports there is nothing left to restack:\n\n- Run a final `git status` (clean) and `ns slot gt exec stack-branches --format json`\n  for structured topology confirmation. `gt log` \u002F `gt ls` may be shown as\n  human visual confirmation only.\n- Regenerate any auto-generated files that were touched (per\n  `code-resolve-merge-conflicts` step 7) and stage\u002Fcommit them as appropriate.\n- For a **full-scope** restack, the final-verification rule is binary: if any\n  conflict was resolved anywhere in the restack, run a final scoped\n  verification from the stack tip after the restack completes; if the whole\n  restack replayed conflict-free, skip it. This covers upstack branches that\n  replayed without conflicts but now sit atop resolved code. Use the engine's\n  step-4 check rule\n  (`code-resolve-merge-conflicts`, \"Verify before continuing\"), scoped by the\n  file types conflicted across the whole restack.\n\n### 6. Bail-out\n\nThe engine's bail-out policy applies, plus this driver's extra condition from\n**Engine parameters** (a conflict outside the selected scope). Summarize per\nthe engine: what was resolved, what remains, and the exact command\u002Fstate you\nstopped at.\n",{"name":5,"description":7,"disable-model-invocation":54},true,"master","44a56f0d543f274b42239091b35fe4d23855f6b3","skills\u002Finternal\u002Fcode\u002Fcode-gt-restack-resolve",0,"https:\u002F\u002Fgithub.com\u002Fnseng-ai\u002Fns","https:\u002F\u002Fgithub.com\u002Fnseng-ai","Keeping the clankers in check: Nonslop Engineering for AI","2026-10-02 12:48:53",{"source":8,"skillName":5,"commands":64,"prompt":74,"zipAvailable":54},[65,68,71],{"tool":66,"command":67},"npx","npx skills add nseng-ai\u002Fns --skill code-gt-restack-resolve",{"tool":69,"command":70},"bunx","bunx skills add nseng-ai\u002Fns --skill code-gt-restack-resolve",{"tool":72,"command":73},"pnpm","pnpm dlx skills add nseng-ai\u002Fns --skill code-gt-restack-resolve","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fnseng-ai\u002Fns\u002Fblob\u002Fmaster\u002Fskills\u002Finternal\u002Fcode\u002Fcode-gt-restack-resolve\u002FSKILL.md",[76],{"path":77,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":80,"sourceHtmlUrl":81},"agents\u002Fopenai.yaml","REFERENCE","参考文档",43,"https:\u002F\u002Fgithub.com\u002Fnseng-ai\u002Fns\u002Fblob\u002Fmaster\u002Fskills\u002Finternal\u002Fcode\u002Fcode-gt-restack-resolve\u002Fagents\u002Fopenai.yaml",[83,104,131,153,176,187],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":49},"01M6KM3VZ7JC4S6R4KATJ368EH","pr-make-accountable","Interview a PR author to establish shared understanding of intent and design decisions, then co-author the What \u002F Why \u002F Changes PR body with opt-in Requested reviewer focus.","https:\u002F\u002Fgithub.com\u002Fnseng-ai\u002Fns\u002Fblob\u002Fmaster\u002Fskills\u002Fpublic\u002Fprs\u002Fpr-make-accountable\u002FSKILL.md",[],[90,91,92,93,94,95,96,97,98,99,100,101,37,36,102,103],"pr","make","pr make accountable","design","why","reviewer","decisions","interview","intent","focus","shared","co","changes","pr body",{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":113,"publishedAt":49},"01M6KM3NZCZ86VJ91RSVTRGTJW","typescript-style","Opinionated style guide for strict, portable TypeScript. Use when writing, designing, or reviewing TypeScript: type design, boundary validation, error handling, module architecture, and review discipline.","https:\u002F\u002Fgithub.com\u002Fnseng-ai\u002Fns\u002Fblob\u002Fmaster\u002Fskills\u002Finternal\u002Ftypescript\u002Ftypescript-style\u002FSKILL.md",[110],{"categoryNo":111,"categoryName":112,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",[114,115,116,93,117,118,119,120,121,122,123,124,48,125,126,127,128,129,130,35],"typescript","style","typescript style","writing","review","architecture","core","error handling","system","Rules","README","error-handling","study","module","error","case-study","style guide",{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":140,"publishedAt":49},"01M6KM3HNY4WY42KMYRPS6KEJZ","typescript-fake-driven-testing","TypeScript fake-driven testing architecture. Use when writing or reviewing TS code with external dependencies, gateway interfaces, real adapters, in-memory fakes, or CLI scenario tests.","https:\u002F\u002Fgithub.com\u002Fnseng-ai\u002Fns\u002Fblob\u002Fmaster\u002Fskills\u002Finternal\u002Ftypescript\u002Ftypescript-fake-driven-testing\u002FSKILL.md",[137],{"categoryNo":138,"categoryName":139,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",[141,114,142,143,144,117,145,146,119,29,147,48,148,149,150,151,37,152],"testing","driven","fake driven testing","typescript fake driven testing","cli","memory","gateway","dependencies","tests","scenario","Adapters","in-memory",{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":159,"publishedAt":49},"01M6KM3AXC2539PENYVZJYKCP9","ns-typescript","TypeScript overlay for ns-style projects. Use when editing or reviewing TS in this repo: tsconfig baseline, pnpm\u002FVitest\u002Foxlint\u002Foxfmt\u002Fnative tsc commands, relative .ts imports, workspace subpath exports, and the exactOptionalPropertyTypes spread idiom. Repo-specific enforcement (test lanes, time seams, style guard) lives in the host repo's AGENTS.md.","https:\u002F\u002Fgithub.com\u002Fnseng-ai\u002Fns\u002Fblob\u002Fmaster\u002Fskills\u002Finternal\u002Ftypescript\u002Fns-typescript\u002FSKILL.md",[],[114,160,161,162,163,164,165,166,48,167,168,169,170,115,171,172,173,35,174,175],"ns typescript","test","guard","vitest","projects","editing","repo","enforcement","references","time","host","oxlint","import","native","alternatives","imports",{"skillNo":177,"name":178,"nameZh":6,"description":179,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":180,"categories":181,"keywords":182,"publishedAt":49},"01M6KM36Y5KZ5V48M58MT42AHM","ns-typescript-style-tripwire","Invoke the ns TypeScript style Tripwire against a supplied diff or current branch.","https:\u002F\u002Fgithub.com\u002Fnseng-ai\u002Fns\u002Fblob\u002Fmaster\u002Fskills\u002Finternal\u002Ftypescript\u002Fns-typescript-style-tripwire\u002FSKILL.md",[],[114,183,115,184,185,186,36],"tripwire","ns typescript style tripwire","branch","diff",{"skillNo":188,"name":189,"nameZh":6,"description":190,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":191,"categories":192,"keywords":194,"publishedAt":49},"01M6KM313HANS0AV181X37ZM45","skill-management","Manage skills with `npx skills`: add, edit, remove, rename, update, or list skills (local or GitHub), and the nested `skills\u002F\u003Cdisposition>\u002F...\u002F\u003Cname>\u002F` \u002F flat `.agents\u002Fskills\u002F` layout conventions.","https:\u002F\u002Fgithub.com\u002Fnseng-ai\u002Fns\u002Fblob\u002Fmaster\u002Fskills\u002Finternal\u002Fskill-system\u002Fskill-management\u002FSKILL.md",[193],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[195,196,197,198,199,186,200,201,66,202,203,37,204,205,206,207,208,209,36,210],"management","skill management","github","Bash","remove","nested","manage","local","cat","ln","ls","mkdir","mv","readlink","rg","lock"]