close-session
БесплатноБез исполняемых скриптовНе проверенUse when the user asks to close, end, clean up, tear down, or finish a worktree/session after work is landed.
от divad12★ 26 звёзд на GitHubОб этом скилле
Close Session
Close the current worktree after confirming its work is merged. This skill is a narrow git cleanup only; it does not write summaries or clean runtime state.
Prerequisites
You must be inside a worktree, not the target repo/worktree. If you're already in the target repo, tell the user there's nothing to close.
Steps
1. Gather session info
Set TARGET_BRANCH to the branch being landed into, then run this to collect
the worktree and merge-safety details:
WORKTREE_PATH=$(git rev-parse --show-toplevel) && \
BRANCH=$(git rev-parse --abbrev-ref HEAD) && \
git worktree list && \
TARGET_BRANCH="<target branch>" && \
TARGET_REPO=$(git worktree list | awk -v target="[$TARGET_BRANCH]" 'index($0, target) {print $1; exit}') && \
test -n "$TARGET_REPO" && \
UNCOMMITTED=$(git status --porcelain) && \
echo "WORKTREE_PATH=$WORKTREE_PATH" && \
echo "BRANCH=$BRANCH" && \
echo "TARGET_BRANCH=$TARGET_BRANCH" && \
echo "TARGET_REPO=$TARGET_REPO" && \
echo "UNCOMMITTED=$UNCOMMITTED" && \
if [ "$WORKTREE_PATH" = "$TARGET_REPO" ]; then echo "ERROR: You are in the target repo, not a worktree."; exit 1; fi && \
if [ -n "$UNCOMMITTED" ]; then echo "WARNING: Uncommitted changes exist"; fi && \
git log "$TARGET_BRANCH"..$BRANCH --oneline 2>/dev/null && \
echo "---FILES---" && \
git diff --name-only "$TARGET_BRANCH"..$BRANCH 2>/dev/null
If the target branch is unclear, ask the user. If you're in the target repo, stop. If there are uncommitted changes, ask the user what to do.
2. Ensure work is merged into the target
git -C "$TARGET_REPO" merge-base --is-ancestor "$BRANCH" "$TARGET_BRANCH"
If this fails (exit code non-zero), run the /merge skill first. Wait for it to complete.
3. Tell the user, then tear down
Report what will happen: branch name and worktree path.
Then run the teardown as one bash command:
TARGET_REPO="<absolute path>" && \
WORKTREE_PATH="<absolute path>" && \
BRANCH="<branch name>" && \
cd "$TARGET_REPO" && \
git worktree remove "$WORKTREE_PATH" --force && \
git branch -d "$BRANCH" && \
echo "SESSION_CLOSED"
Substitute the actual values collected in step 1. Use -d (not -D) so git refuses if unmerged.
CRITICAL: This is the absolute last action. After running this command:
- DO NOT run any more bash commands. The original CWD no longer exists. Shell errors like
shell-init: error retrieving current directoryare expected and harmless. - DO NOT try to verify the branch was deleted or the worktree was removed.
- DO NOT try to "fix" CWD errors by cd-ing, using absolute paths, or spawning shells.
- Just tell the user "Session closed" and stop completely.
Rules
- Do not write session files. Closeout notes belong in the conversation or a user-requested artifact, not automatic teardown.
- Do not manage port files. Port assignment belongs to
new-session; close-session must not create, edit, or remove port metadata. - Only remove the git worktree and branch. Do not kill dev-server ports, delete screenshots, or clean incidental runtime artifacts.
- Never delete unmerged work. The merge check in step 2 is the safety gate.
- Never use
-D(force delete). Always-dso git validates the merge. - Minimize bash calls. Steps 1 and 3 should each be one bash command.
Установить close-session в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл close-session?
Use when the user asks to close, end, clean up, tear down, or finish a worktree/session after work is landed.
Как установить скилл close-session?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл close-session запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic