Session end

From the-agency-ai/the-agency · View interactive version

Session end is an AI agent skill from the GitHub repository the-agency-ai/the-agency. Clean session teardown — commit all work, write a resumption-framed handoff, stop monitors, report readiness. Leaves a clean working tree. No asking.

How to use this skill

Skill file

<!--

Flag #62/#63: allowed-tools removed. Inherits Bash(*) from

.claude/settings.json. Restricting to specific subcommand patterns at the

skill level silently blocks agents on permission prompts the agent cannot

see — see dispatch #171 for the devex incident that surfaced this trap.

-->

Session End

Why this exists

The next session starts from the handoff. A session that ends with a dirty tree, unsent dispatches, or a stale handoff leaves the next agent reverse-engineering what was in flight. This skill forces the three end-of-session preconditions and shells to agency/tools/session-pause --framing resumption for the mechanics — commit, archive, stop monitors, emit new handoff path.

PAUSE-for-end surface. Paired with /session-resume on the other side.

Required reading

Usage

/session-end
/session-end "end-of-day"
/session-end "switching-context"

[trigger-reason] (optional): short tag for telemetry + handoff frontmatter. Defaults to session-end.

Preconditions

  1. You're ending the session (or switching context). For mid-sprint refresh, use /compact-prepare.
  2. Uncommitted work is ready to commit as-is. The skill does not stash.

Idempotent: safe to run multiple times. Archives + re-writes each run.

Flow / Steps

Step 1: Run session-pause primitive

./agency/tools/session-pause --framing resumption --trigger "${REASON:-session-end}"

--framing resumption tells the tool: stop monitors (registry-driven SIGTERM), fire SessionEnd hooks naturally on process exit, archive prior handoff, emit new path. If framework code is dirty, the tool force-commits the handoff alone first (handoff_commit_sha set), then aborts on the framework-code gate. Handoff is always persisted.

Parse the emitted key=value output. Key fields: handoff_path, archived_previous_handoff, commit_sha, handoff_commit_sha, status.

On status=aborted, surface error_reason. If handoff_commit_sha is non-none the handoff is safe — run /quality-gate + /iteration-complete on the framework code and re-run /session-end.

Step 2: Author resumption-framed handoff

Write the handoff file at handoff_path. Frontmatter:

Body: phase/iteration status, what was done, what's next, decisions/context the next session needs, open blockers. Frame for resumption — a future session will read this after a break.

Step 3: Verify handoff + report

./agency/tools/handoff read

Report: branch, last commit, handoff_path, "Handoff: written ✓", then:

Safe to /compact and/or /exit.

Failure modes

What this does NOT do

Status

active (v2 refactored in session-lifecycle-refactor Phase 3 Iteration 3.3 — body collapsed from ~145 lines to ~60, now shells to session-pause). Paired with /session-resume, /compact-prepare.

Related

OFFENDERS WILL BE FED TO THE — CUTE — ATTACK KITTENS!

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.