plugins-claude/session/skills/session-end/SKILL.md
Review, clean up, and open a PR to finalize the work
npx skillsauth add st0nefish/claude-toolkit session-endInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Finalize the work: review, clean up commits, push, open a PR, watch CI, and return to the default branch.
This is the review-gated, worktree-aware finalizer. It owns a
pre-PR code review gate, Resolves #N issue linking, and worktree
teardown after merge. For a quick lifecycle with none of that —
just stage → commit → push → PR → watch → merge → return — use
/git-tools:ship instead. (session-end does not delegate to
ship because ship ends with git checkout <default>, which
fails from inside a worktree.)
Gather current state:
bash ${CLAUDE_PLUGIN_ROOT}/scripts/catchup
Extract from the output:
CURRENT — the current branch nameDEFAULT — the default branch name
(e.g. master or main)ON_BASE — true if the current branch IS the
default branch with no diverging commitsIf ON_BASE is true and there are no uncommitted
changes, tell the user there is nothing to finalize
and stop.
1b. Check for an existing open PR for the current branch:
PR_JSON=$(bash \
${CLAUDE_PLUGIN_ROOT}/scripts/git-cli \
pr list --state open \
| jq --arg b "$CURRENT" \
'.[] | select(.head == $b)')
If found, extract the PR URL and number, skip steps 3-7, and jump directly to step 8 (CI watch) using the existing PR info.
Check for uncommitted work. If found, ask the user via AskUserQuestion:
git restore .end flowIf ON_BASE is true (working directly on the default
branch), push the commit and skip to step 8 (CI watch).
Steps 3-7 only apply to feature branches.
Agent review — use the Agent tool
(subagent_type: general-purpose) to spawn a review
agent with this prompt:
Review the changes on the current branch compared to the default branch. Focus on:
- Does the code actually address the linked issue (if any)?
- Code quality: clarity, edge cases, error handling
- Test coverage: are the changes tested?
- Any obvious bugs introduced?
Report findings concisely. Do not make changes — report only.
Use bash ${CLAUDE_PLUGIN_ROOT}/scripts/catchup
output and git diff <default>..<branch> as context
for the review agent.
Present the review findings to the user. Ask via AskUserQuestion:
end
flow; user will re-invoke when readyDetermine the linked issue number from the branch
name (type/NNN-*). Build the PR body:
## Summary
<2-3 sentence description of what was done>
## Changes
- <bulleted list of key changes>
## Testing
<how this was tested or why no tests were needed>
If a linked issue exists, append Resolves #N
to the summary.
Create the PR:
DEFAULT=$(bash \
${CLAUDE_PLUGIN_ROOT}/scripts/git-cli \
repo default-branch)
BRANCH=$(git rev-parse --abbrev-ref HEAD)
cat > /tmp/pr-body.md << 'EOF'
<PR body from step 5>
EOF
bash ${CLAUDE_PLUGIN_ROOT}/scripts/git-cli \
pr create \
--title "<concise PR title>" \
--head "$BRANCH" \
--base "$DEFAULT" \
--body-file /tmp/pr-body.md
rm -f /tmp/pr-body.md
Confirm to the user: PR URL, linked issue (if any), and note that CI is being watched next.
Watch CI — poll the CI run for the current branch:
bash ${CLAUDE_PLUGIN_ROOT}/scripts/git-cli \
run watch --branch "$BRANCH"
Parse the key:value stdout output (status, url,
duration, failed_jobs). Then:
pass — continue to step 8bfail — show the failed jobs and log excerpt
(printed to stderr by run watch). Ask via
AskUserQuestion:
end flow; user will
address failures and re-invokeno-workflow — note that no CI workflow was
found; continue to step 8btimeout — ask via AskUserQuestion:
run watch with
--initial-delay 0 and a longer --timeout8a. Check auto-merge — only when step 8 returned
pass and ON_BASE is false:
bash ${CLAUDE_PLUGIN_ROOT}/scripts/git-cli \
pr auto-merge-status --branch "$CURRENT"
Parse the auto_merge value from the output.
If true, note to the user that auto-merge is enabled
and the PR will merge automatically.
8b. Wait for merge — skip this step if ON_BASE is
true (direct-to-default pushes have no PR to wait on).
Otherwise, poll until the PR merges:
bash ${CLAUDE_PLUGIN_ROOT}/scripts/git-cli \
pr wait --branch "$CURRENT"
Parse the key:value stdout output (status,
pr_number, url, duration). Then:
merged — continue to step 9closed — ask via AskUserQuestion:
end flow for the
user to investigateblocked — ask via AskUserQuestion:
end flow for the
user to resolve conflicts and re-invoketimeout — if auto-merge was detected in
step 8a, automatically re-run pr wait with
--timeout 600 (up to 2 retries, no prompt).
If auto-merge was NOT detected, ask via
AskUserQuestion:
pr wait with a
longer --timeoutno-pr — note that no PR was found;
continue to step 9Return to the main checkout / default branch:
If this session is in a worktree (entered via
EnterWorktree this session): call ExitWorktree. Use
action: remove only when the PR merged (step 8b
returned merged) — this returns to the main checkout
and deletes the now-merged worktree and branch.
Otherwise use action: keep to preserve the work. If
remove reports uncommitted changes or unmerged
commits, fall back to keep (or confirm with the user
before re-invoking with discard_changes: true). Then
run git pull in the main checkout.
If ExitWorktree reports no active worktree session
(the worktree was created in an earlier session): cd
to the main worktree root (first entry of
git worktree list), then — only if merged — run
git worktree remove <path> and git branch -d <branch>.
Otherwise (in-place branch):
bash ${CLAUDE_PLUGIN_ROOT}/scripts/branch default \
&& git pull
Skip if already on the default branch in the main checkout.
Final summary — present to the user:
development
Start work from your description — explore the codebase and plan
data-ai
Multi-phase, multi-agent feature workflow: spec → plan → refine → divide → execute → review. Invoke when the user escalates a session-start/session-issue flow to orchestration, or asks to run a non-trivial feature (multiple files, design ambiguity, cross-cutting concerns, correctness-critical paths) through the full multi-agent workflow. For small fixes, prefer session-start.
tools
Browse open issues, pick one, and start work on it
tools
Interact with GitHub and Gitea issue trackers and CI systems. List and show issues, file bugs, comment on issues or PRs, list and show pull requests, and fetch CI run logs — all from any repo context without leaving the session.