Skip to content

Inside What a step s session is given

Ilia edited this page Nov 19, 2026 · 2 revisions

The orchestrator assembles a step's context, not the session. What can be gathered deterministically is gathered before the launch and embedded in the prompt ready-made: for step 1 the issue and the manuals' tables of contents (a few dozen headings instead of reading thousands of lines), for step 3 a check on whether .sclaude/local/feature/ got into the branch's commits, for step 4 the PR's checks and both streams of comments. The session pays tokens for judgement rather than for gathering.

Step 4 also gets what it could not have worked out itself: a green Claude review check does not mean the review happened. When the workflow file diverges from the default branch the action exits with zero in seconds having checked nothing — and the step once took such a tick for work done. The orchestrator computes this from the duration and the number of comments and says so outright.

All of it is a snapshot at the moment of launch, and the prompt says so while leaving the commands for re-reading: changing the PR's state is exactly what step 4 is busy with. If the gathering did not work, the block is empty and the prompt keeps its previous instruction inside itself.

The prompt goes to claude as one argument, which Linux holds to 128 KiB, and it is read at every turn; a long feature's gathered text outgrows both. So the instructions stay in the prompt and the bulk goes to files in the feature's tree. The blocks reach render_prompt.py as files, and a block over 32 KB (BLOCK_INLINE_MAX) is written to .sclaude/local/feature/prompt-<block>.md with only its place and size in the prompt. The pull request's snapshot lays itself out: every open thread whole in pr/threads.md, every resolved one by file in pr/resolved.md, the conversation in pr/discussion.md, and the threads the person left as they are in pr/left.md when they are many; the prompt shows each part inline while it stays under its budget, then an index (the discussion's latest entries), then a count per file — with the lines of a file's section in resolved.md, which the session reads before it changes that file. The threads a night left for the person to confirm come first, in whatever layout, since they are asked about before anything else. What the session must read before its first edit — the plan, every open thread whole, the resolved threads of each file it changes, the request comment — is a checklist at the head of step 1 in review.md, whose lines name the files only where the snapshot put something there (keys render_prompt.py derives in placed). The local review's prompt puts its settled findings in pr/settled.md the same way. Should the prompt still be over the limit, claude_launch (prompt_overflow) sends its tail to a file the head points at.

Context is not carried between steps. Every step is a new session, and .sclaude/local/feature/plan.md serves as the bridge, written at step 1 specifically to be handed over: compacting a long session costs more and preserves worse than a plan written for that purpose. Returning to an unfinished step goes through --resume, so an interrupted conversation inside a step is not lost — sessions are named with a UUID generated in advance (--session-id) rather than fished out after the fact.

The review meanwhile goes on at its own pace while the session is closed: a reviewer adds a comment, a check turns red from somebody else's merge into main. So the return to step 4 is the only one that does not stay silent: the orchestrator looks at what has appeared on the PR since the step last worked and passes it as a prompt to --resume. If there is nothing, the return goes silently, as with the other steps.

The count runs from the transcript's last entry rather than from the step's start. The difference is not cosmetic: step 4's session lives for hours and reads the PR all that time, so a comment that arrived mid-work has already been dealt with — from the start it would look new, and the session would be handed its own context to work through.

A step is closed by a result sclaude checks after the session ends, not by the session saying it is done (after_step in run.sh). Step 1 closes on an approved plan whose text could be read back from the transcript; step 2 on the person's "yes, it works" and a green local regression — the yes given in the session's own dialog (Accept work, read back by code_accepted), or at sclaude's question after a session left with /exit; step 3 on a pull request that exists and carries every commit; step 4 on an automatic review with nothing left open and a green local regression. While the result is missing the step stays current. A session that ended by itself is sent back into the same conversation, told what is missing, up to AUTO_RETURNS (two) times; after that, or after a session the person left, the next launch returns to the same step. One more exception: a merged PR closes steps 3 and 4 itself — the work is in main, the review took place, there is nothing left to check a preview on, and there is nothing to ask about. The next step starts at once, with no question. So every prompt tells the session what it ends with: say that it is done and stop — without offering the next step, because agreeing to it inside the session is impossible anyway, as it begins when the session is left.


Generated from docs/sclaude.md; edit it there, then rebuild with wiki/build.py.

Clone this wiki locally