[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M736RZQQMZ0AB3CWFXBP9W7K":3,"skill-same:01M736RZQQMZ0AB3CWFXBP9W7K":54},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":6,"ownerHtmlUrl":27,"ownerBlogUrl":6,"ownerDescription":28,"updatedAt":29,"install":30,"resources":43},"01M736RZQQMZ0AB3CWFXBP9W7K","worktree-triage",null,"Scan and classify git worktrees against a base ref, prune safe\u002Fsuperseded ones, and rescue unmerged work by PR or onto the local default branch. A rebase probe confirms supersession; in-progress work is never lost.","graysurf\u002Fagent-runtime-kit","graysurf","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F10785178?v=4","01M736PQHYKHFMNBYF8BT93NM4","01M736PQJWYH7G046WAN7EQCHD",0,"MIT","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fgolden\u002Fclaude\u002Fplugins\u002Fmeta\u002Fskills\u002Fworktree-triage\u002Fexpected\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: worktree-triage\ndescription: >\n  Scan and classify git worktrees against a base ref, prune safe\u002Fsuperseded\n  ones, and rescue unmerged work by PR or onto the local default branch. A\n  rebase probe confirms supersession; in-progress work is never lost.\n---\n\n# Worktree Triage\n\n## Contract\n\nPrereqs:\n\n- For one repo, run from inside the target git repository (or pass\n  `--repo \u003Cpath>`).\n- For machine-wide cleanup, pass `--all-managed` to scan every repository\n  represented under the managed worktree root\n  (`${AGENT_HOME:-${XDG_STATE_HOME:-$HOME\u002F.local\u002Fstate}\u002Fagent-runtime-kit}\u002Fworktrees`).\n- `git` and `git-cli` are on `PATH`; Python 3.11+ is available (the bundled\n  `worktree_triage.py` scanner is stdlib-only). `semantic-commit` is required\n  for any commit the rescue path makes; `forge-cli >=1.11.2` is required only\n  for the PR-mode rescue path. The scan itself needs no provider access.\n- The base ref the work should have landed on is fetched and current in every\n  scanned repo. The scanner is **read-only and never fetches** — run\n  `git fetch origin --prune` yourself first (in each represented repo for\n  `--all-managed`) so `origin\u002Fmain` ahead\u002Fbehind is not stale. The **PROBE**\n  (step 3) classifies against the *local* base with a rebase, so its\n  supersession verdict stays correct even when a remote is unreachable\n  (404, offline, renamed org).\n- The PROBE and the rescue **mutate branches** (rebase, commit). They are\n  governed: commits go through `semantic-commit`; landing on the default branch\n  goes through `semantic-commit default-branch`. This skill never runs a raw\n  `git commit`\u002F`git merge` on the default branch (see *Hook & tooling\n  constraints*).\n\nInputs:\n\n- The scope to scan:\n  - `--all-managed` for every repo represented under the managed worktree\n    root. Use this when the user says \"all worktrees\", \"no agents are running\",\n    or otherwise asks for global cleanup without naming one repo.\n  - `--repo \u003Cpath>` for one repo, or no scope flag to scan the current repo.\n- The base ref each branch is classified against (`--base`, defaults to\n  `origin\u002Fmain`).\n\nOutputs:\n\n- A `worktree-triage.scan.v1` JSON envelope (or text) with a `scope`, optional\n  `worktree_root`, a `repos` array, a `summary` (per-disposition counts) and a\n  `worktrees` array. Each record carries `path`, `repo_root`, `branch`,\n  `is_primary`, `disposition`, `suggested_action`, and — for branches with\n  unique commits — `ahead`\u002F`behind`, a `unique_commit_count`, and an `evidence`\n  block with the two-dot `git diff \u003Cbase>..\u003Cbranch>` shortstat plus a\n  `likely_superseded` flag. Each repo record also carries `base_freshness`\n  (`{base, upstream, behind_upstream}`) when the base has an upstream, so the\n  caller can spot a **stale local base** before landing onto it.\n- `likely_superseded` is **advisory** — a cheap patch-id hint. The **PROBE**\n  (step 3), not this flag, is what confirms supersession.\n\nDispositions (the SCAN's cheap first pass):\n\n- `primary` — the repo's main working tree. Never a removal target.\n- `dirty` — uncommitted changes present. Never *discarded*; the rescue path\n  commits the work onto the branch first (zero-loss), then treats it normally.\n- `locked` — a git-locked worktree. Surfaced, never auto-removed.\n- `safe-merged` — branch tip is an ancestor of the base (nothing ahead).\n  Safe to prune.\n- `safe-superseded` — branch is ahead by commit SHA, but **every** commit is\n  patch-equivalent to one already in the base (`git cherry` reports them all as\n  `-`). Safe to prune.\n- `rescue-candidate` — branch has commits whose patch is not in the base. This\n  is **resolved by the PROBE**, not by reading `evidence` prose: it may be\n  genuine unmerged work, or work already on the base via a different commit\n  (patch-id is unreliable). Never auto-pruned from the SCAN alone.\n\nFailure modes:\n\n- Not a git repo, or `--base` does not resolve (usually a missing `git fetch`,\n  or a non-`main` default branch — pass `--base`). In `--all-managed`, per-repo\n  base failures are reported in `errors`; do not prune worktrees from a repo\n  whose base could not be verified — but note the PROBE can still classify\n  against a *local* base even when the *remote* base is unreachable.\n- A worktree is `dirty` or `locked`: a verdict to act on, not a tool error.\n  Never discard a dirty worktree; commit its work to the branch first.\n- `base_freshness.behind_upstream` large (local base far behind its upstream):\n  a signal **not** to land rescued work onto that stale base — keep the branch\n  and land after the base is refreshed.\n\n## Entrypoint\n\nFor all managed agent worktrees, fetch each represented repo first, then scan:\n\n```bash\n$HOME\u002F.claude\u002Fplugins\u002Fmeta\u002Fskills\u002Fworktree-triage\u002Fscripts\u002Fworktree-triage.sh --all-managed --base origin\u002Fmain --format json\n```\n\nFor one repo, fetch first so the base ref is current, then scan:\n\n```bash\ngit fetch origin\n$HOME\u002F.claude\u002Fplugins\u002Fmeta\u002Fskills\u002Fworktree-triage\u002Fscripts\u002Fworktree-triage.sh --repo . --base origin\u002Fmain\n```\n\nMachine-readable envelope for selection logic:\n\n```bash\n$HOME\u002F.claude\u002Fplugins\u002Fmeta\u002Fskills\u002Fworktree-triage\u002Fscripts\u002Fworktree-triage.sh --repo . --base origin\u002Fmain --format json\n```\n\n## Workflow — SCAN → PROBE → ACT\n\n### 1. SCAN (read-only)\n\nChoose scope, fetch each represented repo (`git fetch origin --prune`; the\nscanner never fetches), then run the scanner and treat its output as evidence.\nPresent the triage grouped into: safe-to-prune (`safe-merged` +\n`safe-superseded`), rescue-candidates, and blocked (`dirty` \u002F `locked` \u002F\n`primary`). Surface each repo's `base_freshness`; flag any repo whose local\nbase is far behind its upstream.\n\n### 2. Prune the mechanically safe set\n\nWhen the user has asked to clean up, prune every `safe-merged` \u002F\n`safe-superseded` record without per-item confirmation, against the reported\n`path`, deleting the branch from that record's `repo_root` (rows may come from\ndifferent repos under `--all-managed`). Run each mutation with the command\ntool's top-level workdir set to the record's `repo_root`:\n\n```bash\ngit-cli worktree remove \u003Cpath> --format json\ngit branch -d \u003Cbranch>   # use -D if it is merged only to the LOCAL default\n```\n\nDelete a remote branch only when it has no open PR, or its PR is\nsuperseded\u002Fclosed. Never prune a `primary`, `dirty`, or `locked` worktree, and\nnever prune anything from a repo listed in `errors`.\n\n### 3. PROBE each rescue-candidate (the definitive supersession \u002F landing test)\n\nFirst guarantee **zero-loss**: if the worktree has uncommitted work (a\n`rescue-candidate` you are about to probe, or a `dirty` worktree you are\nrescuing), commit it onto its own branch with `semantic-commit` — never\ndiscard. This decouples \"rescue\" from \"landing\".\n\nThen, with the command tool's top-level workdir set to the worktree, rebase the\nbranch onto the base:\n\n```bash\nGIT_EDITOR=true git rebase \u003Cbase>\n```\n\nRebasing operates on the **feature branch**, not the default branch, so it does\nnot trip the default-branch delivery guard. Three outcomes:\n\n- **superseded-confirmed** — the rebase collapses the branch to `0` ahead of\n  the base (git drops every commit as an already-applied cherry-pick). The\n  branch's work is already in the base. Prune it like the safe set. This\n  replaces the old, unreliable \"match `git cherry -v` subjects against base\n  commit bodies\" step.\n- **genuine, ff-ready** — the rebase completes cleanly and the branch is still\n  `N` ahead. Real unmerged work, now fast-forwardable. Go to step 4.\n- **conflicted** — resolve trivial\u002Fadditive conflicts yourself (e.g. the branch\n  adds a symbol the base does not have, or the base added tests the branch\n  lacks). For genuine **semantic divergence** (the same logic changed two\n  different ways), STOP and ask the user which side to take — never guess. If\n  it cannot be resolved safely, `git rebase --abort` (work stays committed on\n  the branch) and retain it with a report.\n\n### 4. ACT — land genuine work by delivery mode\n\nPick the delivery mode from the environment, not by habit:\n\n- **PR mode** (a forge is available — the default): hand the ff-ready branch to\n  `deliver-pr`. Triage never merges.\n- **local-main mode** (no PR: forge down \u002F offline \u002F the user asked to \"commit\n  to local main\"): after the rebase has made the branch ff-ready, land it on\n  the local default branch through the governed path — **not** a raw\n  `git merge`\u002F`git branch -f`:\n\n  Materialize and stage only the proven feature-branch patch in the clean\n  primary checkout through the ordinary project-dev mutation boundary. Then\n  bind the explicit repository and current full `HEAD`, validate the exact\n  preflight without a receipt, and run the authorized mutation with a new\n  outside-repository receipt:\n\n  ```bash\n  semantic-commit default-branch --repo \u003Cabsolute-repo-root> \\\n    --expect-head \u003Cfull-current-head> --dry-run --automation --format json \\\n    --message \u003Cmessage>\n  semantic-commit default-branch --repo \u003Cabsolute-repo-root> \\\n    --expect-head \u003Cfull-current-head> --receipt-out \u003Coutside-repo-receipt> \\\n    --automation --format json --message \u003Cmessage>\n  ```\n\n  If `base_freshness` shows the local base is far behind its upstream, prefer\n  keeping the branch and landing after the base is refreshed. If the landing\n  cannot run from the agent shell (hook-blocked), emit a copy-paste script for\n  the user's own terminal instead.\n\nAfter landing or pruning, remove the worktree by running `git-cli worktree\nremove \u003Cpath>` with the tool workdir set to `\u003Crepo_root>`. Keep the branch for\ngenuine work that has not yet landed;\ndelete it once its work is in the base.\n\n### 5. Stop at the human gate\n\nNever remove a `primary`, never *discard* a `dirty` worktree (commit-to-branch\nfirst), never remove rows from repos with scan `errors`. Land on the default\nbranch only with the applicable authorization (PR confirmation for PR mode;\ncurrent-request maintainer approval for default-branch completion). Ask the user\non any semantic conflict, and never treat a related commit as proof of\nsupersession — the PROBE is the proof.\n\n## Delivery Modes\n\n- **PR mode (default).** A forge is reachable and PRs are accepted. Genuine\n  `rescue-candidate` work goes to `deliver-pr`; triage opens\u002Fmerges nothing\n  itself.\n- **local-main mode.** PRs are unavailable (forge outage, offline, or the user\n  explicitly wants local-only commits). Rescue lands on the local default\n  branch through `semantic-commit default-branch`, which requires\n  current-request maintainer approval for default-branch delivery. This mode\n  relies on the PROBE having made the branch ff-ready first, and honors the\n  `base_freshness` stale-base guard.\n\n## Hook & Tooling Constraints (agent execution notes)\n\n- **`block-unsafe-default-delivery`** blocks a raw-shell `git merge` targeting\n  the default branch — and even a read-only inspection that references it in a\n  delivery-shaped command. A `git rebase \u003Cbase>` on a *feature* branch is not\n  blocked. So the rescue path rebases (feature branch) and lands via\n  `semantic-commit default-branch`; it never raw-merges the default branch.\n- **`git-cli worktree remove` handles dirty worktrees** (it snapshots them). Do\n  **not** `git reset --hard` \u002F `git clean` a worktree before removing it — those\n  trip the delivery guard and are unnecessary.\n- **`git-cli` resolves the repo from the tool workdir.** Set the command tool's\n  top-level workdir to the repo (or one of its worktrees) before\n  `git-cli worktree remove`; do not retarget with shell `cd`.\n- **`git branch -d` checks the upstream**, so a branch merged only to the\n  *local* default refuses to delete. Use `-D` after confirming it is merged to\n  `HEAD`.\n- **`semantic-commit default-branch`** requires explicit opt-in, an absolute\n  `--repo`, full `--expect-head`, the clean primary default checkout with\n  staged-only changes, and authoritative remote-free or aligned cached-default\n  identity. `--dry-run` forbids a receipt; mutation requires a new absolute\n  outside-repository `--receipt-out`. Compound\u002Fnested shell forms fail closed.\n\n## Boundary\n\n`worktree_triage.py` owns read-only enumeration, the ahead\u002Fbehind and ancestor\nchecks, the patch-equivalence (`git cherry`) call, the two-dot net-diff\nevidence, `base_freshness`, and the SCAN disposition verdict — it never\nmutates. The skill body owns SCAN orchestration, the **PROBE** (the rebase-based\nsupersession \u002F landing test), the zero-loss commit-to-branch, and mode-aware\nlanding through governed tools (`semantic-commit` \u002F `deliver-pr`). It never\nre-implements the scanner's classification in prose, never auto-removes a\n`dirty`\u002F`locked`\u002F`primary` worktree, never removes a branch from a repo with\nscan errors, never lands on the default branch outside the governed path, and\nnever guesses a semantic conflict.\n\n## Related Skills\n\n- `deliver-pr` — owns the provider lifecycle for a genuine `rescue-candidate`\n  in PR mode. Triage never merges.\n- `semantic-commit` — governed commits for the rescue path, including\n  `default-branch` for local-main mode.\n- `sync-runtime-surfaces` — its apply path refuses linked-worktree source\n  roots; this skill is the companion that cleans those worktrees up.\n","# Worktree Triage\n\n## Contract\n\nPrereqs:\n\n- For one repo, run from inside the target git repository (or pass\n  `--repo \u003Cpath>`).\n- For machine-wide cleanup, pass `--all-managed` to scan every repository\n  represented under the managed worktree root\n  (`${AGENT_HOME:-${XDG_STATE_HOME:-$HOME\u002F.local\u002Fstate}\u002Fagent-runtime-kit}\u002Fworktrees`).\n- `git` and `git-cli` are on `PATH`; Python 3.11+ is available (the bundled\n  `worktree_triage.py` scanner is stdlib-only). `semantic-commit` is required\n  for any commit the rescue path makes; `forge-cli >=1.11.2` is required only\n  for the PR-mode rescue path. The scan itself needs no provider access.\n- The base ref the work should have landed on is fetched and current in every\n  scanned repo. The scanner is **read-only and never fetches** — run\n  `git fetch origin --prune` yourself first (in each represented repo for\n  `--all-managed`) so `origin\u002Fmain` ahead\u002Fbehind is not stale. The **PROBE**\n  (step 3) classifies against the *local* base with a rebase, so its\n  supersession verdict stays correct even when a remote is unreachable\n  (404, offline, renamed org).\n- The PROBE and the rescue **mutate branches** (rebase, commit). They are\n  governed: commits go through `semantic-commit`; landing on the default branch\n  goes through `semantic-commit default-branch`. This skill never runs a raw\n  `git commit`\u002F`git merge` on the default branch (see *Hook & tooling\n  constraints*).\n\nInputs:\n\n- The scope to scan:\n  - `--all-managed` for every repo represented under the managed worktree\n    root. Use this when the user says \"all worktrees\", \"no agents are running\",\n    or otherwise asks for global cleanup without naming one repo.\n  - `--repo \u003Cpath>` for one repo, or no scope flag to scan the current repo.\n- The base ref each branch is classified against (`--base`, defaults to\n  `origin\u002Fmain`).\n\nOutputs:\n\n- A `worktree-triage.scan.v1` JSON envelope (or text) with a `scope`, optional\n  `worktree_root`, a `repos` array, a `summary` (per-disposition counts) and a\n  `worktrees` array. Each record carries `path`, `repo_root`, `branch`,\n  `is_primary`, `disposition`, `suggested_action`, and — for branches with\n  unique commits — `ahead`\u002F`behind`, a `unique_commit_count`, and an `evidence`\n  block with the two-dot `git diff \u003Cbase>..\u003Cbranch>` shortstat plus a\n  `likely_superseded` flag. Each repo record also carries `base_freshness`\n  (`{base, upstream, behind_upstream}`) when the base has an upstream, so the\n  caller can spot a **stale local base** before landing onto it.\n- `likely_superseded` is **advisory** — a cheap patch-id hint. The **PROBE**\n  (step 3), not this flag, is what confirms supersession.\n\nDispositions (the SCAN's cheap first pass):\n\n- `primary` — the repo's main working tree. Never a removal target.\n- `dirty` — uncommitted changes present. Never *discarded*; the rescue path\n  commits the work onto the branch first (zero-loss), then treats it normally.\n- `locked` — a git-locked worktree. Surfaced, never auto-removed.\n- `safe-merged` — branch tip is an ancestor of the base (nothing ahead).\n  Safe to prune.\n- `safe-superseded` — branch is ahead by commit SHA, but **every** commit is\n  patch-equivalent to one already in the base (`git cherry` reports them all as\n  `-`). Safe to prune.\n- `rescue-candidate` — branch has commits whose patch is not in the base. This\n  is **resolved by the PROBE**, not by reading `evidence` prose: it may be\n  genuine unmerged work, or work already on the base via a different commit\n  (patch-id is unreliable). Never auto-pruned from the SCAN alone.\n\nFailure modes:\n\n- Not a git repo, or `--base` does not resolve (usually a missing `git fetch`,\n  or a non-`main` default branch — pass `--base`). In `--all-managed`, per-repo\n  base failures are reported in `errors`; do not prune worktrees from a repo\n  whose base could not be verified — but note the PROBE can still classify\n  against a *local* base even when the *remote* base is unreachable.\n- A worktree is `dirty` or `locked`: a verdict to act on, not a tool error.\n  Never discard a dirty worktree; commit its work to the branch first.\n- `base_freshness.behind_upstream` large (local base far behind its upstream):\n  a signal **not** to land rescued work onto that stale base — keep the branch\n  and land after the base is refreshed.\n\n## Entrypoint\n\nFor all managed agent worktrees, fetch each represented repo first, then scan:\n\n```bash\n$HOME\u002F.claude\u002Fplugins\u002Fmeta\u002Fskills\u002Fworktree-triage\u002Fscripts\u002Fworktree-triage.sh --all-managed --base origin\u002Fmain --format json\n```\n\nFor one repo, fetch first so the base ref is current, then scan:\n\n```bash\ngit fetch origin\n$HOME\u002F.claude\u002Fplugins\u002Fmeta\u002Fskills\u002Fworktree-triage\u002Fscripts\u002Fworktree-triage.sh --repo . --base origin\u002Fmain\n```\n\nMachine-readable envelope for selection logic:\n\n```bash\n$HOME\u002F.claude\u002Fplugins\u002Fmeta\u002Fskills\u002Fworktree-triage\u002Fscripts\u002Fworktree-triage.sh --repo . --base origin\u002Fmain --format json\n```\n\n## Workflow — SCAN → PROBE → ACT\n\n### 1. SCAN (read-only)\n\nChoose scope, fetch each represented repo (`git fetch origin --prune`; the\nscanner never fetches), then run the scanner and treat its output as evidence.\nPresent the triage grouped into: safe-to-prune (`safe-merged` +\n`safe-superseded`), rescue-candidates, and blocked (`dirty` \u002F `locked` \u002F\n`primary`). Surface each repo's `base_freshness`; flag any repo whose local\nbase is far behind its upstream.\n\n### 2. Prune the mechanically safe set\n\nWhen the user has asked to clean up, prune every `safe-merged` \u002F\n`safe-superseded` record without per-item confirmation, against the reported\n`path`, deleting the branch from that record's `repo_root` (rows may come from\ndifferent repos under `--all-managed`). Run each mutation with the command\ntool's top-level workdir set to the record's `repo_root`:\n\n```bash\ngit-cli worktree remove \u003Cpath> --format json\ngit branch -d \u003Cbranch>   # use -D if it is merged only to the LOCAL default\n```\n\nDelete a remote branch only when it has no open PR, or its PR is\nsuperseded\u002Fclosed. Never prune a `primary`, `dirty`, or `locked` worktree, and\nnever prune anything from a repo listed in `errors`.\n\n### 3. PROBE each rescue-candidate (the definitive supersession \u002F landing test)\n\nFirst guarantee **zero-loss**: if the worktree has uncommitted work (a\n`rescue-candidate` you are about to probe, or a `dirty` worktree you are\nrescuing), commit it onto its own branch with `semantic-commit` — never\ndiscard. This decouples \"rescue\" from \"landing\".\n\nThen, with the command tool's top-level workdir set to the worktree, rebase the\nbranch onto the base:\n\n```bash\nGIT_EDITOR=true git rebase \u003Cbase>\n```\n\nRebasing operates on the **feature branch**, not the default branch, so it does\nnot trip the default-branch delivery guard. Three outcomes:\n\n- **superseded-confirmed** — the rebase collapses the branch to `0` ahead of\n  the base (git drops every commit as an already-applied cherry-pick). The\n  branch's work is already in the base. Prune it like the safe set. This\n  replaces the old, unreliable \"match `git cherry -v` subjects against base\n  commit bodies\" step.\n- **genuine, ff-ready** — the rebase completes cleanly and the branch is still\n  `N` ahead. Real unmerged work, now fast-forwardable. Go to step 4.\n- **conflicted** — resolve trivial\u002Fadditive conflicts yourself (e.g. the branch\n  adds a symbol the base does not have, or the base added tests the branch\n  lacks). For genuine **semantic divergence** (the same logic changed two\n  different ways), STOP and ask the user which side to take — never guess. If\n  it cannot be resolved safely, `git rebase --abort` (work stays committed on\n  the branch) and retain it with a report.\n\n### 4. ACT — land genuine work by delivery mode\n\nPick the delivery mode from the environment, not by habit:\n\n- **PR mode** (a forge is available — the default): hand the ff-ready branch to\n  `deliver-pr`. Triage never merges.\n- **local-main mode** (no PR: forge down \u002F offline \u002F the user asked to \"commit\n  to local main\"): after the rebase has made the branch ff-ready, land it on\n  the local default branch through the governed path — **not** a raw\n  `git merge`\u002F`git branch -f`:\n\n  Materialize and stage only the proven feature-branch patch in the clean\n  primary checkout through the ordinary project-dev mutation boundary. Then\n  bind the explicit repository and current full `HEAD`, validate the exact\n  preflight without a receipt, and run the authorized mutation with a new\n  outside-repository receipt:\n\n  ```bash\n  semantic-commit default-branch --repo \u003Cabsolute-repo-root> \\\n    --expect-head \u003Cfull-current-head> --dry-run --automation --format json \\\n    --message \u003Cmessage>\n  semantic-commit default-branch --repo \u003Cabsolute-repo-root> \\\n    --expect-head \u003Cfull-current-head> --receipt-out \u003Coutside-repo-receipt> \\\n    --automation --format json --message \u003Cmessage>\n  ```\n\n  If `base_freshness` shows the local base is far behind its upstream, prefer\n  keeping the branch and landing after the base is refreshed. If the landing\n  cannot run from the agent shell (hook-blocked), emit a copy-paste script for\n  the user's own terminal instead.\n\nAfter landing or pruning, remove the worktree by running `git-cli worktree\nremove \u003Cpath>` with the tool workdir set to `\u003Crepo_root>`. Keep the branch for\ngenuine work that has not yet landed;\ndelete it once its work is in the base.\n\n### 5. Stop at the human gate\n\nNever remove a `primary`, never *discard* a `dirty` worktree (commit-to-branch\nfirst), never remove rows from repos with scan `errors`. Land on the default\nbranch only with the applicable authorization (PR confirmation for PR mode;\ncurrent-request maintainer approval for default-branch completion). Ask the user\non any semantic conflict, and never treat a related commit as proof of\nsupersession — the PROBE is the proof.\n\n## Delivery Modes\n\n- **PR mode (default).** A forge is reachable and PRs are accepted. Genuine\n  `rescue-candidate` work goes to `deliver-pr`; triage opens\u002Fmerges nothing\n  itself.\n- **local-main mode.** PRs are unavailable (forge outage, offline, or the user\n  explicitly wants local-only commits). Rescue lands on the local default\n  branch through `semantic-commit default-branch`, which requires\n  current-request maintainer approval for default-branch delivery. This mode\n  relies on the PROBE having made the branch ff-ready first, and honors the\n  `base_freshness` stale-base guard.\n\n## Hook & Tooling Constraints (agent execution notes)\n\n- **`block-unsafe-default-delivery`** blocks a raw-shell `git merge` targeting\n  the default branch — and even a read-only inspection that references it in a\n  delivery-shaped command. A `git rebase \u003Cbase>` on a *feature* branch is not\n  blocked. So the rescue path rebases (feature branch) and lands via\n  `semantic-commit default-branch`; it never raw-merges the default branch.\n- **`git-cli worktree remove` handles dirty worktrees** (it snapshots them). Do\n  **not** `git reset --hard` \u002F `git clean` a worktree before removing it — those\n  trip the delivery guard and are unnecessary.\n- **`git-cli` resolves the repo from the tool workdir.** Set the command tool's\n  top-level workdir to the repo (or one of its worktrees) before\n  `git-cli worktree remove`; do not retarget with shell `cd`.\n- **`git branch -d` checks the upstream**, so a branch merged only to the\n  *local* default refuses to delete. Use `-D` after confirming it is merged to\n  `HEAD`.\n- **`semantic-commit default-branch`** requires explicit opt-in, an absolute\n  `--repo`, full `--expect-head`, the clean primary default checkout with\n  staged-only changes, and authoritative remote-free or aligned cached-default\n  identity. `--dry-run` forbids a receipt; mutation requires a new absolute\n  outside-repository `--receipt-out`. Compound\u002Fnested shell forms fail closed.\n\n## Boundary\n\n`worktree_triage.py` owns read-only enumeration, the ahead\u002Fbehind and ancestor\nchecks, the patch-equivalence (`git cherry`) call, the two-dot net-diff\nevidence, `base_freshness`, and the SCAN disposition verdict — it never\nmutates. The skill body owns SCAN orchestration, the **PROBE** (the rebase-based\nsupersession \u002F landing test), the zero-loss commit-to-branch, and mode-aware\nlanding through governed tools (`semantic-commit` \u002F `deliver-pr`). It never\nre-implements the scanner's classification in prose, never auto-removes a\n`dirty`\u002F`locked`\u002F`primary` worktree, never removes a branch from a repo with\nscan errors, never lands on the default branch outside the governed path, and\nnever guesses a semantic conflict.\n\n## Related Skills\n\n- `deliver-pr` — owns the provider lifecycle for a genuine `rescue-candidate`\n  in PR mode. Triage never merges.\n- `semantic-commit` — governed commits for the rescue path, including\n  `default-branch` for local-main mode.\n- `sync-runtime-surfaces` — its apply path refuses linked-worktree source\n  roots; this skill is the companion that cleans those worktrees up.\n",{"name":5,"description":7},"main","da7119f2ebece510d6955cea72743069f5496c73","tests\u002Fgolden\u002Fclaude\u002Fplugins\u002Fmeta\u002Fskills\u002Fworktree-triage\u002Fexpected","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit","https:\u002F\u002Fgithub.com\u002Fgraysurf","Building reliable tools for teams of AI coding agents · Rust \u002F TypeScript · @sympoies","2026-08-29 05:27:47",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add graysurf\u002Fagent-runtime-kit --skill worktree-triage",{"tool":36,"command":37},"bunx","bunx skills add graysurf\u002Fagent-runtime-kit --skill worktree-triage",{"tool":39,"command":40},"pnpm","pnpm dlx skills add graysurf\u002Fagent-runtime-kit --skill worktree-triage","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fgolden\u002Fclaude\u002Fplugins\u002Fmeta\u002Fskills\u002Fworktree-triage\u002Fexpected\u002FSKILL.md",true,[44,50],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"bin\u002Fworktree_triage.py","SCRIPT","脚本",18249,"https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fgolden\u002Fclaude\u002Fplugins\u002Fmeta\u002Fskills\u002Fworktree-triage\u002Fexpected\u002Fbin\u002Fworktree_triage.py",{"path":51,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":52,"sourceHtmlUrl":53},"scripts\u002Fworktree-triage.sh",210,"https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fgolden\u002Fclaude\u002Fplugins\u002Fmeta\u002Fskills\u002Fworktree-triage\u002Fexpected\u002Fscripts\u002Fworktree-triage.sh",[55,61,66,73,80,87],{"skillNo":56,"name":57,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":18},"01M736XWK14DFRERMQ8RT3HS0Z","removable-skill","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fruntime-smoke\u002Ffixtures\u002Fskill-lifecycle\u002Fremove-skill\u002Ftests\u002Fgolden\u002Fcodex\u002Fplugins\u002Ffixture\u002Fskills\u002Fremovable-skill\u002FSKILL.md",[],[],{"skillNo":62,"name":57,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":18},"01M736XTPQEKAYESDM1REN2KAN","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fruntime-smoke\u002Ffixtures\u002Fskill-lifecycle\u002Fremove-skill\u002Ftests\u002Fgolden\u002Fclaude\u002Fplugins\u002Ffixture\u002Fskills\u002Fremovable-skill\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":18},"01M736XRMWHMJB4X563G9J6QYY","removable-project-skill","Fixture project-local skill used to prove remove-project-skill dry-run coverage.","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fruntime-smoke\u002Ffixtures\u002Fskill-lifecycle\u002Fremove-project-skill\u002F.agents\u002Fskills\u002Fremovable-project-skill\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M736XPT65YZMPCBD4K3RHV4P","project-sample-skill","Fixture project-local skill used to prove create-project-skill governance coverage.","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fruntime-smoke\u002Ffixtures\u002Fskill-lifecycle\u002Fcreate-project-skill\u002F.agents\u002Fskills\u002Fproject-sample-skill\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":18},"01M736XKZVYWVQA1YB0P459WND","project-local-skill","Fixture project-local skill used by runtime-kit project-local smoke checks.","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fprojects\u002Fproject-local-smoke\u002F.agents\u002Fskills\u002Fproject-local-skill\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":18},"01M736XHA73KZ5G2TKWSED5P1B","topic-radar","Aggregate read-only AI and technology trend signals (Polymarket, Hacker News, GitHub, arXiv, Hugging Face, news search) into source-grounded Markdown or JSON; the lower-level data engine behind `daily-brief`.","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fgolden\u002Fhermes\u002Fplugins\u002Freporting\u002Fskills\u002Ftopic-radar\u002Fexpected\u002FSKILL.md",[],[]]