logo
Published on

CH6. session-flow: splitting sessions into slots and handing over through files

Authors
  • avatar
    Name
    seren-wib
    Twitter
Contents

0. Introduction

Part 6 of the skills series. What a skill is and why I keep them separate is in CH0. Skills overview.

When several sessions run at once in the Claude Code desktop app, anything a session knows only from its conversation is lost the moment that conversation is replaced. So I wrote session-flow: rules that split sessions into levels and keep all state in files.

In restaurant terms, this is how a restaurant chain runs. Headquarters only knows which branches are open, each branch manager splits the work, and staff take turns at stations such as the kitchen or the floor. The next person on shift starts from the handover log, not from the previous person's memory. Headquarters is the home Lead, a branch manager is a project Lead, a station is a role slot, a staff member is a conversation, and the handover log is WORK.md.

Sessions are split into home Lead, project Lead and work session, and what each one knows lives only in two files, WORK.md and INDEX.md. So any session can drop its conversation and start fresh, and it picks up the work just by reading those files. Where this structure sits in the whole environment is covered briefly in the session layout of my agent environment; this post covers how the rules changed over two weeks. Of the 34 commits to the session-flow folder (2026-11-14 to 11-28), 33 changed SKILL.md (~/dotfiles git log, as of 2026-11-28).

1. Three levels of sessions

Under the home Lead there is one Lead per project, and under each, role slots and work sessions. Reports go up through SendMessage

Under the home Lead there is one Lead per project, and under each, role slots and work sessions. Reports go up through SendMessage

  1. Home Lead (Lead): always exactly one, in the home folder (~). It opens and closes projects and keeps "In progress" in worklog/INDEX.md. Questions that span projects also go here.
  2. Project Lead (<name> Lead): one per open project, running in that project's root. The name is whatever I call the project (blog, coffee shop). It owns that key's WORK.md and its ## 자리 (slots) list.
  3. Role slots: only the roles I asked for (PM, FE, BE and so on). With a PM, the PM splits the work and the others take items from ## 할 일 (to do). A session that does one job and ends is a work session; when it writes code it runs in its own git worktree. This post was written by one such work session.

A session starts another with start_session, and the new session is nested under the one that started it. Only project Leads are pulled out with detach_session and placed in a per-project group in the sidebar. Role slots are never detached, so that closing a project Lead also cleans up everything nested under it.

The structure did not start with three levels. The first version on 2026-11-14 was one home Lead with sessions under it; the same day, three levels (home Lead, project Lead, roles) and several projects open at once came in (88d9bc6). On 11-17 the Lead levels were fixed at two, and work sessions always open in the project root (13243e5). A session opened in a subfolder gets a different project memory path and starts with empty memory. How the memory path follows the folder name is in the folder is the address.

2. Leads only assign

The "Leads assign, never do" rule was added on 2026-11-17 (bdd01fa).

  • A Lead never edits code or documents, never makes commits, branches or PRs, and never deletes or moves project files, however small the change.
  • What a Lead does: read (records, transcripts, subagents), decide who does what, open that session or message it with SendMessage, and check the result. It writes only three things: WORK.md, INDEX.md and ## 자리.
  • With no fitting slot, it opens a work session. Even when I ask a Lead directly, it hands the work off and says which session took it.

Before this rule, the archive table had a separate row for "a Lead makes a PR on its own"; this commit removed that row and merged it into the work-session PR row. No more detailed reason is recorded.

For the same reason, Leads hold no state. Open projects are in INDEX.md, and a project's slots and work are in its key's WORK.md. A Lead knows how far a slot got from these files, not from what it heard in conversation. So a Lead can swap its conversation just like any other session.

3. The slot stays, the conversation changes

  • A slot stays in ## 자리 as one line, - FE: <what it owns>. The line stays even when no session is running in it.
  • Replacing a conversation is a handover, not an end. The handover steps are in archive.md. Finished work gets one line in ## 한 일 (done) with the slot name (- YYYY-MM-DD <what changed> (FE, <PR url>)), and unfinished work goes into ## 할 일 as - [ ] items that a session which never saw this conversation can pick up: where it stopped, what was tried, what's next, what is unverified.
  • A finished conversation leaves a transcript link in ~/dotfiles/session-archive/<YYYY-MM>/<key>/, named <date> <title>.jsonl, through archive-link.js. Moving the transcript would break reopening it in the app, so only a link is made (archive-link.js is 1,823 B). On Windows without Developer Mode, symlinks are refused, so a hard link is used instead.

WORK.md holds only the latest conversation's record (d814f21, 11-14). When a new conversation first writes to it, the old ## 한 일 lines move to history/ and it starts empty. history/ holds one checklist per stage and is never read at start; a question that needs it opens one file or searches.

4. Turns that can open sessions

This section covers the turns where start_session is refused. It works only in a turn I typed in that session (Remote Control included), in the first turn of a session started from such a turn, or from an own_initiative card I click. In a turn started by another session's SendMessage, it is refused in every permission mode. SendMessage itself is never refused.

This constraint reshaped the rules several times.

  • 11-17: first, the session that heard me opened the slot itself in that turn (2b5a0e4); the same day this was rewritten so a slot is always opened by its project Lead and nested under it (6698925). Then the flow where the Lead posted a card was removed too, and a new slot in an open project is something I say directly in that Lead's window (9701b2c). Asked in any other window, the answer is one line: "say it in the <name> Lead window".
  • 11-20: the order of closing the home Lead changed (6bbb683). Before, the next home Lead was started after the project Leads reported they had closed, but those reports arrive as message-started turns, where start_session is refused. In practice the home Lead did not come back on Windows. Now the next home Lead is started first, in the turn I typed, and only then is the close relayed to each project Lead.

When a Lead needs a slot I haven't asked for, it doesn't open it; it tells me which slot and why. In a message-started turn it tells the home Lead, which asks me to type one line in that Lead's window.

5. Report up only what's needed

The reporting rules are in the skill's Reports section, settled on 11-17 (3500aa4).

From → toWhat
Role slot → project LeadEverything (nested, so it arrives by itself)
Project Lead → home LeadResults of work the home Lead relayed; merges, PR closes, deadline results; anything other projects need; project open, close, handover and archive requests; what it can't solve alone
Lead → LeadResults back to the Lead that asked
Session started by another → its starterBefore archiving: what it did, commit or PR, what's left

The last row came in on 11-18 (28fe93a). Work I gave directly in a Lead's window is not sent up. Being worth remembering is not a reason to report either: that goes in ## 한 일, which the home Lead reads to know the status.

When work is handed to another project, my words quoted exactly count as my own instruction, commit and push included (3d4f8fd, 11-17). Paraphrased or added words are not mine. On 11-28 the same standard went into the brief (work order) given to a sub-session (ba07d45). A brief opens with my words quoted as I said them, and adds only what the sender checked itself (paths, IDs, PR links, measured values) and the scope. No conclusions, guessed causes or chosen fixes. The trigger was a brief that came with its conclusions already written, from which a wrong course name went straight into a post; the receiving session never got the chance to check it.

6. Write records in the same turn

The skill's Every turn section reads like this. The app auto-archives sessions unused for 3 days (auto_archive_inactive_days), and no model runs in the session when that happens. No hook fires and nothing is written. So a plan of "I'll clean up when archiving" misses that moment.

  • When remaining work changes, edit ## 할 일. When something is done, write a dated ## 한 일 line in that turn and delete its ## 할 일 item.
  • When I only learn something is resolved (checked, not done by me), grep every key's (28 folders as of 2026-11-28) ~/dotfiles/worklog/*/WORK.md and close every matching item, other projects' keys included (7adb788, 11-27). In those keys only the item is removed, with no ## 한 일 line.
  • A changed fact goes to memory; work started or stopped goes to "In progress" in INDEX.md.
  • No git commands for these files. The Stop hook commits and pushes memory/ and worklog/.

For work with a deadline, like an assignment, the deadline and submission status live only in the upper Lead's key (e.g. univ) (01bc017, 11-27). The key that does the work (e.g. vm) holds only a pointer, "deadline and submission status: univ WORK.md", never the value. If the same value lives in two places, only one gets updated.

7. A merge doesn't close the session

This rule is in the skill's "After a PR merges" section and pr-merge.md. At first a role slot was archived when its PR merged (e9fe6e0, 11-17). But there were cases where the PR merged while the slot's work was not done, and on 11-19 the merge row was removed from the archive table (3cff282). The app setting auto_archive_on_pr_close is off too (ff487c6). It's an account-wide setting, so it is off on both the Mac and Windows.

Now, in the turn of the merge and before any other reply:

  1. Fetch and fast-forward local main. If a worktree was used, the repo's main checkout too. Delete only this PR's branch, locally and on the remote (its worktree first), and start the next work on a fresh branch from main. Report how many commits main moved.
  2. One line in WORK.md ## 한 일 with the PR URL.
  3. Tell the session this one reports to about the merge.
  4. Keep working.

The branch cleanup scope changed twice in one day. On 11-19, after seeing 24 local and 22 remote merged branches piled up in one project, the rule was changed to delete every merged branch after a merge (a82bb3a); the same day it went back to deleting only this PR's branch (4900b66). If every merge deletes its own branch, everything ends up clean anyway. A full sweep happens only in the branch update of pr-workflow, when I ask for it.

8. Closing and the sweep

This rule is the close cascade (9124350, 11-17). The session told to close closes together with everything nested under it, and only the home Lead ever reopens.

  • A project Lead waits until every session under it has handed over and archived, deletes the project's sidebar group, and archives itself (06848d8). No successor. Reopening brings back only the Lead; a slot starts from WORK.md again only when I ask for it.
  • When I tell the home Lead to close, it first starts the next home Lead (section 4), then relays the close to each open project Lead. Once "In progress" lists no projects, it archives itself.

Leftover sessions are cleaned up by the sweep. The trigger on 11-15 was a Mac sidebar piled up with sessions. The records disagree on the number: the memory log says more than 30, the worklog more than 100. Before that, only sessions I named were cleaned up. Now the sidebar keeps only Lead, the Leads of "In progress" projects, and their ## 자리 slots. At start, and whenever it sees anything else, the home Lead reads each leftover session's last turns, moves unrecorded work into that key's ## 할 일, links the transcript and archives it. Sessions still running are skipped, with a note saying why (2bdd5ec, 11-17).

9. Models and session cost

Model choice for slots and agents was set on 11-19 (731fb96). A Lead picks Opus for sessions that need judgment or design, and Sonnet for fixed procedures. The brief sets the agents' model and a cap on concurrent agents: mechanical agent work runs on Sonnet, judgment stays in the session. The basis is a measurement from another project running both models. The measurement conditions are not in this skill's records; only the result numbers are.

2026-11-19, another project, from the worklogSonnetOpus
finish errors035
tokens per item7,0986,859

Each session start reads all instructions and the tool list from scratch. So a question never opens a session; reading and searching go to a subagent. This input-token cost is the same reason instructions are moved out into skills in the first place.

10. From 135 lines to 71

This structure is progressive disclosure. SKILL.md opens first, and the files next to it open only for their situation. The 11-20 commit (1f7935d) cut SKILL.md down to rules and moved situational procedures into five side files. Duplicated rules were merged, and quotes, incident notes and examples were removed. As of 2026-11-28, measured from file sizes in the ~/dotfiles repo.

SKILL.md atSize
Its largest (just before the 11-20 split)135 lines, 29,962 B
Right after the split71 lines, 7,908 B (−74%)
Now73 lines, 8,893 B
Five side files combined11,116 B
FileOpened when
archive.mdArchiving, closing, replacing, handover
pr-merge.mdA PR was merged or closed
projects.mdOpening or closing a project, handing work to another project, a new repo
slots.mdSlot requests, Red Team, work-session defaults, models, sidebar groups
history.mdWriting history/ files

A Red Team slot writes no code and owns no files. It only raises objections against plans, decision records and PRs. When I split a project into slots and ## 자리 has no Red Team, the Lead asks in one line whether to add one. The objections and their answers go into the decision record.

11. Reflection

Any session can drop its conversation and start fresh, and it picks up the work by reading only WORK.md and INDEX.md.