overnightworks

session-restart

Close every open Claude session tab and start one fresh head session per repository that takes over from the old transcript and reports its state. Use when the operator switched accounts (/login), asks to restart, renew or replace all sessions or tabs, or to reopen the sessions a reboot, crash or power-off stopped.

overnightworks 0 Updated 13h ago

Resources

1
GitHub

Install

npx skillscat add overnightworks/marketplace/session-restart

Install via the SkillsCat registry.

SKILL.md

Session restart

Runs from a Claude Code head only: it reads Claude Code's session records and
opens gnome-terminal tabs.

The new sessions take over by reading the end of their predecessor's transcript.
The old sessions write no handover, which saves a whole round of tokens, and
nothing is lost, because the transcript and the items hold everything.

  1. Dry run from the coordinating session, keeping its own pid:

    python3 ${CLAUDE_SKILL_DIR}/scripts/restart_sessions.py --keep $PPID --order "<the operator's words, verbatim>"

    $PPID of a Bash tool call is the running Claude process. The script lists
    one line per repository with the sessions it replaces. Two sessions on one
    repository become one new head that reads both transcripts. A record whose
    pid is held by another process, or by one in another pid namespace, is named
    as stale and never signalled.

  2. Check the list. Every session marked MISSING has no transcript at the expected
    path, and every one marked DIRECTORY GONE has no checkout any more: it gets
    no new tab. Tell the operator before you go on.

    After a reboot, crash or power-off no session is live, and the dry run says
    so. Then dry-run again with --after-reboot. It lists, per repository, the
    newest transcript written before the boot, with its last write time, plus any
    session that ran beside it there. A repository where a session ran after the
    boot is left out, and so is one whose last write is more than a day older than
    the last write before the boot. Your own repository's old transcript stays with
    you: read its end.

  3. Run the same command with --apply. It goes one repository at a time. It
    closes the repository's tabs: it hangs up each tab's bash -c shell and
    terminates claude, then waits up to 10 seconds until no process with that pid
    and start time remains. A session started from an interactive shell keeps its
    tab at a prompt. Only then it opens the repository's gnome-terminal tab. Its
    first message quotes the order, which makes the session a
    head. It names the old transcripts and asks for a report of 0/10 per topic,
    what comes next, and what the head needs from the operator. Last, it opens
    the aco board in the browser (aco board --url), so the operator never
    needs its link.

  4. A failure in one repository is printed with its directory and old transcripts
    and the others go on. The summary names each repository left without a new
    head and how to reopen it; tell the operator. The exit status is 1 then.
    Tell the operator how many tabs started. Use ListAgents to check that each
    repository shows a new session.

A plugin update that lands after the tabs started reaches a session only through
/reload-plugins, a CLI command only the operator can type; a session cannot run
it. Ask him to type it in each tab where no lane workflow runs.

Workflow runs stop with their session; a new session cannot resume them by run
id. The new head commits uncommitted lane work as a checkpoint, then takes each
stopped lane on as the lane workflow's Awaiting-head results say: it lands a lane
approved at its pull request's head, otherwise it starts a new run that repeats
only what is not yet proven.

Categories