[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ASNSKFMMXSG954AEMW8HAZ":3,"skill-same:01M7ASNSKFMMXSG954AEMW8HAZ":54},{"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":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":6,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":33,"updatedAt":34,"install":35,"resources":47},"01M7ASNSKFMMXSG954AEMW8HAZ","exit-session",null,"Tear down the ephemeral resources a Claude Code working session created, then quit the CLI — so the user can wrap up with a single \u002Fexit-session. Use when the user says \"exit session\", \"clean up this session\", \"tear down everything\", \"wrap up and clean up resources\", \"remove the worktree and scratch\", \"stop the background processes\", \"shut down the stack\", \"clean up the agent worktrees\", or asks to clean up after finishing a task — even if they only name one resource (assume they want the full sweep unless they scope it). Runs teardown permission-free: stops background processes and dev servers, Docker\u002Fcompose stacks plus their volumes, networks and images, local Tilt\u002FKubernetes, git worktrees, merged local branches, and temp\u002Fscratch files without prompting, then exits the CLI. Covers the worktrees and Docker resources left behind by subagents spawned during the session, not just the primary agent's own worktree — both determined from git locks and Docker labels rather than from recall. Never touches resources a still-live session holds.","ozzycodes2\u002Fclaudellum","ozzycodes2","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F21285094?v=4","01M7ASJ57KTP519F96S4QGM7C5","Osniel Quintana","01M7ASJ589JS8S075AA92Y08S4",1,"MIT","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Fsession-mgmt\u002Fskills\u002Fexit-session\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: exit-session\ndescription: >-\n  Tear down the ephemeral resources a Claude Code working session created, then\n  quit the CLI — so the user can wrap up with a single \u002Fexit-session. Use when the\n  user says \"exit session\", \"clean up this session\", \"tear down everything\", \"wrap\n  up and clean up resources\", \"remove the worktree and scratch\", \"stop the\n  background processes\", \"shut down the stack\", \"clean up the agent worktrees\", or asks\n  to clean up after finishing a task — even if they only name one resource (assume they\n  want the full sweep unless they scope it). Runs teardown permission-free: stops\n  background processes and dev servers, Docker\u002Fcompose stacks plus their volumes,\n  networks and images, local Tilt\u002FKubernetes, git worktrees, merged local branches, and\n  temp\u002Fscratch files without prompting, then exits the CLI. Covers the worktrees and\n  Docker resources left behind by subagents spawned during the session, not just the\n  primary agent's own worktree — both determined from git locks and Docker labels rather\n  than from recall. Never touches resources a still-live session holds.\nlicense: MIT\ncompatibility: >-\n  Assumes a git repo with optional worktrees under .claude\u002Fworktrees\u002F or \u002Ftmp;\n  Docker + docker compose; optional Tilt (rancher-desktop\u002Fk3d); optional `just`\n  task runner. Runs without prompts in default, accept-edits and bypassPermissions\n  mode via allow rules in settings.json, and in `auto` mode — which strips those rules\n  — via an autoMode.allow entry describing the sweep. Only plan mode is refused, by the\n  bundled UserPromptSubmit hook, since it blocks mutating tools outright. The final\n  self-exit uses `kill \"$PPID\"` (the CLI process).\nargument-hint: \"[optional: resource to scope to, e.g. worktree | docker | tilt | scratch]\"\ndisable-model-invocation: true\n---\n\n# Exit Session\n\nTeardown of everything a working session spun up: background processes, Docker\u002Fcompose\nstacks with their volumes, networks and locally built images, local Tilt\u002FKubernetes, git\nworktrees — the session's own **and every one it handed to a subagent** — merged local\nbranches, and scratch files, leaving the machine as clean as before the session started,\nthen quit the CLI. Designed\nto run **permission-free**: the teardown verbs are allow-listed in default, accept-edits\nand bypassPermissions mode, and described to the classifier in `autoMode.allow` for `auto`\nmode, so you execute the sweep directly without stopping for confirmation — including the\ntwo operations that destroy *data* rather than just tear down ephemeral resources. Only\nplan mode is refused (Phase 0).\n\n## Core principles\n\n1. **Scoped by live holder, not by memory.** A resource is off-limits when a *live*\n   session still holds it — not merely because you don't recall creating it. Worktrees\n   locked by another running `claude` pid, and their containers, are preserved and listed\n   under \"left untouched.\" Everything with no live holder — this session's own worktrees,\n   its subagents' worktrees, and worktrees whose holder pid is gone — is in scope.\n2. **Attribute mechanically first, from memory second.** Three resources are *knowable\n   with certainty*, so ask the system, never your recollection:\n   - the worktree this session sits in → `git rev-parse` (Phase 0a);\n   - which worktrees belong to this session's subagents → the git **lock reason**, which\n     names the holding `claude` pid; that pid is an ancestor of your own shell (Phase 0c);\n   - which Docker resources belong to a given worktree → the\n     `com.docker.compose.project` label, which equals the worktree directory basename.\n\n   Conversation history is the fallback for genuinely ambiguous resources (an ad-hoc\n   `docker run --name`, a scratch path), never the primary test for a worktree. By the\n   time a real session reaches teardown its context has usually compacted, so the\n   `EnterWorktree` and `Agent(isolation:\"worktree\")` calls are long gone — and \"I don't\n   remember creating it\" then silently becomes \"it must be someone else's,\" which is how\n   a session leaks its own worktree, and every worktree it gave a subagent, on every run.\n3. **Discover, then execute — no plan-gate.** Do one read-only discovery pass to build\n   the inventory, then tear down immediately. Teardown is pre-authorized; you do **not**\n   pause for a \"confirm the plan\" step. Show the inventory as you go so progress is visible.\n4. **Fully permission-free — no data-loss gate.** Once Phase 0 settles the mode, every\n   teardown of a resource this session created runs without a prompt, including\n   `docker compose down -v` (wipes volumes \u002F local DB state) and removing a worktree that\n   still has **uncommitted** changes. The only thing you never do is run the still-denied\n   remote\u002Fhistory ops (Phase 4) — those aren't teardown; hand them back.\n5. **Preserve on doubt — except where git already answered.** For anything you can't\n   attribute, default to leaving it and flagging it: a missed cleanup is cheap, a wrong\n   deletion is not. This does **not** apply to the worktrees Phase 0a and 0c settle\n   mechanically — those are answered by `git rev-parse` and the lock pid, so there is no\n   doubt to preserve on, and skipping them is the failure mode this rule is blamed for.\n   The one live remnant of the rule: a worktree with **uncommitted changes** that is not\n   this session's own gets preserved and reported, never discarded (Phase 3c).\n6. **No leading `cd`.** Use `git -C \u003Cpath>` and absolute paths. A leading `cd` triggers a\n   permission prompt (per the user's global CLAUDE.md) and defeats the point of a\n   permission-free sweep.\n7. **One plain command per Bash call while in a worktree.** When the session is inside a\n   linked worktree — the normal case for this sweep — Claude Code's isolation validator\n   refuses any Bash line it cannot statically prove stays inside it: *\"too complex to\n   verify that it stays inside the worktree; break it into plain, separate commands.\"*\n   It rejects `;` and `&&` chains, `$(…)` substitution, and heredocs **even when every\n   component is read-only**. It is a static-analysis gate, not a permission check, so no\n   allow rule and no permission mode gets past it. Issue separate Bash calls, in parallel\n   in one message where they're independent. The one exception is the bundled discovery\n   script: it is a single `bash \u003Cscript>` call, and the commands inside its own subshell\n   are not re-examined — which is also why it is the cheapest way to run discovery.\n\n## Workflow\n\nWork the phases in order. Create a todo per phase so progress is visible.\n\n### Phase 0 — Permission mode (preflight)\n\n**If you are reading this, the mode is already fine.** The bundled `UserPromptSubmit`\nhook (`hooks\u002Frequire-accept-edits.sh`) blocks `\u002Fexit-session` in plan mode before you ever\nsee the prompt, and it let this invocation through. Proceed straight to Phase 0a.\n\nOnly plan mode is refused, because it blocks the mutating tools the sweep needs. Every\nother mode works, by two different routes: `default`, `acceptEdits` and\n`bypassPermissions` honour the `Bash(...)` allow rules in settings.json, while `auto`\nstrips them all at mode-entry (`Ignoring dangerous permission \u003Crule> from \u003Csource>\n(bypasses classifier)` in the debug log) and relies instead on the `autoMode.allow` entry\ndescribing this sweep. Do not reintroduce an auto-mode gate: it fired on every single\ninvocation and cost the user a Shift+Tab and a re-run each time.\n\nNothing here can flip the mode for the user, so do not try: no hook output field sets it\n(`PreToolUse` returns only `permissionDecision` \u002F `permissionDecisionReason` \u002F\n`updatedInput` \u002F `additionalContext`), and the `setMode` permission update is reachable\nonly from the SDK permission bridge. The keystroke is the only lever. If prompts start\nlanding on verbs that should be covered, stop the sweep, report what has already been\ntorn down, and say which rule is missing — do not grind through the sweep one\nconfirmation at a time.\n\n### Phase 0a — Identify this session's own worktree (read-only, deterministic)\n\n**Do this first, before the discovery script.** It is three read-only commands and it\nsettles the question the rest of the sweep keeps getting wrong: *is the directory I am\nsitting in a worktree that should be torn down?*\n\nThree separate Bash calls, issued in parallel in one message — not `&&`-joined, and not\nwrapped in `echo \"$(…)\"` (Principle 7):\n\n```\ngit -C \u003Ccwd> rev-parse --git-dir           # linked worktree -> \u003Cmain>\u002F.git\u002Fworktrees\u002F\u003Cname>\ngit -C \u003Ccwd> rev-parse --git-common-dir    # linked worktree -> \u003Cmain>\u002F.git   (differs!)\ngit -C \u003Ccwd> rev-parse --show-toplevel     # linked worktree -> the worktree path itself\n```\n\n`git rev-parse --git-dir --git-common-dir --show-toplevel` in one call is also fine —\nthat is a single command with three flags, not a chain.\n\n- **`--git-dir` and `--git-common-dir` differ** → the session is inside a **linked\n  worktree**. `--show-toplevel` is `SELF_WORKTREE`, and the parent of `--git-common-dir`\n  is `MAIN_REPO`. `SELF_WORKTREE` is a teardown target **unconditionally** — do not ask\n  whether you remember creating it. A session lands in a worktree because it was put\n  there (`\u002Fstart-session`, `EnterWorktree`, `claude -w`), so by construction it is this\n  session's. Read the real branch from `git -C \u003CMAIN_REPO> worktree list --porcelain`\n  (it is `worktree-\u003Cname>`, not `\u003Cname>`).\n- **They are the same** → the session is in the main checkout. There is no self-worktree,\n  and Phase 3a is a no-op. This says **nothing** about the other worktrees in the list:\n  a session running from the main checkout still owns every worktree it handed to a\n  subagent. Phase 0c classifies those; do not conclude they are all other sessions'.\n\n`MAIN_REPO` — not `SELF_WORKTREE` — is the `\u003Crepo-root>` argument for everything that\nfollows. The bundled script resolves this itself and prints a `THIS SESSION'S OWN WORKTREE`\nsection, but pass `MAIN_REPO` anyway: handing a worktree path to a hand-rolled scan makes\nit look at `\u003Cworktree>\u002F.claude\u002Fworktrees`, a nested path that cannot exist, so the on-disk\nworktree section comes back empty and the sweep silently has nothing to do.\n\n### Phase 0b — Discover (read-only)\n\nBuild an inventory before touching anything. Run the bundled discovery script, which\ngathers the whole picture in one read-only pass. Pass the repo root as an argument —\n**do not `cd`**:\n\n```\nbash \u003Cskill-dir>\u002Fscripts\u002Fdiscover-resources.sh \u003Crepo-root>\n```\n\nAdd `--worktrees-only` when you only need the worktree picture — for\n`\u002Fexit-session worktree`, or to re-check the inventory after Phase 3. The full pass spends\nmost of its wall time in `pgrep -f`, about a second per pattern on a busy machine.\n\n(Substitute the real absolute path to this skill's `scripts\u002Fdiscover-resources.sh`, and\nthe absolute repo root.) Write it exactly that way: `bash ` then the bare unquoted path.\nQuoting the path, or executing the script directly without `bash `, changes the command\nstring enough to miss the allow rule and costs a prompt. It prints sections for the\nself-worktree, **every worktree classified by lock holder** (Phase 0c), unregistered\nworktree directories, current branch + merge status, background jobs\u002Fports, Docker\ncontainers, Docker volumes\u002Fnetworks\u002Fimages grouped by compose project, Tilt\u002Fk8s, and\nscratch dirs. If the script is unavailable, gather the same signals by hand (all\nread-only, all with `git -C`, no `cd`):\n\n- **Background tasks this session spawned:** use the `Monitor` tool to enumerate live\n  background shells and their `task_id`s — it is deferred, so `ToolSearch select:Monitor`\n  first. (There is no `TaskList` tool; asking for one wastes a turn.) Cross-reference\n  `ps` \u002F `pgrep -f` \u002F `lsof -iTCP -sTCP:LISTEN -P -n` for dev servers (vite,\n  `target\u002Fdebug\u002Fapi`, `cargo run -p api`, `npm run dev`, cloudflared,\n  `kubectl port-forward`).\n- **Worktrees:** `git -C \u003Crepo> worktree list --porcelain` (the `--porcelain` form is what\n  carries the lock reasons Phase 0c needs) and\n  `ls -la \u003Crepo>\u002F.claude\u002Fworktrees\u002F 2>\u002Fdev\u002Fnull`.\n- **Branch:** `git -C \u003Crepo> branch --show-current`, `git -C \u003Crepo> status -s`, and whether\n  its PR is merged (`gh pr view \u003Cbranch> --json state,mergedAt`).\n- **Docker:** `docker ps -a` (note session stacks like `postgres kafka localstack` and any\n  ad-hoc `--name` containers), plus `docker volume ls`, `docker network ls`, and\n  `docker image ls` — each with\n  `--filter label=com.docker.compose.project=\u003Cworktree-basename>` to attribute them.\n- **Tilt\u002Fk8s:** `tilt get session 2>\u002Fdev\u002Fnull`; `kubectl port-forward` procs.\n- **Scratch:** `.claude\u002Fjobs\u002F\u003Cid>\u002Ftmp` dirs and `\u002Ftmp\u002F*` paths this session created (PR\n  bodies, commit-msg files, review worktrees).\n\n**Attribute each resource mechanically where you can, from history only where you can't.**\n`SELF_WORKTREE` (Phase 0a) is yours, and no amount of not remembering it changes that.\nEvery other worktree is settled by its lock holder (Phase 0c), and each worktree's Docker\nresources by its compose-project label. Conversation history is the source of truth only\nfor what those two keys cannot reach: ad-hoc `docker run --name` containers, ports, and\nscratch paths. Anything you didn't start and can't attribute goes in \"left untouched.\"\nIf the user passed a scope arg (e.g. `worktree`), limit the sweep to that resource type.\n\nA compacted or `\u002Fclear`ed context is the normal case here, not an edge case. When history\nis thin, that is a reason to lean harder on the mechanical answers — never a reason to\ndowngrade `SELF_WORKTREE` or a subagent worktree to \"probably another session's.\"\n\n### Phase 0c — Classify every other worktree by its lock holder (read-only)\n\nPhase 0a settles only the worktree you are *standing in*. Subagents get their own:\n`Agent(isolation:\"worktree\")` and the `worktree.bgIsolation` setting both put each\nsubagent in `\u003CMAIN_REPO>\u002F.claude\u002Fworktrees\u002Fagent-\u003C17-hex>` on a `worktree-agent-\u003Cid>`\nbranch. A session that fanned out across a dozen agents therefore owns a dozen worktrees\nit never entered — and because nothing in conversation history survives compaction, they\nare the bulk of what this sweep used to leak.\n\nThe classifier is the **lock reason**. Every worktree the CLI enters is locked as\n`claude agent \u003Cname> (pid \u003CPID> start \u003Cts>)`, and that PID is the `claude` process — an\n**ancestor of your own shell**. So:\n\n| Lock state | Meaning | Disposition |\n|---|---|---|\n| pid is one of your ancestors | this session's subagent | tear down (3c) |\n| **no lock** | the agent finished and released it | tear down (3c) |\n| pid alive **and** is a `claude` process | another live session | **leave**, report |\n| pid gone, or recycled into a non-`claude` process | crashed session's orphan | tear down (3c) |\n\nThe bundled discovery script does this classification for you and prints one line per\nworktree under `WORKTREES CLASSIFIED`, tagged `SELF` \u002F `THIS-SESSION` \u002F\n`STALE-UNLOCKED` \u002F `FOREIGN-LIVE` \u002F `ORPHAN-DEAD-PID` \u002F `ORPHAN-PID-RECYCLED`, with the\nbranch, the uncommitted-file count, and each worktree's Docker resources. Read the tags\nand act on them; do not re-derive the attribution by hand.\n\nDoing it by hand takes one command plus one liveness check per distinct pid:\n\n```\ngit -C \u003CMAIN_REPO> worktree list --porcelain     # 'locked claude agent … (pid N start …)'\nps -o comm= -p \u003CN>                               # basename not claude -> orphan\n```\n\nYour own ancestor pids come from walking `ps -o ppid= -p \u003Cpid>` up from `$PPID`.\n\nCompare the **basename** of what `ps` prints. On macOS it is the full executable path, so\ntesting for `claude` anywhere in the string also matches an unrelated program living under\na directory with `claude` in its name — and that reads a dead lock as a live session,\npreserving the worktree forever.\n\n**Do not use the `start` timestamp to confirm a pid.** The lock records it in UTC while\n`ps -o lstart=` prints local time, so they disagree by your UTC offset on a perfectly\nhealthy lock. The command name is the recycling guard.\n\nAlso check `ListAgents` for subagents of *this* session still running. If any are, their\nworktrees are in use: skip them, finish the rest of the sweep, and name them in the\nreport rather than reaping a worktree out from under a working agent.\n\n### Phase 1 — Stop ephemeral runtime (permission-free)\n\n1. **Background tasks:** call `TaskStop` (deferred — `ToolSearch select:TaskStop`) for\n   each `task_id` this session spawned. For\n   manually-launched servers not tracked as tasks, `pkill -f '\u003Cpattern>'` or `kill \u003Cpid>`\n   (use the narrowest pattern that matches only this session's process). Confirm ports are\n   freed with `lsof -iTCP:\u003Cport> -sTCP:LISTEN -P -n`.\n2. **Local Tilt\u002FKubernetes:** `just -f \u003Crepo>\u002Fjustfile tilt-down` if the `justfile` defines\n   it, else `tilt down`. Kill lingering `kubectl port-forward`. Leave the namespace in place.\n3. **Docker:** `just -f \u003Crepo>\u002Fjustfile compose-down` if defined, else\n   `docker compose -f \u003Crepo>\u002F\u003Ccompose-file> down`. Add `-v` to also drop this session's\n   volumes\u002Flocal DB state — permission-free, no confirmation. `docker rm -f \u003Ccid>` for\n   ad-hoc `--name` containers this session started.\n4. **Docker left by subagent stacks.** A subagent that ran compose inside its own worktree\n   created a *separate* project, named after that worktree's directory — so\n   `compose down` in the main checkout does not touch it, and its containers, volumes and\n   networks outlive the agent. For each worktree Phase 0c marked as in-scope, tear down\n   its project by label (`\u003Cproj>` = the worktree directory basename):\n\n   ```\n   docker compose -p \u003Cproj> down -v --remove-orphans --rmi local\n   ```\n\n   `--rmi local` drops the images that project built itself and leaves pulled base images\n   (`postgres:16`, `apache\u002Fkafka`, `localstack`) alone. If the project's compose file is\n   gone with the worktree, `compose -p` has nothing to read; remove by label instead, one\n   plain command per call:\n\n   ```\n   docker rm -f $(docker ps -aq --filter label=com.docker.compose.project=\u003Cproj>)\n   docker volume rm $(docker volume ls -q --filter label=com.docker.compose.project=\u003Cproj>)\n   docker network rm $(docker network ls -q --filter label=com.docker.compose.project=\u003Cproj>)\n   docker image rm $(docker image ls -q --filter label=com.docker.compose.project=\u003Cproj>)\n   ```\n\n   Then `docker image prune -f` for untagged layers. **Never** `docker system prune`,\n   `image prune -a`, or `volume prune`: those reach shared base images, the build cache,\n   and anonymous volumes that carry no project label and no owner — `volume prune` in\n   particular would destroy another session's database. Anonymous volumes\n   (`com.docker.volume.anonymous`) are unattributable; `compose down -v` removes the ones\n   bound to the project's own containers, and the rest stay.\n\n### Phase 2 — Remove scratch files (permission-free)\n\nDelete only paths this session created, using absolute paths:\n\n- `rm -rf \u003Crepo>\u002F.claude\u002Fjobs\u002F\u003Cthis-session-id>\u002Ftmp`\n- `rm -f` the specific `\u002Ftmp\u002F*` scratch files\u002Fdirs this session made (commit messages, PR\n  bodies, review scratch).\n\nNever blanket-wipe `\u002Ftmp` or `.claude\u002Fjobs\u002F` — scope to this session's own paths.\n\n### Phase 3 — Git worktrees (permission-free)\n\nThree kinds of worktree get torn down here. 3a is the one the session is standing in; 3c\nis the larger pile the session handed to its subagents, and the one this phase used to\nwalk past.\n\n**3a. `SELF_WORKTREE` — the worktree this session is in (from Phase 0a).** Remove it\nunconditionally. You are inside it, so use the native tool, which relocates the session\nback to `MAIN_REPO` as it goes:\n\n```\nExitWorktree({\"action\":\"remove\",\"discard_changes\":true})\n```\n\n`discard_changes: true` is correct and deliberate: uncommitted work in a session worktree\nis teardown scope, not a data-loss gate to stop on (Principle 4). If `ExitWorktree` is\nunavailable, fall back to the `git` sequence below run against `MAIN_REPO`. If it refuses,\nreport what it said — do not leave the worktree standing silently.\n\n**3b. Any other worktree this session created** — throwaway checkouts under `\u002Ftmp`,\nreview clones, a second worktree spun up mid-task:\n\nThree separate Bash calls, in this order — `;`-joining them gets the whole line refused\nunder worktree isolation (Principle 7):\n\n```\ngit -C \u003CMAIN_REPO> worktree unlock \u003Cpath>           # errors if not locked; that error is fine\ngit -C \u003CMAIN_REPO> worktree remove --force \u003Cpath>   # .claude\u002Fworktrees\u002F\u003Cname> or \u002Ftmp\u002F\u003Cname>\ngit -C \u003CMAIN_REPO> worktree prune                   # clears stale admin refs (self-healing)\n```\n\n`git worktree remove --force` removes the worktree even if it has uncommitted changes —\nthat's intended here; run it without confirmation. **Unlock first.** A worktree the CLI\nentered (`EnterWorktree`, or `claude -w`) is locked for the session, and the lock can\noutlive the process that took it; without the unlock, removal fails with `cannot remove a\nlocked working tree, lock reason: claude session \u003Cname> (pid …)`. `remove -f -f` overrides\nthe lock too, if you prefer one command.\n\n**3c. Subagent and orphan worktrees (from Phase 0c).** Every worktree tagged\n`THIS-SESSION`, `STALE-UNLOCKED`, `ORPHAN-DEAD-PID`, or `ORPHAN-PID-RECYCLED` gets removed\nhere. `FOREIGN-LIVE` ones do not — a running `claude` process is using them.\n\nPer worktree, in this order, one plain command per Bash call:\n\n```\ngit -C \u003CMAIN_REPO> worktree unlock \u003Cpath>\ngit -C \u003CMAIN_REPO> worktree remove --force \u003Cpath>\n```\n\nThen, once for the whole batch:\n\n```\ngit -C \u003CMAIN_REPO> worktree prune\nrm -rf \u003Cunregistered-worktree-dir>     # dirs prune leaves behind (script lists them)\n```\n\nBranches, after the worktrees are gone:\n\n- `worktree-agent-\u003Cid>` and `worktree-\u003Cname>` are **auto-generated throwaway** names.\n  Delete them: `git -C \u003CMAIN_REPO> branch -D worktree-agent-\u003Cid>`.\n- A worktree on a **hand-named** branch (`worker-lib-split`, `fix-rustls-advisories`) holds\n  deliberate work. Remove the worktree, **keep the branch**, and list it in the report. The\n  commits survive the worktree; deleting the branch is what loses them.\n\n**The one preserve rule left.** A worktree whose uncommitted-file count is non-zero and\nthat is *not* `SELF` or `THIS-SESSION` — i.e. another session's leftover, live or dead —\nis preserved, not forced. Its dirty files were never committed anywhere, so `remove\n--force` is the only irreversible step in this whole sweep. Report the path and the file\ncount and move on. For `SELF` and `THIS-SESSION`, dirty is still teardown scope\n(Principle 4): force them.\n\nVerify with `git -C \u003CMAIN_REPO> worktree list` and confirm `SELF_WORKTREE` and every\nin-scope agent worktree are gone from it. A run that ends with the session's own worktree —\nor a pile of `agent-*` entries it spawned — still listed has failed this phase, even if\nevery other line of the report is green. Never remove a worktree tied to another active\nsession.\n\n### Phase 4 — Merged local branches (permission-free) + destructive git (hand back)\n\n**Merged local branches — delete directly.** `git branch -d\u002F-D\u002F--delete` is allow-listed\nfor teardown. For each local branch **this session** created whose PR is already merged (or\nwhich is otherwise dead), delete it without prompting, using `git -C`:\n\n```\ngit -C \u003Crepo> branch -D \u003Cbranch>       # e.g. worktree branch left behind after merge\ngit -C \u003Crepo> fetch origin --prune     # clears the remote-tracking ref\n```\n\nOnly delete branches you can attribute to this session and that are safe (merged, or never\npushed and clearly throwaway). If a branch has unmerged commits you can't attribute to\nmerged work, **preserve it** and list it under \"left for you.\"\n\n**Still hard-denied — never attempt, hand back to the user.** These remain deny-listed in\nsettings because they rewrite history or touch shared\u002Fremote state, and are **not**\nteardown. Do not run them; print the exact command for the user:\n\n- **Remote branch deletion:** `git push origin --delete \u003Cbranch>` (shared remote).\n- **History rewrite \u002F merge \u002F force-push:** `git reset --hard`, `gh pr merge`,\n  `git push --force* origin main`.\n\nIf the wrap-up implies any of these, list the ready-to-paste command and stop there.\n\n## Confirmation gating\n\n- **Permission-free in every mode the hook admits (run directly, no prompt — the whole sweep):**\n  stopping tasks\u002Fservers, `tilt down`, `docker compose down` **including `-v`**\n  (volume\u002Fdata wipe), scratch `rm`,\n  `git worktree remove --force` **including worktrees with uncommitted changes**,\n  `git worktree prune`, `git branch -d\u002F-D` for merged\u002Fthrowaway session branches,\n  `git fetch --prune`, `docker compose -p \u003Cproj> down -v --rmi local` and the\n  label-filtered `docker rm` \u002F `volume rm` \u002F `network rm` \u002F `image rm` for a subagent's\n  project, `docker image prune -f`. No `AskUserQuestion` gate anywhere in teardown.\n- **Never run — hand back:** `git push origin --delete`, `git reset --hard`, `gh pr merge`,\n  force-push to main (still deny-listed).\n- **Never run at all — not even on request here:** `docker system prune`,\n  `docker image prune -a`, `docker volume prune`, `docker builder prune`. They are\n  unscoped: they reach base images, the build cache, and label-less anonymous volumes\n  belonging to sessions and projects this sweep has no claim on. Label-filtered removal is\n  the only correct path.\n\n## Gotchas (environment-specific — do not assume otherwise)\n\n- **Teardown verbs are allow-listed**, so `git worktree remove\u002Fprune`, `git branch -d\u002F-D`,\n  `docker compose\u002Fstop\u002Frm\u002Fps`, `pkill`, `kill`, `pgrep`, `ps`, `lsof`, `rm -rf \u002Ftmp\u002F*`,\n  and `tilt down\u002Fget` run without a prompt. `just -f \u003Crepo>\u002Fjustfile compose-down` \u002F\n  `tilt-down` is the house convention — check the `justfile` before falling back to raw\n  commands.\n- **Bash allow rules match the raw command string**, with `*` spanning `\u002F` and spaces —\n  they are not gitignore-style path globs (that matcher serves `Read`\u002F`Edit` rules only).\n  So `Bash(rm -rf *.claude\u002Fjobs\u002F*)` does cover an absolute scratch path. It does not cover\n  flag reorderings like `rm -fr` or `rm -r -f`; keep to `rm -rf`.\n- **`auto` mode has no allow rules**, so in that mode the thing clearing the sweep is the\n  `autoMode.allow` entry describing it, not the `Bash(...)` rules — those are stripped at\n  mode entry. The practical difference: a classifier judgement is probabilistic where an\n  allow rule is not. If a teardown verb does get stopped in `auto`, that is a gap in the\n  prose entry; report it rather than retrying the command.\n- **Still deny-listed:** `git push origin --delete`, `git reset --hard`, force-push to main,\n  and `gh pr merge`. Attempting them wastes a turn on a guaranteed denial. Print-for-user is\n  the only correct path.\n- **`worktree.baseRef` is `fresh`** — worktrees branch from a freshly-fetched base, not local\n  `main`. Don't assume a branch's base is local HEAD when reasoning about merge status.\n- **A compacted context is not evidence of innocence.** The `EnterWorktree` and\n  `Agent(isolation:\"worktree\")` calls are usually gone from context by teardown time — long\n  sessions compact repeatedly. Reasoning \"I see no worktree creation in my history, so this\n  worktree must be another session's\" is the single most common way this skill leaves\n  worktrees behind. Phases 0a and 0c exist precisely so this judgement is never made from\n  memory.\n- **Subagents get worktrees you never entered.** `Agent(isolation:\"worktree\")` and the\n  `worktree.bgIsolation: \"worktree\"` setting create `.claude\u002Fworktrees\u002Fagent-\u003C17-hex>` per\n  agent, on a `worktree-agent-\u003Cid>` branch. A session that fanned out ten agents owns ten\n  worktrees that never appear in `ExitWorktree`'s view and that `SELF_WORKTREE` reasoning\n  never reaches — tens of gigabytes across a week. They are Phase 3c's job, and the lock\n  pid, not your memory, is what identifies them.\n- **The worktree lock reason names the holding pid**, as\n  `claude agent \u003Cname> (pid N start \u003Cts>)`. `N` is the `claude` CLI process and an ancestor\n  of your own shell when the agent was yours. Do **not** compare the lock's `start` stamp\n  with `ps -o lstart=`: the lock is UTC, `ps` is local, so they disagree by your offset on\n  a perfectly healthy lock.\n- **Check the holder's *basename*, not a substring.** macOS `ps -o comm=` prints the full\n  executable path, so matching `*claude*` also matches an unrelated program under a\n  directory with `claude` in its name — and reads a dead lock as a live session. A zombie\n  reports `\u003Cdefunct>` on macOS and nothing on Linux while still passing `kill -0`; both\n  mean the holder is gone.\n- **An unlocked `.claude\u002Fworktrees\u002F*` entry means the agent finished and released it** —\n  that is the signal this skill was missing, not a reason for caution. Agents under\n  `bgIsolation` release the lock when they complete.\n- **Compose project name == worktree directory basename.** That is why a subagent's stack\n  survives `compose down` run from the main checkout: it is a different project. It is also\n  why attribution is exact — `com.docker.compose.project=\u003Cbasename>` on every container,\n  volume, network, and locally built image. Networks named `\u003Cbasename>_default` left in\n  `docker network ls` are the visible symptom.\n- **`--rmi local` vs `--rmi all`.** `local` drops only images the project built itself;\n  `all` would delete `postgres:16` and friends out from under every other project on the\n  machine. Use `local`.\n- **Give the discovery script `MAIN_REPO`, never the worktree.** Its on-disk scan looks at\n  `\u003Carg>\u002F.claude\u002Fworktrees`. Pass a worktree path and that becomes\n  `\u003Cworktree>\u002F.claude\u002Fworktrees` — nonexistent — so the section is empty and the sweep\n  concludes there is nothing to remove.\n- **Session worktrees are locked.** `git worktree remove --force` alone fails on them; run\n  `git worktree unlock \u003Cpath>` first (or `remove -f -f`). A stale lock naming a dead pid is\n  still a lock.\n- **`worktree prune` leaves the directory.** It clears the admin ref, not the files on\n  disk, so a crashed session leaves a full checkout under `.claude\u002Fworktrees\u002F\u003Cname>` that\n  no longer appears in `worktree list`. The discovery script lists these under\n  `UNREGISTERED WORKTREE DIRS`; they need `rm -rf`, not another `prune`.\n- **The branch is `worktree-\u003Cname>`, not `\u003Cname>`.** EnterWorktree prefixes it, so deleting\n  by the worktree directory name silently deletes nothing (or the wrong branch). Read the\n  real name from `git -C \u003Crepo> worktree list --porcelain` before `branch -D`.\n- **An agent's branch is not always auto-named.** A subagent that renamed its branch sits in\n  `agent-\u003Chex>` on something like `fix-rustls-advisories`. The *directory* is still\n  throwaway; the *branch* is not. Delete only `worktree-*`-prefixed branches; keep the rest\n  and report them.\n- **Removing a worktree removes its `.env` copy.** `.worktreeinclude` puts a real\n  credential file in every worktree, so teardown is also the only thing that cleans those\n  copies up — intended. Never extend that reasoning to the *main* checkout's `.env`.\n- **`docker compose down -v` destroys volume data** (local Postgres\u002FKafka state) — that's the\n  intended full teardown here; add `-v` without asking. Only this session's stack, never a\n  shared one.\n- **Scratch lives in `.claude\u002Fjobs\u002F\u003C8-char-id>\u002Ftmp`** and assorted `\u002Ftmp\u002F*` paths. Only remove\n  this session's own IDs.\n- **Never treat a *live* session's worktree\u002Fbranch\u002Fcontainer as yours** — preserve and\n  report those as untouched. A worktree whose holder pid is gone is not a live session's;\n  it is debris, and reaping it is this phase's job.\n- Use absolute paths and `git -C \u003Cpath>`; never `cd` (per the user's global CLAUDE.md) — a\n  leading `cd` reintroduces the permission prompt this skill is built to avoid.\n\n## Final report, then exit\n\nClose with a concise summary, print it, **then quit the CLI as the very last action**.\n\nPrint this summary first:\n\n```\nSession teardown complete.\n  Stopped:   \u003Cbackground tasks \u002F servers \u002F ports freed>\n  Docker:    \u003Cstacks \u002F containers brought down>\n  Docker (subagent projects): \u003Cprojects down -v; volumes\u002Fnetworks\u002Fimages removed, by count>\n  Tilt\u002Fk8s:  \u003Ctilt down; port-forwards killed> (namespace left in place)\n  Scratch:   \u003Cpaths removed>\n  Worktree:  \u003CSELF_WORKTREE removed — this session's own> (or: none; ran from the main checkout)\n  Subagent worktrees: \u003CN removed: this session's agents + released\u002Forphaned> (or: none found)\n  Orphan dirs: \u003Cunregistered .claude\u002Fworktrees dirs rm -rf'd>\n  Branches:  \u003Cworktree-* branches deleted; hand-named branches kept>\n  Left for you (still denied): \u003Cgit push origin --delete \u002F reset --hard \u002F gh pr merge, if any>\n  Left untouched (live sessions): \u003CFOREIGN-LIVE worktrees + their containers, with holder pid>\n  Left untouched (dirty, not ours): \u003Cpath — N uncommitted files>\n\nExiting the CLI…\n```\n\nThen, as the **final tool call of the session**, quit Claude Code by terminating the CLI\nprocess (its PID is the parent of the shell your Bash tool runs in):\n\n```\nkill \"$PPID\"\n```\n\n`$PPID` resolves to the `claude` process, so this is the programmatic equivalent of the\nuser typing `\u002Fexit`. Run it only after the teardown is done and the summary is printed —\nnothing runs after it, because the CLI is gone. Do not run it if the user scoped the sweep\nto a single resource and asked to stay in the session; in that case, stop after the summary.\n","# Exit Session\n\nTeardown of everything a working session spun up: background processes, Docker\u002Fcompose\nstacks with their volumes, networks and locally built images, local Tilt\u002FKubernetes, git\nworktrees — the session's own **and every one it handed to a subagent** — merged local\nbranches, and scratch files, leaving the machine as clean as before the session started,\nthen quit the CLI. Designed\nto run **permission-free**: the teardown verbs are allow-listed in default, accept-edits\nand bypassPermissions mode, and described to the classifier in `autoMode.allow` for `auto`\nmode, so you execute the sweep directly without stopping for confirmation — including the\ntwo operations that destroy *data* rather than just tear down ephemeral resources. Only\nplan mode is refused (Phase 0).\n\n## Core principles\n\n1. **Scoped by live holder, not by memory.** A resource is off-limits when a *live*\n   session still holds it — not merely because you don't recall creating it. Worktrees\n   locked by another running `claude` pid, and their containers, are preserved and listed\n   under \"left untouched.\" Everything with no live holder — this session's own worktrees,\n   its subagents' worktrees, and worktrees whose holder pid is gone — is in scope.\n2. **Attribute mechanically first, from memory second.** Three resources are *knowable\n   with certainty*, so ask the system, never your recollection:\n   - the worktree this session sits in → `git rev-parse` (Phase 0a);\n   - which worktrees belong to this session's subagents → the git **lock reason**, which\n     names the holding `claude` pid; that pid is an ancestor of your own shell (Phase 0c);\n   - which Docker resources belong to a given worktree → the\n     `com.docker.compose.project` label, which equals the worktree directory basename.\n\n   Conversation history is the fallback for genuinely ambiguous resources (an ad-hoc\n   `docker run --name`, a scratch path), never the primary test for a worktree. By the\n   time a real session reaches teardown its context has usually compacted, so the\n   `EnterWorktree` and `Agent(isolation:\"worktree\")` calls are long gone — and \"I don't\n   remember creating it\" then silently becomes \"it must be someone else's,\" which is how\n   a session leaks its own worktree, and every worktree it gave a subagent, on every run.\n3. **Discover, then execute — no plan-gate.** Do one read-only discovery pass to build\n   the inventory, then tear down immediately. Teardown is pre-authorized; you do **not**\n   pause for a \"confirm the plan\" step. Show the inventory as you go so progress is visible.\n4. **Fully permission-free — no data-loss gate.** Once Phase 0 settles the mode, every\n   teardown of a resource this session created runs without a prompt, including\n   `docker compose down -v` (wipes volumes \u002F local DB state) and removing a worktree that\n   still has **uncommitted** changes. The only thing you never do is run the still-denied\n   remote\u002Fhistory ops (Phase 4) — those aren't teardown; hand them back.\n5. **Preserve on doubt — except where git already answered.** For anything you can't\n   attribute, default to leaving it and flagging it: a missed cleanup is cheap, a wrong\n   deletion is not. This does **not** apply to the worktrees Phase 0a and 0c settle\n   mechanically — those are answered by `git rev-parse` and the lock pid, so there is no\n   doubt to preserve on, and skipping them is the failure mode this rule is blamed for.\n   The one live remnant of the rule: a worktree with **uncommitted changes** that is not\n   this session's own gets preserved and reported, never discarded (Phase 3c).\n6. **No leading `cd`.** Use `git -C \u003Cpath>` and absolute paths. A leading `cd` triggers a\n   permission prompt (per the user's global CLAUDE.md) and defeats the point of a\n   permission-free sweep.\n7. **One plain command per Bash call while in a worktree.** When the session is inside a\n   linked worktree — the normal case for this sweep — Claude Code's isolation validator\n   refuses any Bash line it cannot statically prove stays inside it: *\"too complex to\n   verify that it stays inside the worktree; break it into plain, separate commands.\"*\n   It rejects `;` and `&&` chains, `$(…)` substitution, and heredocs **even when every\n   component is read-only**. It is a static-analysis gate, not a permission check, so no\n   allow rule and no permission mode gets past it. Issue separate Bash calls, in parallel\n   in one message where they're independent. The one exception is the bundled discovery\n   script: it is a single `bash \u003Cscript>` call, and the commands inside its own subshell\n   are not re-examined — which is also why it is the cheapest way to run discovery.\n\n## Workflow\n\nWork the phases in order. Create a todo per phase so progress is visible.\n\n### Phase 0 — Permission mode (preflight)\n\n**If you are reading this, the mode is already fine.** The bundled `UserPromptSubmit`\nhook (`hooks\u002Frequire-accept-edits.sh`) blocks `\u002Fexit-session` in plan mode before you ever\nsee the prompt, and it let this invocation through. Proceed straight to Phase 0a.\n\nOnly plan mode is refused, because it blocks the mutating tools the sweep needs. Every\nother mode works, by two different routes: `default`, `acceptEdits` and\n`bypassPermissions` honour the `Bash(...)` allow rules in settings.json, while `auto`\nstrips them all at mode-entry (`Ignoring dangerous permission \u003Crule> from \u003Csource>\n(bypasses classifier)` in the debug log) and relies instead on the `autoMode.allow` entry\ndescribing this sweep. Do not reintroduce an auto-mode gate: it fired on every single\ninvocation and cost the user a Shift+Tab and a re-run each time.\n\nNothing here can flip the mode for the user, so do not try: no hook output field sets it\n(`PreToolUse` returns only `permissionDecision` \u002F `permissionDecisionReason` \u002F\n`updatedInput` \u002F `additionalContext`), and the `setMode` permission update is reachable\nonly from the SDK permission bridge. The keystroke is the only lever. If prompts start\nlanding on verbs that should be covered, stop the sweep, report what has already been\ntorn down, and say which rule is missing — do not grind through the sweep one\nconfirmation at a time.\n\n### Phase 0a — Identify this session's own worktree (read-only, deterministic)\n\n**Do this first, before the discovery script.** It is three read-only commands and it\nsettles the question the rest of the sweep keeps getting wrong: *is the directory I am\nsitting in a worktree that should be torn down?*\n\nThree separate Bash calls, issued in parallel in one message — not `&&`-joined, and not\nwrapped in `echo \"$(…)\"` (Principle 7):\n\n```\ngit -C \u003Ccwd> rev-parse --git-dir           # linked worktree -> \u003Cmain>\u002F.git\u002Fworktrees\u002F\u003Cname>\ngit -C \u003Ccwd> rev-parse --git-common-dir    # linked worktree -> \u003Cmain>\u002F.git   (differs!)\ngit -C \u003Ccwd> rev-parse --show-toplevel     # linked worktree -> the worktree path itself\n```\n\n`git rev-parse --git-dir --git-common-dir --show-toplevel` in one call is also fine —\nthat is a single command with three flags, not a chain.\n\n- **`--git-dir` and `--git-common-dir` differ** → the session is inside a **linked\n  worktree**. `--show-toplevel` is `SELF_WORKTREE`, and the parent of `--git-common-dir`\n  is `MAIN_REPO`. `SELF_WORKTREE` is a teardown target **unconditionally** — do not ask\n  whether you remember creating it. A session lands in a worktree because it was put\n  there (`\u002Fstart-session`, `EnterWorktree`, `claude -w`), so by construction it is this\n  session's. Read the real branch from `git -C \u003CMAIN_REPO> worktree list --porcelain`\n  (it is `worktree-\u003Cname>`, not `\u003Cname>`).\n- **They are the same** → the session is in the main checkout. There is no self-worktree,\n  and Phase 3a is a no-op. This says **nothing** about the other worktrees in the list:\n  a session running from the main checkout still owns every worktree it handed to a\n  subagent. Phase 0c classifies those; do not conclude they are all other sessions'.\n\n`MAIN_REPO` — not `SELF_WORKTREE` — is the `\u003Crepo-root>` argument for everything that\nfollows. The bundled script resolves this itself and prints a `THIS SESSION'S OWN WORKTREE`\nsection, but pass `MAIN_REPO` anyway: handing a worktree path to a hand-rolled scan makes\nit look at `\u003Cworktree>\u002F.claude\u002Fworktrees`, a nested path that cannot exist, so the on-disk\nworktree section comes back empty and the sweep silently has nothing to do.\n\n### Phase 0b — Discover (read-only)\n\nBuild an inventory before touching anything. Run the bundled discovery script, which\ngathers the whole picture in one read-only pass. Pass the repo root as an argument —\n**do not `cd`**:\n\n```\nbash \u003Cskill-dir>\u002Fscripts\u002Fdiscover-resources.sh \u003Crepo-root>\n```\n\nAdd `--worktrees-only` when you only need the worktree picture — for\n`\u002Fexit-session worktree`, or to re-check the inventory after Phase 3. The full pass spends\nmost of its wall time in `pgrep -f`, about a second per pattern on a busy machine.\n\n(Substitute the real absolute path to this skill's `scripts\u002Fdiscover-resources.sh`, and\nthe absolute repo root.) Write it exactly that way: `bash ` then the bare unquoted path.\nQuoting the path, or executing the script directly without `bash `, changes the command\nstring enough to miss the allow rule and costs a prompt. It prints sections for the\nself-worktree, **every worktree classified by lock holder** (Phase 0c), unregistered\nworktree directories, current branch + merge status, background jobs\u002Fports, Docker\ncontainers, Docker volumes\u002Fnetworks\u002Fimages grouped by compose project, Tilt\u002Fk8s, and\nscratch dirs. If the script is unavailable, gather the same signals by hand (all\nread-only, all with `git -C`, no `cd`):\n\n- **Background tasks this session spawned:** use the `Monitor` tool to enumerate live\n  background shells and their `task_id`s — it is deferred, so `ToolSearch select:Monitor`\n  first. (There is no `TaskList` tool; asking for one wastes a turn.) Cross-reference\n  `ps` \u002F `pgrep -f` \u002F `lsof -iTCP -sTCP:LISTEN -P -n` for dev servers (vite,\n  `target\u002Fdebug\u002Fapi`, `cargo run -p api`, `npm run dev`, cloudflared,\n  `kubectl port-forward`).\n- **Worktrees:** `git -C \u003Crepo> worktree list --porcelain` (the `--porcelain` form is what\n  carries the lock reasons Phase 0c needs) and\n  `ls -la \u003Crepo>\u002F.claude\u002Fworktrees\u002F 2>\u002Fdev\u002Fnull`.\n- **Branch:** `git -C \u003Crepo> branch --show-current`, `git -C \u003Crepo> status -s`, and whether\n  its PR is merged (`gh pr view \u003Cbranch> --json state,mergedAt`).\n- **Docker:** `docker ps -a` (note session stacks like `postgres kafka localstack` and any\n  ad-hoc `--name` containers), plus `docker volume ls`, `docker network ls`, and\n  `docker image ls` — each with\n  `--filter label=com.docker.compose.project=\u003Cworktree-basename>` to attribute them.\n- **Tilt\u002Fk8s:** `tilt get session 2>\u002Fdev\u002Fnull`; `kubectl port-forward` procs.\n- **Scratch:** `.claude\u002Fjobs\u002F\u003Cid>\u002Ftmp` dirs and `\u002Ftmp\u002F*` paths this session created (PR\n  bodies, commit-msg files, review worktrees).\n\n**Attribute each resource mechanically where you can, from history only where you can't.**\n`SELF_WORKTREE` (Phase 0a) is yours, and no amount of not remembering it changes that.\nEvery other worktree is settled by its lock holder (Phase 0c), and each worktree's Docker\nresources by its compose-project label. Conversation history is the source of truth only\nfor what those two keys cannot reach: ad-hoc `docker run --name` containers, ports, and\nscratch paths. Anything you didn't start and can't attribute goes in \"left untouched.\"\nIf the user passed a scope arg (e.g. `worktree`), limit the sweep to that resource type.\n\nA compacted or `\u002Fclear`ed context is the normal case here, not an edge case. When history\nis thin, that is a reason to lean harder on the mechanical answers — never a reason to\ndowngrade `SELF_WORKTREE` or a subagent worktree to \"probably another session's.\"\n\n### Phase 0c — Classify every other worktree by its lock holder (read-only)\n\nPhase 0a settles only the worktree you are *standing in*. Subagents get their own:\n`Agent(isolation:\"worktree\")` and the `worktree.bgIsolation` setting both put each\nsubagent in `\u003CMAIN_REPO>\u002F.claude\u002Fworktrees\u002Fagent-\u003C17-hex>` on a `worktree-agent-\u003Cid>`\nbranch. A session that fanned out across a dozen agents therefore owns a dozen worktrees\nit never entered — and because nothing in conversation history survives compaction, they\nare the bulk of what this sweep used to leak.\n\nThe classifier is the **lock reason**. Every worktree the CLI enters is locked as\n`claude agent \u003Cname> (pid \u003CPID> start \u003Cts>)`, and that PID is the `claude` process — an\n**ancestor of your own shell**. So:\n\n| Lock state | Meaning | Disposition |\n|---|---|---|\n| pid is one of your ancestors | this session's subagent | tear down (3c) |\n| **no lock** | the agent finished and released it | tear down (3c) |\n| pid alive **and** is a `claude` process | another live session | **leave**, report |\n| pid gone, or recycled into a non-`claude` process | crashed session's orphan | tear down (3c) |\n\nThe bundled discovery script does this classification for you and prints one line per\nworktree under `WORKTREES CLASSIFIED`, tagged `SELF` \u002F `THIS-SESSION` \u002F\n`STALE-UNLOCKED` \u002F `FOREIGN-LIVE` \u002F `ORPHAN-DEAD-PID` \u002F `ORPHAN-PID-RECYCLED`, with the\nbranch, the uncommitted-file count, and each worktree's Docker resources. Read the tags\nand act on them; do not re-derive the attribution by hand.\n\nDoing it by hand takes one command plus one liveness check per distinct pid:\n\n```\ngit -C \u003CMAIN_REPO> worktree list --porcelain     # 'locked claude agent … (pid N start …)'\nps -o comm= -p \u003CN>                               # basename not claude -> orphan\n```\n\nYour own ancestor pids come from walking `ps -o ppid= -p \u003Cpid>` up from `$PPID`.\n\nCompare the **basename** of what `ps` prints. On macOS it is the full executable path, so\ntesting for `claude` anywhere in the string also matches an unrelated program living under\na directory with `claude` in its name — and that reads a dead lock as a live session,\npreserving the worktree forever.\n\n**Do not use the `start` timestamp to confirm a pid.** The lock records it in UTC while\n`ps -o lstart=` prints local time, so they disagree by your UTC offset on a perfectly\nhealthy lock. The command name is the recycling guard.\n\nAlso check `ListAgents` for subagents of *this* session still running. If any are, their\nworktrees are in use: skip them, finish the rest of the sweep, and name them in the\nreport rather than reaping a worktree out from under a working agent.\n\n### Phase 1 — Stop ephemeral runtime (permission-free)\n\n1. **Background tasks:** call `TaskStop` (deferred — `ToolSearch select:TaskStop`) for\n   each `task_id` this session spawned. For\n   manually-launched servers not tracked as tasks, `pkill -f '\u003Cpattern>'` or `kill \u003Cpid>`\n   (use the narrowest pattern that matches only this session's process). Confirm ports are\n   freed with `lsof -iTCP:\u003Cport> -sTCP:LISTEN -P -n`.\n2. **Local Tilt\u002FKubernetes:** `just -f \u003Crepo>\u002Fjustfile tilt-down` if the `justfile` defines\n   it, else `tilt down`. Kill lingering `kubectl port-forward`. Leave the namespace in place.\n3. **Docker:** `just -f \u003Crepo>\u002Fjustfile compose-down` if defined, else\n   `docker compose -f \u003Crepo>\u002F\u003Ccompose-file> down`. Add `-v` to also drop this session's\n   volumes\u002Flocal DB state — permission-free, no confirmation. `docker rm -f \u003Ccid>` for\n   ad-hoc `--name` containers this session started.\n4. **Docker left by subagent stacks.** A subagent that ran compose inside its own worktree\n   created a *separate* project, named after that worktree's directory — so\n   `compose down` in the main checkout does not touch it, and its containers, volumes and\n   networks outlive the agent. For each worktree Phase 0c marked as in-scope, tear down\n   its project by label (`\u003Cproj>` = the worktree directory basename):\n\n   ```\n   docker compose -p \u003Cproj> down -v --remove-orphans --rmi local\n   ```\n\n   `--rmi local` drops the images that project built itself and leaves pulled base images\n   (`postgres:16`, `apache\u002Fkafka`, `localstack`) alone. If the project's compose file is\n   gone with the worktree, `compose -p` has nothing to read; remove by label instead, one\n   plain command per call:\n\n   ```\n   docker rm -f $(docker ps -aq --filter label=com.docker.compose.project=\u003Cproj>)\n   docker volume rm $(docker volume ls -q --filter label=com.docker.compose.project=\u003Cproj>)\n   docker network rm $(docker network ls -q --filter label=com.docker.compose.project=\u003Cproj>)\n   docker image rm $(docker image ls -q --filter label=com.docker.compose.project=\u003Cproj>)\n   ```\n\n   Then `docker image prune -f` for untagged layers. **Never** `docker system prune`,\n   `image prune -a`, or `volume prune`: those reach shared base images, the build cache,\n   and anonymous volumes that carry no project label and no owner — `volume prune` in\n   particular would destroy another session's database. Anonymous volumes\n   (`com.docker.volume.anonymous`) are unattributable; `compose down -v` removes the ones\n   bound to the project's own containers, and the rest stay.\n\n### Phase 2 — Remove scratch files (permission-free)\n\nDelete only paths this session created, using absolute paths:\n\n- `rm -rf \u003Crepo>\u002F.claude\u002Fjobs\u002F\u003Cthis-session-id>\u002Ftmp`\n- `rm -f` the specific `\u002Ftmp\u002F*` scratch files\u002Fdirs this session made (commit messages, PR\n  bodies, review scratch).\n\nNever blanket-wipe `\u002Ftmp` or `.claude\u002Fjobs\u002F` — scope to this session's own paths.\n\n### Phase 3 — Git worktrees (permission-free)\n\nThree kinds of worktree get torn down here. 3a is the one the session is standing in; 3c\nis the larger pile the session handed to its subagents, and the one this phase used to\nwalk past.\n\n**3a. `SELF_WORKTREE` — the worktree this session is in (from Phase 0a).** Remove it\nunconditionally. You are inside it, so use the native tool, which relocates the session\nback to `MAIN_REPO` as it goes:\n\n```\nExitWorktree({\"action\":\"remove\",\"discard_changes\":true})\n```\n\n`discard_changes: true` is correct and deliberate: uncommitted work in a session worktree\nis teardown scope, not a data-loss gate to stop on (Principle 4). If `ExitWorktree` is\nunavailable, fall back to the `git` sequence below run against `MAIN_REPO`. If it refuses,\nreport what it said — do not leave the worktree standing silently.\n\n**3b. Any other worktree this session created** — throwaway checkouts under `\u002Ftmp`,\nreview clones, a second worktree spun up mid-task:\n\nThree separate Bash calls, in this order — `;`-joining them gets the whole line refused\nunder worktree isolation (Principle 7):\n\n```\ngit -C \u003CMAIN_REPO> worktree unlock \u003Cpath>           # errors if not locked; that error is fine\ngit -C \u003CMAIN_REPO> worktree remove --force \u003Cpath>   # .claude\u002Fworktrees\u002F\u003Cname> or \u002Ftmp\u002F\u003Cname>\ngit -C \u003CMAIN_REPO> worktree prune                   # clears stale admin refs (self-healing)\n```\n\n`git worktree remove --force` removes the worktree even if it has uncommitted changes —\nthat's intended here; run it without confirmation. **Unlock first.** A worktree the CLI\nentered (`EnterWorktree`, or `claude -w`) is locked for the session, and the lock can\noutlive the process that took it; without the unlock, removal fails with `cannot remove a\nlocked working tree, lock reason: claude session \u003Cname> (pid …)`. `remove -f -f` overrides\nthe lock too, if you prefer one command.\n\n**3c. Subagent and orphan worktrees (from Phase 0c).** Every worktree tagged\n`THIS-SESSION`, `STALE-UNLOCKED`, `ORPHAN-DEAD-PID`, or `ORPHAN-PID-RECYCLED` gets removed\nhere. `FOREIGN-LIVE` ones do not — a running `claude` process is using them.\n\nPer worktree, in this order, one plain command per Bash call:\n\n```\ngit -C \u003CMAIN_REPO> worktree unlock \u003Cpath>\ngit -C \u003CMAIN_REPO> worktree remove --force \u003Cpath>\n```\n\nThen, once for the whole batch:\n\n```\ngit -C \u003CMAIN_REPO> worktree prune\nrm -rf \u003Cunregistered-worktree-dir>     # dirs prune leaves behind (script lists them)\n```\n\nBranches, after the worktrees are gone:\n\n- `worktree-agent-\u003Cid>` and `worktree-\u003Cname>` are **auto-generated throwaway** names.\n  Delete them: `git -C \u003CMAIN_REPO> branch -D worktree-agent-\u003Cid>`.\n- A worktree on a **hand-named** branch (`worker-lib-split`, `fix-rustls-advisories`) holds\n  deliberate work. Remove the worktree, **keep the branch**, and list it in the report. The\n  commits survive the worktree; deleting the branch is what loses them.\n\n**The one preserve rule left.** A worktree whose uncommitted-file count is non-zero and\nthat is *not* `SELF` or `THIS-SESSION` — i.e. another session's leftover, live or dead —\nis preserved, not forced. Its dirty files were never committed anywhere, so `remove\n--force` is the only irreversible step in this whole sweep. Report the path and the file\ncount and move on. For `SELF` and `THIS-SESSION`, dirty is still teardown scope\n(Principle 4): force them.\n\nVerify with `git -C \u003CMAIN_REPO> worktree list` and confirm `SELF_WORKTREE` and every\nin-scope agent worktree are gone from it. A run that ends with the session's own worktree —\nor a pile of `agent-*` entries it spawned — still listed has failed this phase, even if\nevery other line of the report is green. Never remove a worktree tied to another active\nsession.\n\n### Phase 4 — Merged local branches (permission-free) + destructive git (hand back)\n\n**Merged local branches — delete directly.** `git branch -d\u002F-D\u002F--delete` is allow-listed\nfor teardown. For each local branch **this session** created whose PR is already merged (or\nwhich is otherwise dead), delete it without prompting, using `git -C`:\n\n```\ngit -C \u003Crepo> branch -D \u003Cbranch>       # e.g. worktree branch left behind after merge\ngit -C \u003Crepo> fetch origin --prune     # clears the remote-tracking ref\n```\n\nOnly delete branches you can attribute to this session and that are safe (merged, or never\npushed and clearly throwaway). If a branch has unmerged commits you can't attribute to\nmerged work, **preserve it** and list it under \"left for you.\"\n\n**Still hard-denied — never attempt, hand back to the user.** These remain deny-listed in\nsettings because they rewrite history or touch shared\u002Fremote state, and are **not**\nteardown. Do not run them; print the exact command for the user:\n\n- **Remote branch deletion:** `git push origin --delete \u003Cbranch>` (shared remote).\n- **History rewrite \u002F merge \u002F force-push:** `git reset --hard`, `gh pr merge`,\n  `git push --force* origin main`.\n\nIf the wrap-up implies any of these, list the ready-to-paste command and stop there.\n\n## Confirmation gating\n\n- **Permission-free in every mode the hook admits (run directly, no prompt — the whole sweep):**\n  stopping tasks\u002Fservers, `tilt down`, `docker compose down` **including `-v`**\n  (volume\u002Fdata wipe), scratch `rm`,\n  `git worktree remove --force` **including worktrees with uncommitted changes**,\n  `git worktree prune`, `git branch -d\u002F-D` for merged\u002Fthrowaway session branches,\n  `git fetch --prune`, `docker compose -p \u003Cproj> down -v --rmi local` and the\n  label-filtered `docker rm` \u002F `volume rm` \u002F `network rm` \u002F `image rm` for a subagent's\n  project, `docker image prune -f`. No `AskUserQuestion` gate anywhere in teardown.\n- **Never run — hand back:** `git push origin --delete`, `git reset --hard`, `gh pr merge`,\n  force-push to main (still deny-listed).\n- **Never run at all — not even on request here:** `docker system prune`,\n  `docker image prune -a`, `docker volume prune`, `docker builder prune`. They are\n  unscoped: they reach base images, the build cache, and label-less anonymous volumes\n  belonging to sessions and projects this sweep has no claim on. Label-filtered removal is\n  the only correct path.\n\n## Gotchas (environment-specific — do not assume otherwise)\n\n- **Teardown verbs are allow-listed**, so `git worktree remove\u002Fprune`, `git branch -d\u002F-D`,\n  `docker compose\u002Fstop\u002Frm\u002Fps`, `pkill`, `kill`, `pgrep`, `ps`, `lsof`, `rm -rf \u002Ftmp\u002F*`,\n  and `tilt down\u002Fget` run without a prompt. `just -f \u003Crepo>\u002Fjustfile compose-down` \u002F\n  `tilt-down` is the house convention — check the `justfile` before falling back to raw\n  commands.\n- **Bash allow rules match the raw command string**, with `*` spanning `\u002F` and spaces —\n  they are not gitignore-style path globs (that matcher serves `Read`\u002F`Edit` rules only).\n  So `Bash(rm -rf *.claude\u002Fjobs\u002F*)` does cover an absolute scratch path. It does not cover\n  flag reorderings like `rm -fr` or `rm -r -f`; keep to `rm -rf`.\n- **`auto` mode has no allow rules**, so in that mode the thing clearing the sweep is the\n  `autoMode.allow` entry describing it, not the `Bash(...)` rules — those are stripped at\n  mode entry. The practical difference: a classifier judgement is probabilistic where an\n  allow rule is not. If a teardown verb does get stopped in `auto`, that is a gap in the\n  prose entry; report it rather than retrying the command.\n- **Still deny-listed:** `git push origin --delete`, `git reset --hard`, force-push to main,\n  and `gh pr merge`. Attempting them wastes a turn on a guaranteed denial. Print-for-user is\n  the only correct path.\n- **`worktree.baseRef` is `fresh`** — worktrees branch from a freshly-fetched base, not local\n  `main`. Don't assume a branch's base is local HEAD when reasoning about merge status.\n- **A compacted context is not evidence of innocence.** The `EnterWorktree` and\n  `Agent(isolation:\"worktree\")` calls are usually gone from context by teardown time — long\n  sessions compact repeatedly. Reasoning \"I see no worktree creation in my history, so this\n  worktree must be another session's\" is the single most common way this skill leaves\n  worktrees behind. Phases 0a and 0c exist precisely so this judgement is never made from\n  memory.\n- **Subagents get worktrees you never entered.** `Agent(isolation:\"worktree\")` and the\n  `worktree.bgIsolation: \"worktree\"` setting create `.claude\u002Fworktrees\u002Fagent-\u003C17-hex>` per\n  agent, on a `worktree-agent-\u003Cid>` branch. A session that fanned out ten agents owns ten\n  worktrees that never appear in `ExitWorktree`'s view and that `SELF_WORKTREE` reasoning\n  never reaches — tens of gigabytes across a week. They are Phase 3c's job, and the lock\n  pid, not your memory, is what identifies them.\n- **The worktree lock reason names the holding pid**, as\n  `claude agent \u003Cname> (pid N start \u003Cts>)`. `N` is the `claude` CLI process and an ancestor\n  of your own shell when the agent was yours. Do **not** compare the lock's `start` stamp\n  with `ps -o lstart=`: the lock is UTC, `ps` is local, so they disagree by your offset on\n  a perfectly healthy lock.\n- **Check the holder's *basename*, not a substring.** macOS `ps -o comm=` prints the full\n  executable path, so matching `*claude*` also matches an unrelated program under a\n  directory with `claude` in its name — and reads a dead lock as a live session. A zombie\n  reports `\u003Cdefunct>` on macOS and nothing on Linux while still passing `kill -0`; both\n  mean the holder is gone.\n- **An unlocked `.claude\u002Fworktrees\u002F*` entry means the agent finished and released it** —\n  that is the signal this skill was missing, not a reason for caution. Agents under\n  `bgIsolation` release the lock when they complete.\n- **Compose project name == worktree directory basename.** That is why a subagent's stack\n  survives `compose down` run from the main checkout: it is a different project. It is also\n  why attribution is exact — `com.docker.compose.project=\u003Cbasename>` on every container,\n  volume, network, and locally built image. Networks named `\u003Cbasename>_default` left in\n  `docker network ls` are the visible symptom.\n- **`--rmi local` vs `--rmi all`.** `local` drops only images the project built itself;\n  `all` would delete `postgres:16` and friends out from under every other project on the\n  machine. Use `local`.\n- **Give the discovery script `MAIN_REPO`, never the worktree.** Its on-disk scan looks at\n  `\u003Carg>\u002F.claude\u002Fworktrees`. Pass a worktree path and that becomes\n  `\u003Cworktree>\u002F.claude\u002Fworktrees` — nonexistent — so the section is empty and the sweep\n  concludes there is nothing to remove.\n- **Session worktrees are locked.** `git worktree remove --force` alone fails on them; run\n  `git worktree unlock \u003Cpath>` first (or `remove -f -f`). A stale lock naming a dead pid is\n  still a lock.\n- **`worktree prune` leaves the directory.** It clears the admin ref, not the files on\n  disk, so a crashed session leaves a full checkout under `.claude\u002Fworktrees\u002F\u003Cname>` that\n  no longer appears in `worktree list`. The discovery script lists these under\n  `UNREGISTERED WORKTREE DIRS`; they need `rm -rf`, not another `prune`.\n- **The branch is `worktree-\u003Cname>`, not `\u003Cname>`.** EnterWorktree prefixes it, so deleting\n  by the worktree directory name silently deletes nothing (or the wrong branch). Read the\n  real name from `git -C \u003Crepo> worktree list --porcelain` before `branch -D`.\n- **An agent's branch is not always auto-named.** A subagent that renamed its branch sits in\n  `agent-\u003Chex>` on something like `fix-rustls-advisories`. The *directory* is still\n  throwaway; the *branch* is not. Delete only `worktree-*`-prefixed branches; keep the rest\n  and report them.\n- **Removing a worktree removes its `.env` copy.** `.worktreeinclude` puts a real\n  credential file in every worktree, so teardown is also the only thing that cleans those\n  copies up — intended. Never extend that reasoning to the *main* checkout's `.env`.\n- **`docker compose down -v` destroys volume data** (local Postgres\u002FKafka state) — that's the\n  intended full teardown here; add `-v` without asking. Only this session's stack, never a\n  shared one.\n- **Scratch lives in `.claude\u002Fjobs\u002F\u003C8-char-id>\u002Ftmp`** and assorted `\u002Ftmp\u002F*` paths. Only remove\n  this session's own IDs.\n- **Never treat a *live* session's worktree\u002Fbranch\u002Fcontainer as yours** — preserve and\n  report those as untouched. A worktree whose holder pid is gone is not a live session's;\n  it is debris, and reaping it is this phase's job.\n- Use absolute paths and `git -C \u003Cpath>`; never `cd` (per the user's global CLAUDE.md) — a\n  leading `cd` reintroduces the permission prompt this skill is built to avoid.\n\n## Final report, then exit\n\nClose with a concise summary, print it, **then quit the CLI as the very last action**.\n\nPrint this summary first:\n\n```\nSession teardown complete.\n  Stopped:   \u003Cbackground tasks \u002F servers \u002F ports freed>\n  Docker:    \u003Cstacks \u002F containers brought down>\n  Docker (subagent projects): \u003Cprojects down -v; volumes\u002Fnetworks\u002Fimages removed, by count>\n  Tilt\u002Fk8s:  \u003Ctilt down; port-forwards killed> (namespace left in place)\n  Scratch:   \u003Cpaths removed>\n  Worktree:  \u003CSELF_WORKTREE removed — this session's own> (or: none; ran from the main checkout)\n  Subagent worktrees: \u003CN removed: this session's agents + released\u002Forphaned> (or: none found)\n  Orphan dirs: \u003Cunregistered .claude\u002Fworktrees dirs rm -rf'd>\n  Branches:  \u003Cworktree-* branches deleted; hand-named branches kept>\n  Left for you (still denied): \u003Cgit push origin --delete \u002F reset --hard \u002F gh pr merge, if any>\n  Left untouched (live sessions): \u003CFOREIGN-LIVE worktrees + their containers, with holder pid>\n  Left untouched (dirty, not ours): \u003Cpath — N uncommitted files>\n\nExiting the CLI…\n```\n\nThen, as the **final tool call of the session**, quit Claude Code by terminating the CLI\nprocess (its PID is the parent of the shell your Bash tool runs in):\n\n```\nkill \"$PPID\"\n```\n\n`$PPID` resolves to the `claude` process, so this is the programmatic equivalent of the\nuser typing `\u002Fexit`. Run it only after the teardown is done and the summary is printed —\nnothing runs after it, because the CLI is gone. Do not run it if the user scoped the sweep\nto a single resource and asked to stay in the session; in that case, stop after the summary.\n",{"name":5,"license":15,"description":7,"argument-hint":24,"compatibility":25,"disable-model-invocation":26},"[optional: resource to scope to, e.g. worktree | docker | tilt | scratch]","Assumes a git repo with optional worktrees under .claude\u002Fworktrees\u002F or \u002Ftmp; Docker + docker compose; optional Tilt (rancher-desktop\u002Fk3d); optional `just` task runner. Runs without prompts in default, accept-edits and bypassPermissions mode via allow rules in settings.json, and in `auto` mode — which strips those rules — via an autoMode.allow entry describing the sweep. Only plan mode is refused, by the bundled UserPromptSubmit hook, since it blocks mutating tools outright. The final self-exit uses `kill \"$PPID\"` (the CLI process).",true,"main","a3f19bcc313571bff79dca391a83f9c4d38bb335","session-mgmt\u002Fskills\u002Fexit-session",0,"https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum","https:\u002F\u002Fgithub.com\u002Fozzycodes2","Software Engineer | Engineering Manager | AI whisperer | ☕Enjoyer","2026-11-14 04:50:11",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":26},[37,40,43],{"tool":38,"command":39},"npx","npx skills add ozzycodes2\u002Fclaudellum --skill exit-session",{"tool":41,"command":42},"bunx","bunx skills add ozzycodes2\u002Fclaudellum --skill exit-session",{"tool":44,"command":45},"pnpm","pnpm dlx skills add ozzycodes2\u002Fclaudellum --skill exit-session","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Fsession-mgmt\u002Fskills\u002Fexit-session\u002FSKILL.md",[48],{"path":49,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":52,"sourceHtmlUrl":53},"scripts\u002Fdiscover-resources.sh","SCRIPT","脚本",11317,"https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Fsession-mgmt\u002Fskills\u002Fexit-session\u002Fscripts\u002Fdiscover-resources.sh",[55,62,69,76,83,90],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7ASQB3CTKMKDNAXD9DCF1YC","writing-design-docs","Use when the user wants to write a problem-statement design doc, says \"let's plan a feature properly\" \u002F \"write a design doc\" \u002F \"I'm thinking about how to do X\" for a non-trivial X, or before committing to a non-obvious technical direction","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Ftechnical-writing\u002Fskills\u002Fwriting-design-docs\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7ASQ6JD4QRV5ZKK2QME401Y","write-doc","Use when the user asks to write or draft a README, ADR, runbook, tutorial, how-to, explanation, or reference doc, or a caller passes \"type ADR\" or \"type README\". Picks the type, fills a template, adds diagrams. RFCs and design docs belong to writing-design-docs.","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Ftechnical-writing\u002Fskills\u002Fwrite-doc\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7ASQ1VWNVP1RE7M5D4G2QMG","review-doc","Use when the user asks to review, critique, score, grade, or \"how good is this doc\" for a Markdown doc or pasted text. Read-only. Scores it on the 20 Practical Prose dimensions and emits a findings table. Does not edit; fix-doc applies the findings next.","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Ftechnical-writing\u002Fskills\u002Freview-doc\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7ASPWST208JZNR7HF7J6KMV","fix-doc","Use when the user asks to fix, edit for prose quality, polish, tighten, humanize, or de-slop a Markdown doc or pasted text, or says \"make this read less AI\". Applies review-doc findings, generates flagged diagrams, lists substantive issues for the author, then runs the AI-tell pass last. Modifies the target.","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Ftechnical-writing\u002Fskills\u002Ffix-doc\u002FSKILL.md",[],[],{"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":19},"01M7ASPS6Y9ZGK9KCDHNPDR75A","create-slides","Use when the user asks for a slide deck, presentation, talk, or slides from a document, report, PR, notes, or topic. Builds one self-contained Machinify-branded HTML deck in a minimalist style, with headline-plus-visual slides, speaker notes, and every diagram drawn by architecture-design:create-diagram.","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Ftechnical-writing\u002Fskills\u002Fcreate-slides\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M7ASPAKFY045KHR92Y4QFTWV","start-session","Open a Claude Code working session in a fresh, isolated git worktree, so the user can start a task with a single \u002Fstart-session \u003Cname>. Use at the START of a session when the user says \"start session\", \"start a worktree\", \"spin up a worktree for ABC-123\", \"begin work on \u003Cticket>\", or passes a name\u002Fticket to work under. Creates and ENTERS a worktree via the EnterWorktree tool (never `git worktree add`) under .claude\u002Fworktrees\u002F, named exactly after the argument, on a local branch `worktree-\u003Cargument>`. Reports what the worktree inherited (`.worktreeinclude` copies, symlinked node_modules) and whether its `.env` still points at the main checkout's stack. If the argument is a JIRA key (e.g. ABC-123, PROJ-1505), also loads that story with the Atlassian CLI (`acli`) when available and summarizes the implementation ask. Also renames the session to the argument (the same effect as `\u002Frename \u003CNAME>`) so it's easy to find in `\u002Fresume`. Then stops and waits — it sets up the workspace and context, it does not implement.","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Fsession-mgmt\u002Fskills\u002Fstart-session\u002FSKILL.md",[],[]]