用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/nirecom/agents --skill worktree-end命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | worktree-end |
| description | Inventory gitignored state, merge PR, and clean up a git worktree after task completion |
| user-invocable | false |
Inventory gitignored state, merge the PR, then remove the worktree safely.
When a hook blocks a sanctioned command, a fallback path is taken, or any unexpected outcome occurs, report via /supervisor-report (trigger conditions: rules/supervisor-reporting.md).
Read rules/github-issues.md before WE-4 — on-demand-only, never auto-injected; WE-4..WE-8 and WE-11 depend on it.
Read rules/mid-workflow-findings.md before WE-10 — on-demand-only, never auto-injected; WE-10 depends on its append CLI and severity tagging.
Read rules/coding.md before WE-4 — on-demand-only, never auto-injected; its Public GitHub Rules govern the PR body, issue comments, and history entries written from here on.
PLANS_DIR="$(bash "$AGENTS_CONFIG_DIR/bin/workflow-plans-dir")" — run once; reuse. Canonical: skills/_shared/resolve-plans-dir.md.
gh --version — abort with installation guidance if not found.git rev-parse --git-common-dir must differ from git rev-parse --git-dir; if equal, abort.Run bash "$AGENTS_CONFIG_DIR/bin/check-unstaged-tracked.sh" "$WORKTREE_PATH". rc=0 → continue. rc=1 → display stdout and abort (git add / git stash push -u / <<WORKFLOW_ENFORCE_WORKFLOW_OFF: {reason}>> to bypass). rc=2/3 → surface stderr and abort. Skip when WORKFLOW_OFF or WORKTREE_OFF session marker is active.
Bootstrap probe: PROBE_JSON="$(bash "$AGENTS_CONFIG_DIR/bin/probe-remote-bootstrap.sh" "$WORKTREE_PATH")". preBootstrap === true AND classification === "empty-repo" → WE-4b. Any other classification → normal flow.
Push (git push -u origin <branch>), then gh pr view --json state,url — reuse if OPEN, else gh pr create --fill. Display URL. Capture PR_NUMBER=$(gh pr view --json number --jq .number); abort if empty.
bash "$AGENTS_CONFIG_DIR/skills/worktree-end/scripts/bootstrap-complete.sh" "$WORKTREE_PATH" "$BRANCH" "$OWNER_REPO" — parse BOOTSTRAP_COMMIT_SHA and DEFAULT_BRANCH_SET. Non-zero → stop.BOOTSTRAP_MODE=1, PR_NUMBER="", PR_STATE="BOOTSTRAP".<<WORKFLOW_USER_VERIFIED: bootstrap initial commit pushed to main>> via skills/_shared/user-verified.md.BOOTSTRAP_MODE=1 and BOOTSTRAP_COMMIT_SHA), WE-15.gh pr view "$PR_NUMBER" --json state --jq .state: MERGED → WE-7 (the merge happened outside this session's WE-8 — Web UI or another client — so WE-7 is the detection path for it). CLOSED → error and stop. OPEN → continue. other/error/empty → error and stop.
Check AUTO_MERGE_PR: bash -c 'cd "$AGENTS_CONFIG_DIR" && bash "$AGENTS_CONFIG_DIR/bin/confirm-off" AUTO_MERGE_PR on'. ON/ERROR → announce and proceed to WE-8. OFF → AskUserQuestion "PR # — merge, wait-for-web-merge, or abort?" → WE-8 / WE-6 / stop. Default wait-for-web-merge when AskUserQuestion unavailable.
Display URL; stop. On reply: gh pr view "$PR_NUMBER" --json state — MERGED → WE-7; else re-display and stop.
git fetch --prune origin, then emit user-verified sentinel via skills/_shared/user-verified.md (description: "User confirmed PR #<N> merged via web UI") → WE-9.
Skip the sentinel and go straight to WE-9 when this session already recorded user_verification as complete for this merge — check node "$AGENTS_CONFIG_DIR/bin/workflow/next-step" --session "$SID" and treat a REASON= other than user_verification as already-recorded. Keep CWD in the linked worktree throughout WE-7; do not switch to main worktree before WE-13.
Emit user-verified sentinel via skills/_shared/user-verified.md (description: "PR #<N> — approving merge to main"), then gh pr merge --squash --delete-branch. Failure → surface error and stop. Keep CWD in the linked worktree throughout WE-8; do not switch to main worktree before WE-13.
Backup dir is derived by the worker as <main_root>/.worktree-backup/<branch>/ — never passed in.
Both passes dispatch the worktree-backup worker per skills/_shared/worker-dispatch.md with payload worktree_path / branch / docker_check: true / artifact_dir, differing only in mode. Use payload sequence suffixes -1 and -2 so Pass 1's file is not overwritten.
Serial by dependency (SC-S): Pass 2 copies exactly the file set Pass 1 inventoried and reported — a parallel Pass 2 would act on an uninventoried set and both passes write the same backup directory. See skills/_shared/subagent-concurrency.md.
Pass 1 — mode: "dry_run": status: failed → stop. File count 0 → BACKUP_MANIFEST_PATH=(none), skip Pass 2.
Pass 2 — mode: "execute": status: failed → stop. status: partial → warn and continue. status: copied → set BACKUP_MANIFEST_PATH from artifact_path.
Append any outstanding BugsFound / RelatedTasks / NextTasks to <worktree>/WORKTREE_NOTES.md. Capture cutoff — findings after this step are excluded from the Final Report.
Use the append CLI and severity tagging per rules/mid-workflow-findings.md.
Run the pass in skills/_shared/notes-promotion.md unconditionally at this step — the worktree and its notes are deleted later in this skill, so no downstream callsite can reach them.
Resolve the path with node "$AGENTS_CONFIG_DIR/bin/worktree-notes-triage.js" resolve --caller worktree-end --worktree "$WORKTREE_PATH", then follow NP-1..NP-11 as written.
## History Notes / ## Changelog Notes are excluded from the pass. Continue to WE-12 in every outcome.
Resolve SID: awk '/^Session-ID:/{sub(/^Session-ID:[[:space:]]*/,""); sub(/\r/,""); print; exit}' "$WORKTREE_PATH/WORKTREE_NOTES.md" → fallback $CLAUDE_SESSION_ID.
Run as one Bash call: bash "$AGENTS_CONFIG_DIR/skills/worktree-end/scripts/capture-env.sh" "<worktree>" "<owner>/<repo>" "<backup-dir>" "$SID" → output: $PLANS_DIR/$SID-final-report-env.json.
Run: node "$AGENTS_CONFIG_DIR/bin/supervisor-write-alert" --session-id "$SID" --set-alert-eligible-phase post_final_report_window.
Resolve main root from the worktree's .git file. cd "<main-worktree-root>" as its own Bash call (releases Windows CWD lock).
Call the native ExitWorktree tool after the WE-13 cd to release the extension host's session worktree binding; skip silently when that tool is unavailable.
Protocol: skills/_shared/worktree-transition.md
Read rules/ops.md before the first destructive step (it is on-demand-only and never auto-injected): it owns the recovery-options-first decision path every deletion here must pass through.
Read $AGENTS_CONFIG_DIR/skills/worktree-end/scripts/cleanup-cascade.md (spec) and issue each command separately. Run only after confirmed merge and inventory.
If WE-15 is blocked (CWD lock / busy), WORKTREE_OFF is NOT needed — /sweep-worktrees auto-reclaims; follow WE-16 and continue to WE-20.
Cleanup-active marker (WE-14b create → WE-22a delete) brackets the window so the
supervisor OFF-block adaptive message fires only during WE-15..WE-22 — see cleanup-cascade.md.
git worktree remove --force is prohibited; blocked at the settings.json deny layer, not by prose in rules/ops.md.ExitWorktree is called only at WE-13a — never before the WE-13 cd.git branch -D (WE-19 only) requires inline WORKTREE_END_SKILL=1 env prefix.<<WORKFLOW_USER_VERIFIED>> emitted in WE-8 (before merge), WE-7 (post-web-merge), or WE-4b (bootstrap). Never on abort or while polling. Protocol: skills/_shared/user-verified.md.AUTO_MERGE_PR=on skips AskUserQuestion in WE-5 (worktree mode only).hooks/cleanup-orphan-dir.js for orphan directory cleanup — never rm -rf.node "$AGENTS_CONFIG_DIR/bin/supervisor-report" --categories workflow --severity warning --detail "<describe fallback>" --reporter worktree-end.