Skip to content

Inside Staying current and the code s layout

Ilia edited this page Nov 23, 2026 · 5 revisions

Keeping the orchestrator current, and whose branch it is on. Every command that is about to act (everything but status, dev, news and help) first asks the machine's sclaude.update (update_mode in developer.sh, a git config key of the checkout that install.sh asks): off fetches nothing; notify fetches and lists what main has (instruments_notify, the commits in full once per new head of main, a line after that), and sclaude update (cmd_update) takes it; auto fetches main and brings it in (instruments_take): a fast-forward on main, a merge on a developer's branch. Unset, or set to an unknown word, the start asks the install question once at the terminal and saves the answer; with no terminal it acts as notify and asks again next time. A dirty tree or a conflict leaves the code as it was and says so, with the command that takes the update (instruments_offer, a note the run goes past); commits main already has under other names — a pull request squashed in — are dropped by moving to origin/main (git reset --keep, or switching a branch that is not sclaude's back to main) when merging the two gives main's own tree and the checkout has commits of its own (instruments_taken_in; a branch only behind is left alone), and only where the branch follows origin and origin is not a fork (instruments_follows_upstream, asked of gh; not known is no); no network is silent; afterwards the process re-executes itself so it does not run old code over new files. SCLAUDE_NO_SYNC=1 turns it off. The same holds at the end of a step's session, which may have run for hours: if bin/sclaude or a module changed on disk meanwhile, the process hands what follows claude's exit to the current sclaude (code_reload), so an /exit is handled by the new code. SCLAUDE_NO_RELOAD=1 turns that off. After the update the start says, in a line it goes past, when a branch of the checkout holds work found nowhere else (instruments_local_note, local_branches.py): not on any remote, not checked out in a worktree, and with few of the lines it adds among those origin/main added to the same files since the two parted — a squash leaves none of a branch's commits on main, so the lines, not the commits, tell a squashed branch from a lost one; a branch with no line to judge by (only deletions, binary files or short lines) counts as lost; one whose tree is its base's cannot be judged by lines (main taken in after its squash, or work reverted) and is named at the start too, while doctor asks to read it rather than offering to delete it. sclaude doctor lists every such branch, a squashed one with the command that deletes it. MAINTAINERS names who may commit the orchestrator straight to main. The update leaves everybody on main; a branch of one's own, dev/<name> (the name comes from developer.sh), is for proposing a change to sclaude, and a non-maintainer's commits there go out as a pull request (see "Who changes the orchestrator"). No session sclaude runs changes the live checkout: what a session changes in sclaude it makes in its tree's workshop, and sclaude publishes it (see "The workshop" below) — save the workshop the person opens by hand (sclaude workshop), whose session publishes from a worktree of its own on their word.

sclaude/lib keeps its modules, shell and Python side by side, in folders by what they do:

Folder What lives there
core/ what everything else stands on: the question channel, the terminal, state, steps, the project's config, the environments, who is running it
cycle/ launching a step and its session: the prompt, the watcher, the session's end, the plan, the acceptance criteria
commands/ the sclaude commands: new, resume, the menu, status, the moves between steps, done, the action list, doctor
review/ step 4: the rounds, the closing gate, the local review, the pull request's context, the reports
github/ issues and pull requests: the issue's sync, the board, the outcome, the issue's context and blockers
ship/ after step 4: the epilogue, deploys, QA, the merge, the regression and its gate, rollback, the demo's refresh
tree/ a feature's tree: the worktree, its branch, its database, its dev server's sign-in, the sync with main
improve/ sclaude improving itself: the friction review, deferred friction, the retrospective, the workshop, policy
metrics/ the DORA page and the cycle's metrics
flow/ the process map

Modules import one another by bare name: sclaude/lib/_path.py, imported by every entry point, puts every folder on sys.path. A name is one module's alone, and none takes a standard module's name; tests/paths.py checks both.

File What is in it
bin/sclaude the environment, the modules it sources, main and its dispatch
sclaude/lib/commands/start.sh sclaude new and its options, sclaude <feature>, sclaude issue
sclaude/lib/commands/menu.sh sclaude status and the menu sclaude opens with no arguments
sclaude/lib/commands/step_commands.sh moving a feature between steps by hand: replan, return, reset, the friction review, the regression, the epilogue
sclaude/lib/commands/done.sh sclaude done: closing a merged feature
sclaude/lib/commands/feature_commands.sh sync, news, preview, rollback, dev on a feature in work
sclaude/lib/core/ui.sh questions to the human, answers, colours
sclaude/lib/core/io.sh the question-answer channel: the same question in the terminal and in Telegram
sclaude/lib/core/steps.sh the table of steps and each one's permissions
sclaude/lib/core/project.sh what the project says about itself, and the wizard that writes it
sclaude/lib/core/environment.sh which database this machine's features work against
sclaude/lib/core/developer.sh who is running it, and whether they maintain the orchestrator (MAINTAINERS)
sclaude/lib/core/procinfo.sh, procinfo.py what sclaude and keepawake's scripts ask about other processes, the ports they hold and the machine — a process's directory, name, parent, environment, the bytes it put out (Linux only), which ports listen and by whom, the load, the keyboard's idle time — from /proc and ss on Linux, from ps, lsof and the HID system on macOS; every caller asks here rather than reading /proc itself
sclaude/lib/core/macos.sh what each bash entry point does first on macOS: Homebrew's bash 5 in place of the system's 3.2, and the GNU tools ahead of BSD's on PATH, for sclaude and everything it starts
sclaude/lib/core/launchd.sh sclaude's launchd agents on macOS (launchd/*.plist), which take the systemd units' place: sclaude.* on every Mac (the watcher, the proxy, and the phone's gate, which launchd starts on a connection to 127.0.0.1:3001 and hands its socket to by launch_activate_socket), keepawake* with the extras (the count, the hold, the bot, code-server); written and loaded by install.sh, brought up to date by units_refresh
sclaude/lib/commands/doctor.sh sclaude doctor: what this machine lacks, with the fix for each gap
sclaude/lib/core/page_asset.py reads a page's script or style kept as a file beside the module that draws it (process_*.js, dora_*.css…)
sclaude/lib/core/cycle_steps.py the cycle's steps once: their order, each one's launch (model, effort, mode, title), the icons the lines open with, the sessions numbered after them; cycle_steps.sh is written from it for the shell (python3 cycle_steps.py sh > cycle_steps.sh), and the bot and the process map read it directly
sclaude/lib/core/state.sh the repository, .sclaude/local/feature/state.json and the cycle's record
sclaude/lib/core/feature_files.py every file kept beside a feature's state in .sclaude/local/feature/, with what it is for; python3 feature_files.py [name] lists them or explains one. tests/feature-files.py fails on a name the code writes out in full that is not listed, and on a listed one nothing names
sclaude/lib/core/state_schema.py every field of the feature's state, the epilogue's record and the QA watch, with what it means; python3 state_schema.py lists them, python3 state_schema.py <path> explains one. tests/state-file.py fails on a path the shell reads or writes that is not listed, and on a listed one nothing names
sclaude/lib/core/state_file.py how every writer changes state.json: under a lock (state.json.lock), written whole through a rename, so two writers never lose each other's change and a reader never finds it half written
sclaude/lib/tree/branches.sh sorting out branches with nothing left to hold
sclaude/lib/tree/worktree.sh preparing a feature's tree and the dev server
sclaude/lib/tree/dev_loopback.cjs loaded into a feature's server: a listen on every interface goes to 127.0.0.1
sclaude/lib/cycle/run.sh launching a step and the transitions: the session, its end, the checks before the feature goes on
sclaude/lib/cycle/prompt.sh a step's prompt with its gathered blocks, and what the product and the person add to it
sclaude/lib/cycle/session_watch.sh the markers a session writes when it is done, and the watcher that closes claude on them
sclaude/lib/cycle/acceptance.sh the issue's acceptance criteria as a step leaves them
sclaude/lib/review/review_round.sh step 4's rounds: news since the session looked, the same conversation or a fresh one
sclaude/lib/review/review_gate.sh closing step 4: the gate on the pull request, the threads the person kept, the reports
sclaude/lib/improve/friction.sh the friction review between steps
sclaude/lib/improve/instruments.sh sclaude's own checkout: taking main, proposing a change, refreshing the units
sclaude/lib/github/github.sh issues and pull requests through gh: the pull request, the issue's link, close and blockers
sclaude/lib/github/issue_sync.sh the issue's summary, kept in step with the feature
sclaude/lib/github/board.sh an issue's place on the project board, its dates, the handoff to QA
sclaude/lib/github/outcome.sh a feature's outcome: its labels, its line in sclaude status, the epilogues offered
sclaude/lib/cycle/plan.sh step 1's plan from its session's transcript
sclaude/lib/ship/deploy.sh the cycle's epilogue, step by step, and what is said when shipping failed
sclaude/lib/ship/shipped.sh what has already been shipped: deploys per head, production's marks, what rides along
sclaude/lib/ship/vercel.sh running a deploy: vercel or the project's command, a preview with its migrations
sclaude/lib/ship/qa.sh QA on the preview: accepted, missed, a retest, the wait for its verdict
sclaude/lib/ship/merge.sh the merge: what stands in its way, how it is made, the offer and the wait
sclaude/lib/ship/demo.sh the demo recorded again once the preview is green, and a part's demo between two parts
sclaude/lib/ship/demo_progress.py what that refresh is doing, said as it goes: a bold line per change and a status line, from the session's events and the recording's demo_progress
sclaude/lib/ship/regression.sh the regression run: the suite's parts, the run, its timings and its line
sclaude/lib/ship/regression_gate.sh the gate that closes a step only on a green run
sclaude/lib/ship/regression_fix.sh the session that fixes a red regression
sclaude/lib/ship/rollback.sh putting production back: the deployment, the down blocks, the incident
sclaude/lib/core/picker.sh choosing with arrow keys: issues, menus, actions
sclaude/lib/commands/abandon.sh abandoning a feature: the traces here and on GitHub
sclaude/lib/commands/actions.sh the list of actions on a single feature
sclaude/lib/core/terminal.sh recording sclaude's terminal — what it printed, what the person typed — for reading back
sclaude/lib/improve/retro.sh the retrospective over a merged feature, right before sclaude done removes it
sclaude/lib/improve/workshop.sh, workshop.py the tree's workshop, where a session changes sclaude, and the publishing of what it made there
sclaude/lib/improve/workbench.sh sclaude workshop: sclaude's workshop opened by hand, a worktree and a session that does the rest
sclaude/lib/*/*.py gathering an issue's context, chain and acceptance criteria, reading migrations' -- down: blocks, the cycle's record, and assembling prompts
sclaude/hooks/*.py the steps' bans and the friction log
sclaude/prompts/*.md the steps' prompts and the shared includes (_*.md)
tests/*.py benches for the hooks, the prompts, the project's config, the acceptance criteria, the down blocks, the cycle's record, QA's hand-back, the choice of database, the functions whose failures are silent, choosing with arrow keys and the question channel
tests/run runs the benches side by side, longest first, each with a TMPDIR of its own; --changed for the ones a change touches

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

Clone this wiki locally