End session

From jellyrock/jellyrock · View interactive version

End session is an AI agent skill from the GitHub repository jellyrock/jellyrock. This skill should be used when the user explicitly types \"/end-session\": the mandatory final step of any session started or resumed with /start-project or /resume-project, which the agent prints alone in its own block as the session's last line for the user to type, never invoking it directly. It

How to use this skill

Skill file

End Session

This repo

Contract

Goal. Close out the current session on the active project and hand off cleanly, so the next session can resume cold. This is the mandatory final step of any project-tracked session, the soft enforcement point of the whole lifecycle. It updates the project's PLAN.md (Status as live state, dated decisions, open questions and waits, a kickoff rewritten in the template's skeleton, an appended Session-log line), sweeps the session for deferred tails and routes the cross-cutting ones to /log, sets the project's end-of-session status, checks the PLAN against itself with a script before committing, commits and pushes, proves the handoff loads cold, and releases the session's claim on the project. The work is judgment-heavy synthesis (distilling a whole session into an accurate status delta and a kickoff a memoryless reader can act on, plus careful commit hygiene in a possibly-shared working tree); the mechanical checks are scripts.

Inputs. Any arguments are ignored. The skill identifies the project from the session: whatever was loaded via /start-project or /resume-project, else the single active project (ask if several are). It expects the project's PLAN.md to be readable and the session's actual work to be verifiable against git log / git status.

Outputs.

Success criteria.

Failure modes to avoid.

When not to use.

Implementation

Every read of the PLAN goes through bash .claude/skills/resume-project/resume-state.sh (the reader /resume-project uses, so the close sees what the next resume will see); the projects folder is whatever bash .claude/skills/start-project/projects-dir.sh prints. Repo facts this skill reads: this repo's capture types and its public posture; anything else this repo needs at a close (a hook that regenerates a file, a check before a push that deploys, a harvest before archiving) is in this skill's ## This repo, when it has one.

Step 1: Identify the project

If this session loaded one via /start-project or /resume-project, use that slug. Otherwise run bash .claude/skills/resume-project/resume-state.sh --check with no slug: it picks the single active project, or lists the active ones (exit 2) so you can ask in chat which.

Step 2: Read what you will rewrite

Run bash .claude/skills/resume-project/resume-state.sh {{slug}}. It prints Status, the kickoff, the last Session-log line, what the project waits on, and the commits made since the PLAN was saved (this session's work, for the log line); read any other section by its heading. Never read the whole PLAN: it can pass 100KB, and a part read is enough to edit it. A sed, awk or head slice of the PLAN, or a git log range you picked, is no substitute: it skips what the reader adds (the save commit, what the project waits on, the size flag), and a Status rewritten from memory instead of from this output drifts from the PLAN.

Step 3: Update Status: live state only

Step 4: Rewrite the kickoff in the skeleton

Write the whole section in the template's shape (its <…> fill-ins stay the PLAN template's own, which the scripts read as unfilled text), for a reader with no memory of this session, then put it in place with the script below (the body only: the script keeps the heading):

**Starts at:** <Current phase's id>: <the step to start with>

**Last session stopped:** <where it stopped and why, in a sentence or two>

**Unanswered:** <questions put to the operator that got no reply, or "none">

### Verify first

- `<command>` prints `<the one line it printed at the close>` <what its numbers mean, when the line does not say>

### Next, in order

1. <step>

### Required reading

- <file or section, and why>

### Landmines

- <a trap that bites inside this project, and how to avoid it>
bash .claude/skills/end-session/replace-section.sh {{project-dir}}/PLAN.md "Next-session kickoff" {{body file, or - for a quoted heredoc}}

It replaces exactly one ## section and leaves the rest of the PLAN byte for byte; it refuses, writing nothing, a name that matches no section or several, an empty body, and a body with a # or ## heading outside a code block. If it refuses, fix what it names and run it again; never splice a section by hand.

Step 5: Append one line to the Session log

Add it at the bottom: the log is oldest first, and a resume shows its last entry. Dated; a second session the same day is (s2), and so on. A session that began with /start-project already wrote its line: extend that line rather than adding a second. Say what shipped (with its commit range), what was found, and what went wrong or had to be redone: a log that records only successes is useless for a cold read. Name any landmine you dropped and why it stopped being true.

Step 6: Route the deferred tails

Sweep the session for loose ends that surfaced but won't be done here. Project-scoped ones already live in the PLAN (Steps 3–4); do not also route them through /log, which double-books them. Cross-cutting ones (a fix elsewhere in the repo, a "we should look at X" outside the phases, an audit item for later) go through /log followup; a trap that bites outside this project goes through /log with the type that fits from this repo's capture types. Confirm each landed. If the journal or /log is missing, that is a defect to fix before this step can pass, never a reason to route nothing. Close the step with the line, printed whatever the count:

Cross-cutting tails routed: {{N}}

Carry this line into the session's final summary too. A close whose Steps 3–5 went in as one scripted edit tends to jump from the PLAN to the commit, and a summary that lists what was logged without the count has skipped this step.

Step 7: Set the end-of-session status

Default to active: no change, and no question, while phases are still in progress or pending. Ask in chat only on a real signal that the project is ending or pausing (the final phase has shipped, every phase is ✅, or the user said "we're done" / "let's pause this" / "this isn't working"), with the options and a recommendation:

For a terminal close, the kickoff becomes one line, Project closed {{date}}: {{why}}, put in place with replace-section.sh as in Step 4; its landmines drop with it, and the Step 5 log line says so, since Step 8's check skips its landmine review on a closed PLAN. After an archive move, search the whole repo (not only the docs) for the old path and re-point every hit in the same commit: a moved PLAN breaks links, registries and tests that name it. Decide this before Step 8 so every change lands in one commit.

Step 8: Check the PLAN

Run bash .claude/skills/resume-project/resume-state.sh --check {{slug}}. Every FAIL: line is a contradiction or a missing part: fix it in the PLAN and run the check again until it prints RESULT: ok. A Verify first: FAIL is a value that differs from what its command prints now: copy the printed line, never edit the command to match the value. The check runs each command (60 seconds each at most), so a Verify first command only reads. A REVIEW: line is answered as it says (a dropped landmine may instead be put back). A NOTE: line informs.

Step 9: Commit and push

The PLAN is committed in the repo that holds the projects folder. If git -C {{projects folder}} check-ignore -q . succeeds, the folder is gitignored: there is no PLAN commit, never git add -f it, and the PLAN must be the last thing written this session (after every other commit), because the next resume dates an untracked PLAN by its file time and reads any later commit as work the kickoff has not seen. Otherwise:

  1. git -C {{repo}} branch --show-current is the intended branch, and git -C {{repo}} status --short shows nothing staged that isn't yours (a parallel session may share the tree). Commit by explicit pathspec, never -a.
  2. git add any new file first (DECISIONS.md, an archive's new path). Stage the PLAN, DECISIONS.md, the README when Step 7 changed it, and for an archive move both the old and the new directory; git diff --cached --name-status must show the move as R (or a D for every old path).
  3. git commit -m "{{subject naming the project and the session's outcome}}" -- {{paths}} (-m before --). When this repo's public posture is public, re-read the subject and body first: no other repository or host, no person, email or home path, no secret. If a hook refuses, fix what it names and commit again, never --no-verify.
  4. Push, then re-check the branch. If the commit landed on the wrong branch, cherry-pick it onto the right one and move the stray branch back.

When the projects folder sits in another repo than this one (a projects home: git -C {{projects folder}} rev-parse --show-toplevel is not this repo's top), steps 1 to 4 do not apply. Run (cd {{projects folder}} && bash {{repo}}/.claude/skills/start-project/projects-write.sh --subject "{{subject}}" -- {{paths}}) with the same paths: for an archive move, the old and the new directory. It commits only those paths and pushes, and other sessions' files in that shared clone stay as they were. Exit 0 means pushed. On exit 3 (the change overlaps the remote) or 4 (not pushed) the PLAN stays written there, uncommitted: say so in the report, never push it another way, and go on; the next resume shows it as a pending sync. In a session whose machine will not last (a cloud session), also print the whole PLAN in chat, so the record outlives the machine.

Step 10: Prove it loads cold, then release the claim

Run bash .claude/skills/resume-project/resume-state.sh {{slug}} once more: it is what the next session will see. Every BANNER: line is something to fix now (a dirty tree, an unpushed commit, a commit after the PLAN's save, a PLAN check), not to hand on. After a push to a projects home that failed in Step 9, its pending-sync banner is expected: run its command once more, and if it still cannot push, leave it and say so in the report. After a terminal close its is closed (archived) banner is the cold load, the one BANNER: to leave, and the read stops before its own checks, so check them by hand: git status --short lists nothing of yours, and git status -sb shows no ahead. Then bash .claude/skills/resume-project/resume-state.sh --release {{slug}}, so the next session is not warned about this one.

Step 11: On a terminal close, settle the mail this project dealt with

Skip this step unless Step 7 set completed or abandoned. A message or work request part that started a project, or that it dealt with on the way, stays open until someone closes it, and no other step does. It runs after the push because /done proves the work on the remote.

Run bash .claude/skills/start-project/mailbox.sh list and bash .claude/skills/start-project/mailbox.sh requests. Nothing printed means nothing to settle, as on a machine with no mailbox. Read each line against the Charter and what shipped:

When this repo's public posture is public, an item's id, title and sender go only in the session's report and in /done's closing line, never in the PLAN, the README, a commit or a pull request this step writes.

Close the step with the line, printed on every terminal close, and carry it into the session's final summary:

Open mail settled: {{N}} closed or handled, {{M}} left open

Notes

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.