| name | end_session |
| alias | end-session |
| type | skill |
| category | instruction |
| description | Canonical session close — commit, push, PR, release_task, reflection blocks, handover. Use /dump for emergency bail (no commit/PR/reflection). |
| triggers | ["save work","handover","session end","close session","wrap up","session complete","task complete","stop hook blocked"] |
| modifies_files | true |
| needs_task | true |
| mode | execution |
| domain | ["operations"] |
| permalink | skills/end-session |
/end-session: Canonical Session Close and Handover
Close a session cleanly by committing/pushing changes, filing PRs, resolving tasks, and providing reflections. For mid-flight bails without task completion, use /dump instead.
Contract
- Output a 5–10 line markdown block (see the Handover Block).
- Write structured session data via
release_task.
Execution Path
Determine if session was Read-only (no mutating tools used, no tasks modified/created) or Full-form (modifying).
Read-only Path
- Print:
Output: none — read-only Q&A.
- Exit.
Full-form Path (Standard Close)
1. Resolve Bound Task
Identify the active task:
- In-context task ID: Read the active task ID from the
$AOPS_TASK_ID environment variable (populated automatically in the session context — this is the authoritative source). If it is unset or empty, fall back to the git branch name, which encodes the task ID as the segment after the last / (e.g. polecat/aops-1f9ec7b0 → aops-1f9ec7b0). Do not read or synthesise a filesystem-state file.
- Explicit argument: task ID passed directly to command.
- Fallback: If no task ID can be resolved (via environment, branch name, or explicit argument),
release_task will auto-create an ad-hoc task.
2. Version Control
If files changed, commit, push, and open a PR against this repo's default working branch. For academicOps that branch is dev — gh pr create --fill --base dev (main is publish-only). For any other repo, target its own default branch (most use main) — do not copy academicOps's dev convention onto a repo that has no dev branch.
The PR body describes the change for its reviewer. Do not add merge-gate / do-not-merge / "awaiting Nic" banners — branch protection is the real gate, so a banner warns nobody who can act on it. Canonical rule: [[framework-conventions-summary#pr-body-conventions]].
3. Update Project Breadcrumb
Resolve the parent epic and project node from the bound task. Append to the project file's Active Epics section:
mcp_pkb_append(
id="<project-id-or-permalink>",
section="Active Epics",
content="- [[<epic-id>]] — <epic title> (task [[<bound-task-id>]], PR <url-or-'none'>)"
)