gunk-dev/the-valley

reference.md

sourceccb7354855a5main's published tip history
84.0 KiB · Plain text
Contents

klaus reference #

The complete surface of klaus: commands and flags, configuration, environment, files, trailers, the data ref, events, and the constraints the code enforces. The guide tells the everyday story; the design explains the mechanisms.

In this reference, GitHub work is a GitHub pull request <!-- prose-allow: vocabulary --> that an agent opened or that klaus tracks, and <pr> names one by number, URL or owner/repo#N. A change is a valley change; its handle is the shortest unique prefix of its change ID.

Commands #

CommandPurpose
klaus, klaus session, klaus newResume or start an interactive coordinator session
klaus launchLaunch an autonomous agent run
klaus statusEvery run of the session, then running and recent jobs
klaus dashboardLive TUI of runs, changes and jobs; runs the pipeline
klaus logs <run-id>A run's output
klaus watchStream the session's events, or wait for the next ones
klaus notificationsEvents since the last check, summarised (alias notif)
klaus jobs [show <id>]Consults, reviews and prose passes
klaus consultAsk another model a read-only question
klaus review <pr>Second-opinion review of GitHub work by another model family
klaus approve, klaus mergeApprove GitHub work; merge it in order
klaus ready <run-id|handle>Mark a valley change ready once its review passes
klaus track, klaus untrackFollow work no agent of the session made
klaus failed-checksDispatch fixes for failed valley checks, once
klaus restack-conflictsDispatch runs for valley restack conflicts, once
klaus cleanupRemove runs' worktrees, panes and state
klaus push-log <run-id>Store a log held back for sensitivity on the data ref
klaus report timeWhere agent wall-clock time went
klaus targetSet or show the session's default repository
klaus project, klaus syncThe project registry; fetch every registered project
klaus scaffold <name>Create a GitHub repository and have an agent scaffold it
klaus initWrite default configuration
klaus webhook check|setupGitHub webhooks for registered projects
klaus self-updateInstall the tip of the configured branch into the nix profile

klaus --version prints klaus version <v>.

klaus, klaus session, klaus new #

klaus and klaus session resume the most recent coordinator session or create one; klaus new creates a fresh one. They must run inside tmux. In a repository the coordinator works in a worktree of origin/<default branch> under worktree_base, with klaus's hooks but no trailers; elsewhere in ~/.klaus/sessions/<id>/workspace, configured by ~/.klaus/config.json alone. Each creates the session's events.jsonl and syncs registered projects in the background (~/.klaus/sync.log).

FlagMeaning
--backend <kind>Coordinator backend: claude, codex or agy; saved on the session
--agent-backend <kind>The session's default worker backend
--continue(session) resume the most recent session
--resume <id>(session) resume the given session

A resumed coordinator keeps its saved backend. A Claude coordinator's project memory directory (~/.claude/projects/<encoded path>/memory) is a symlink to ~/.klaus/memory, shared by every session; older memory files migrate into it on resume.

klaus launch #

klaus launch "<prompt>" | --prompt-file <path> [flags]. The positional prompt and --prompt-file are mutually exclusive, and one is required.

FlagMeaning
--prompt-file <path>Read the brief from a file, verbatim
--repo <r>Registered project name, owner/repo or URL
--issue <n|knot>GitHub issue to reference; on a valley project, a knot to work
--pr <n>Work on existing GitHub work's branch; also resumes a budget-paused one
--change <ref>Continue a change in a repository without GitHub on its branch
--resume-from <run-id>Continue a previous run's conversation
--branch <name>Name the new branch; not with --pr or --change
--backend <kind>Worker backend
--model, --effortModel and reasoning effort for the backend
--budget <usd>Claude only: spending cap (default default_budget)
--replay, --no-replayForce or disable trajectory replay
--replay-threshold-kb <n>Largest trajectory replayed; 0 uses replay_threshold_kb
--reason <reason>Dispatch reason recorded on the run and its events
--force-takeoverLaunch past a run still on the branch or change; reset the local branch
--local, --host <name>Run locally, or on this sandbox host
--run-id <id>Use this run ID (YYYYMMDD-HHMM- and 8 hex digits); refused if taken
--expect-owner <principal>With --change <change-id>: require this record owner
--expect-branch <branch>... the active version, and the launch, on this branch
--expect-head <sha>... the active version, origin's branch and the worktree at this full SHA
--expect-draft... the change listed as a draft

Target repository, in order: --repo naming a registered project; --repo as owner/repo or a URL (cloned or fetched under <worktree_base>/.repos/<owner>/<repo>); the current repository; the session target (klaus target); else an error.

Prompt storage. However given, the brief is written to prompts/<run-id>.md in the session directory, kept as the record, and every worker reads it on stdin. A local Claude worker reads its system prompt from prompts/<run-id>.system.md; an agy worker reads system prompt and brief together from prompts/<run-id>.input.md. What still goes on the pane command line (the Codex system prompt, a sandbox Claude system prompt) is checked first: a pane command over 12000 bytes fails the launch before any worktree exists, naming the part that is too large.

Branch names. Without --pr or --change, the branch is <slug>-<tail>, the tail being the run ID's last 8 hex digits. The slug comes from the --issue title (GitHub issue or knot), else the brief's first # heading outside code fences, else its first non-empty line: a leading <repo-name>: is dropped, the text is lowercased, each run of characters outside [a-z0-9] becomes one -, and it is cut at a word boundary to at most 40 characters. With no slug, or a name git rejects, the branch is agent/<run-id>. --branch must pass git check-ref-format --branch and exist neither locally nor on origin.

Setup. Launch fetches the default branch, makes the worktree, snapshots the clone's shared git files (config, info/attributes, hooks), installs the hooks, runs nix develop --command true when the worktree has a flake.nix, and starts the worker in a window of the detached tmux session klaus-agents-<session-id> (or a split of the coordinator's window with agent_display: "pane"). The pane runs the worker piped through tee to the run's log and klaus _format-stream, then klaus _finalize <run-id>. A local worker needs bash and its own CLI on the PATH launch runs with; launch fails, naming the command and the PATH, when either is missing. Launch prints delivery:, change:, replay:, resume: and takes on: lines saying what it decided.

Change IDs of follow-ups #

A fresh launch mints a change ID; a follow-up keeps the one it continues. --pr takes the change ID of the run that opened the GitHub work, in any session on the machine, else the Change-Id of its head commit. --change takes the named change's, even with --resume-from. --resume-from alone takes its run's. A follow-up to a run recorded without a change ID gets a new one, and the change: line says so. Dispatch reasons follow: launch, pr-follow-up, budget-resume, change-follow-up, resume.

Resolving --change #

<ref> is resolved in order: a run ID names its run's change; a change ID, a prefix of one, or a recorded handle is matched against runs of the target repository in any session; failing that, in a repository that delivers to a valley, valley changes --json names it. A run belongs to the target repository when its repository name is the target's last component. A ref naming several changes is an error listing them. --change refuses a GitHub repository, and --pr or --branch beside it. The worktree tracks the change's branch on origin: the valley's active version's branch, else the branch the change's newest run pushed; launch fails when none is known or origin lacks it.

In a valley repository the worker prompt has the agent amend the change's head commit (or end with a commit whose message describes the whole change), never merge another branch in, rebase onto origin/main when asked or when it conflicts, and push with git push --force-with-lease=refs/heads/<branch>:<head> origin HEAD:refs/heads/<branch>, where <head> is the tip launch found. Elsewhere it commits on top and pushes fast-forward, without rebasing or force-pushing.

--resume-from on its run's branch #

Combined with --pr or --change, --resume-from supplies the conversation and they supply the branch. Alone, it continues the branch its run pushed without GitHub work, as --change does, only when all of these hold: the run is in the target repository (by name, and by GitHub owner where known); no run of the change has GitHub work; origin has the branch; no run of another change worked on it and origin's tip carries no other Change-Id; the change's branch (the valley's active version's, else its newest push's) is still that branch; the branch holds that run's push, or a later head of the change (a later run's push on it, or the active version's head); and on GitHub, no GitHub work of any state has the branch as its head. Otherwise the follow-up gets a new branch and the resume: line says why.

A run still working on the branch #

--pr, --change, and --resume-from continuing its run's branch refuse while a run in any session is running on that branch or change in the target repository, naming it. They also refuse, with or without --force-takeover, while any worktree has the branch checked out (naming it, its run, and whether it holds uncommitted changes or commits origin lacks), and while the local branch holds commits origin/<branch> lacks. --force-takeover passes the running-run check and resets the local branch to origin's tip, discarding such commits. In one clone these launches hold klaus-continue.lock from the check through the new run's registration; a second waits up to 5 minutes, then refuses. klaus ready takes the same lock.

Dispatcher launches #

--run-id lets a dispatcher record the run before launching; a launch with it that fails before the worker starts exits with status 3. With --change <full change ID>, the --expect-* flags make launch ask the valley, under the continuation lock, before creating the worktree and again after returning the change to draft, just before the worker starts; a valley or origin it cannot ask, a change not as expected, or a failed valley unready fails the launch. Launch stops a worker whose run it could not record.

Trajectory replay #

At finalize, klaus commits a Claude run's resumable conversation to the data ref at sessions/<run-id>.jsonl. --pr on budget-paused work, and --change on any change, fetch the ref from origin (best effort), restore the newest run's conversation into the new worktree and run claude --resume <uuid>. Only the most recent run is replayed; otherwise the agent starts fresh, and the replay: line names the run and the reason, when: that run used another backend; nothing was stored (sensitive content, or work older than replay); it ran on another machine and push_data_ref was off there; the trajectory exceeds the threshold (default 300 KB; --replay bypasses it); no Claude session ID is known; it ran on a sandbox host; or --no-replay is given. A Codex follow-up of a Codex run forks its thread (codex exec fork) on the same machine; agy always starts fresh. A replayed conversation mentions the old worktree path and holds tool results from the time it stopped. With --resume-from, that run's conversation is used instead; when it cannot be resumed the agent starts fresh rather than replaying another run's.

Backends #

CapabilityClaudeCodexagy
Coordinator resumesaved conversation IDnewest conversation in workspaceworkspace conversation ID
--resume-fromstaged transcriptlocal thread, same machinefresh, with a warning
--pr/--change conversationreplay from the data reffork, same machinefresh
Budget, budget pause, --replayyesrefusedrefused
Shared coordinator memory~/.klaus/memorythe CLI's ownthe CLI's own

Worker backend precedence: --backend, the session's saved worker default, KLAUS_AGENT_BACKEND, default_agent_backend, then claude. Model and effort: the flag, else backends.<kind>, else for Claude only default_agent_model/default_agent_effort; a backends.<kind> entry replaces the legacy defaults even with empty fields, and with nothing set the CLI's own default applies. Model names pass through unchanged. Claude efforts are low, medium, high, xhigh, max. Workers run with each CLI's permission bypass; agy runs with a 24-hour print timeout. klaus status shows the model the worker reported, else the one launched with, else (default model).

klaus status #

Prints the runs table; a line for each run that changed its clone's shared git files; the failed valley checks and the restack conflicts on changes klaus owns; a Session cost line that includes removed runs; then the session's running jobs and consults and reviews that finished in the last 3 hours. When prose passes finished in the same period, a summary line below the jobs table gives their total and any failures (use klaus jobs --kind prose to see individual passes).

ColumnValues
RUN IDthe run's ID
STATUSwhere the run stands (below)
MODEL, COSTbackend and model; the run's cost
ISSUE, REPO, HOSTthe --issue; the target repository; where the agent ran
CHANGE#N, else the change's handle, else the first 8 characters of its change ID
CIpassing, failing, pending, unknown; valley checks for a ready change
CONFLICTSnone, yes, unknown, restack
BEHINDcommits the base has that the head lacks
MERGEready, behind N, blocked, pending
PROMPTthe prompt, or the change's title, cut at 40 characters

STATUS is running, needs-attention, superseded, pr-created, merged, closed, no-access, awaiting-integration, integrated, branch-gone, a valley state, working, tracking or exited. running means the pane is running the run (a dead pane, or one idle at a shell after finalize, is not). working: another run of its change is running. superseded: a run needing attention whose pushed work a later run of its change took on, and that run is running or finished. no-access: GitHub will not show the work with the current credentials. tracking: added by klaus track and not yet settled.

klaus dashboard #

KeyAction
j/k, ↑/↓move the selection
PgUp/PgDnmove a page
g/G, Home/Endtop, bottom
hshow or hide done rows older than hide_finished_after_minutes
aapprove the selected GitHub work
dpre-fill WRT PR#<num>: in the coordinator's pane and focus it <!-- prose-allow: vocabulary -->
oopen the selected GitHub work in a browser (xdg-open, or open)
xafter y: remove what klaus cleanup --done would; hide finished jobs
tabselect a job, or back to the runs
enterread the selected job's record and answer (esc back)
rrefresh and redraw
q, ctrl+cquit

Rows. Runs on one GitHub work share its row (named by the owner and repository in its URL and its number); runs without GitHub work on one change (same change ID, same repository) share the change's row. A change's row shows the handle (else the change ID's first 8 characters), the valley's title (else the pushed head's subject), and where the active version stands, with its head; earlier versions fold into it. A newer push the valley holds no version of is noted in the footer (a newer push 1a2b3c4 isn't ready). While an agent runs on a row, the row names it, sorts with the agents and offers no approve command. Rows are grouped yours, agents, pipeline, done, newest first; the line above the list counts groups and shows the position and hidden count. Done rows older than hide_finished_after_minutes (default 60) are hidden; a row the dashboard watched finish stays the full period. A repository column appears when the session spans repositories or shows a change.

Sources. File-system watching of run state, GitHub polling every 30 seconds (one GraphQL query per repository for all its tracked work, plus a compare when a head or base moved), or webhooks. Work seen merged or closed is not asked about again (pr-transitions.json); reopened work stays closed to klaus. Work the account cannot read (404, a non-rate-limit 403, an unresolvable reference) shows NO ACCESS, skips CI, conflict and review queries, and is asked again every 30 minutes. When GitHub rate-limits, polling stops until the time GitHub gives (or 2 minutes), the header says GitHub rate-limited until HH:MM, and rows keep their status. Pushed branches and valley changes are checked every minute, with at most one valley changes per check. While it shows changes, the dashboard follows each valley host's telemetry with one valley telemetry --json follow per host (one of the principal's follow slots); a decision, stored evidence or a batch's end triggers an extra check. Where telemetry cannot be followed, it logs that once, keeps to the minute and retries every 10 minutes.

Footer commands. dashboard.approve_command is expanded for a selected READY row (approve:) or SUBMIT row (submit:): {repo} (the repository as the row names it), {branch}, {change} (full change ID), {handle}, {head}. Values other than [A-Za-z0-9._/-] are shell-quoted, so placeholders go unquoted. A row lacking a placeholder's value, a DRAFT row, or a row with an agent running shows none.

Jobs. The jobs section lists RUNNING jobs and consults and reviews that finished in the last 3 hours (SUCCEEDED, FAILED, TIMED OUT, INTERRUPTED, DIED). It refreshes every 30 seconds. The header summarises prose passes that finished in the same period. Select a run row to see its finished prose passes in the footer. Each summary gives the total and any failures and appears only when there are passes to count. Job row counts and tab selection cover only job rows.

Restart. Every 30 seconds the dashboard looks for the name it was started as, klaus or valley-flow, in the absolute directories on PATH. When the first match is a different file that runs --version, the footer says klaus updated to <version>; restarting, and after 10 seconds without a key press the dashboard shuts down as on q and execs that file with the same arguments and environment. A dashboard started as valley-flow notes the PATH directory it was found in. If that directory later holds klaus without valley-flow, as when a profile is rolled back to a build that lacks it, the dashboard restarts onto that klaus. A failed exec is shown and that file is not tried again.

Notes go to dashboard.log in the session directory, never to the screen. A narrow or short pane drops spacing, status, job and help lines before rows.

klaus logs #

klaus logs <run-id> shows the live pane while the run runs, else replays the saved log through the formatter. --replay re-formats the saved JSONL log; --raw prints it as is.

klaus watch #

FlagMeaning
--filter <type>Include this type (repeatable); replaces the default filter
--filter-out <type>Exclude this type (repeatable), after --filter
--run <id>Only this run's events (a number for pipeline events, a handle for a change's)
--since-startEmit the file's existing events first
--onceWait for at least one matching event, print all that arrived, then a next: line, exit 0
--after <offset>With --once: the byte offset to read from
--jsonRaw JSONL lines
--list-typesPrint live and reserved types and the default filter
--session-id <id>Override KLAUS_SESSION_ID

--after is a byte offset into events.jsonl at the start of a line. The next: line repeats the other flags given, for example next: klaus watch --once --after 18342; with --json it is {"after":18342,"next":"klaus watch --once --after 18342 --json"}. Without --after, --once starts at the end of the file (the start with --since-start). Interrupted before any event, it prints only its next: line. An offset past the end or inside a line is an error, as is an events file replaced or removed while a watch waits. A watch on a session without an events file waits for it while the session directory exists; an unknown session fails at once.

klaus notifications #

Shows events since the last run (marker notifications-marker in the session directory), grouped into summaries; --all shows every event, --json lists them. A superseded run's agent:needs-attention is left out of the summary.

klaus jobs #

klaus jobs lists running jobs and jobs that finished in the last 3 hours, including prose passes. Use --all to list all retained records. Filter with --kind, using consult, review, or prose. Repeat the flag or separate kinds with commas.

klaus jobs show <id> prints a record and its answer. Use --answer for just the answer. The ID can be a job ID, a unique suffix of a job ID, or a panel ID. A job record (jobs/<run_id>.json) holds kind (consult, review or prose), thread, turn, role, backend, model, effort, dir, repo, commit (or a review's pr), the prompt excerpt, started_at, finished_at, the klaus pid and its start time from /proc/<pid>/stat, panel, and status: running, succeeded, failed, timed out or interrupted, with a short error. A running record whose process is gone reads died. A one-shot consult's answer is <run_id>.answer beside the record, a failed one's raw output <run_id>.raw; a thread's answer is in its log. Records finished over 7 days ago are removed when a job starts.

klaus consult #

klaus consult [flags] ("<question>" | --prompt-file PATH).

FlagMeaning
--backend <kind>Model family (default: first installed in consult.order other than KLAUS_BACKEND)
--model, --effortDefault backends.<kind>
--role <r>partner, critic, reviewer or a verbatim system prompt (default consult.default_role)
--thread NAMEContinue a named conversation in the current or most recent session
--dir <path>Workspace, read as it stands (default: current directory or the thread's)
--repo NAMEA registered project, as a snapshot of origin's default branch
--file <path>Inline a file (repeatable, 200 KB total)
--prompt-fileRead the question from a file
--timeout <d>Deadline per backend call (default 10m)
--panelAsk every installed family other than the caller, concurrently
--listList threads with backend, successful turns and last use

--dir/--repo, --panel/--thread and --panel/--backend are exclusive. Paths resolve from the invoking directory; each attachment sits under a header with its path (for agy, between BEGIN and END lines). The question goes on stdin.

--repo fetches origin's default branch (the project's default_branch, else main) at the start of each turn and checks it out, detached, in a snapshot worktree of the clone. The prompt's first line is Workspace: <project> at origin/<branch> <commit>, and the commit is kept in the thread, the consult:started event and the job record. A one-shot snapshot (shared by a panel) lives in ~/.klaus/consult-snapshots/ and goes when the consult ends; a thread's lives at consults/NAME.workspace and moves to the current origin branch every turn. When the fetch fails, a thread reads its last snapshot with a warning; a first turn fails. klaus cleanup --all removes thread snapshots, and a missing one is made again.

Threads keep backend, model, effort, role and workspace; conflicting overrides are refused. consults/NAME.json holds metadata and consults/NAME.log the transcript: JSON lines, each turn written pending before the backend starts and updated to ok or error: <message>, recording backend, model, resume ID, the snapshot commit, and how the session ID was found (stderr, stdout-json, diagnostic-log, text, assigned, resume). A failed turn keeps its output in NAME.<turn>.raw. Outside a pane, threads use the most recent session; one-shot questions need none.

Panels print each answer whole as it finishes, under a backend/model heading; a timed-out member prints timed out; any failed member fails the command after the others print.

Isolation. Codex runs in its read-only sandbox with --ignore-user-config (no MCP servers from $CODEX_HOME/config.toml; authentication still uses CODEX_HOME) and apps, plugins, hooks and subagents disabled. Claude runs in safe mode with only Read, Grep and Glob. agy runs in plan mode with a temporary agent definition exposing only file reads and search, removed after the call. Consults never create run state.

klaus review #

klaus review <pr> has a model family other than the author's review GitHub work. The author's family is that of the klaus run that opened it, else Claude.

FlagMeaning
--repo <r>Repository of a bare number
--backend <kind>Reviewer family (default: the cross-review choice)
--model <m>Default backends.<reviewer>.review_model
--postSubmit one COMMENT review (default cross_review.post)
--allow-same-familyWith --backend, allow the author's own family

The reviewer sees only gh pr diff, the title and the description, with consult isolation, and returns findings and a verdict on whether the change matches its stated intent. A posted review has event COMMENT, never APPROVE or REQUEST_CHANGES: findings on diff lines become inline comments, the rest go in the body, which ends with <!-- klaus-cross-review backend=<kind> model=<model> sha=<head-sha> -->. Posting is refused when the same reviewer already reviewed the head commit, or when cross_review.max_rounds marker reviews from your gh account exist; both checks, and a check that the head has not moved, run again just before posting. locks/review-<owner>-<repo>-<n>.lock makes a concurrent --post in the session fail at once. In a session it emits review:started/review:completed and leaves a job record; SIGINT and SIGTERM end it as interrupted.

klaus approve, klaus merge #

klaus approve <n>... (--run <run-id>, --all for every merge-ready one) marks GitHub work approved in run state and emits pr:approval-changed.

klaus merge <n>... merges in order, stopping at the first that fails and reporting the rest. For each: check readiness; wait for CI (polling every 30 seconds, up to 10 minutes); if it conflicts, rebase it onto main in a temporary worktree, run the verification (merge_verify_command, else go build ./... when there is a go.mod, else nothing) and push with --force-with-lease; merge with gh pr merge; mark the run merged. Work merely behind is merged as is; if GitHub demands an up-to-date branch, klaus runs GitHub's branch update (a merge from main, which keeps the head and its approval), waits for CI and merges again. Merge never removes a worktree that has the branch checked out. Without a clone it resolves one (current repository, registered project, or a clone under <worktree_base>/.repos), and the target repository's .klaus/config.json applies.

FlagMeaning
--dry-runPrint the plan
--merge-method <m>squash (default), merge or rebase
--no-delete-branchOmit --delete-branch
--repo <owner/repo>Repository for every number
--forceBypass the approval check
--yes, -ySkip unapproved work with a warning instead of prompting

klaus ready #

klaus ready <run-id|handle> [--head <sha>] marks a change's current head ready (valley ready --change <change-id> --head <head> <branch>, in the run's clone): the active version's head when the valley lists the change, else the head its newest run in any session pushed. <run-id|handle> is a run ID, or a handle, change ID or prefix as this session's runs record them. With --head (full, or at least 7 hex digits) it marks exactly that head and refuses, naming the current head, when the change has moved on; the current head is then origin's tip of the change's branch when it differs from the active version, and an unreachable origin is a refusal. It refuses while an agent in any session runs on the change, and for a repository that does not deliver to a valley. It clears valley.draft on this session's run that pushed the head, emits agent:change-ready with "via": "klaus ready", and prints <repo> <handle> v<n> ready at <head> (run <id>).

klaus track, klaus untrack #

klaus track <ref>... and klaus untrack <ref>..., with --repo naming the repository of a bare number or the project of a bare handle or change ID. GitHub work is a number (in --repo, else the session target), a URL or owner/repo#N; it reads tracking until GitHub says merged or closed. A change is a handle, a change ID or <project>:<handle>; the project is the one before the colon, else --repo, else the session target, else the current directory's repository, and klaus runs valley changes --json in its checkout and records the change ID, repository, handle, and the active version's title, branch and head. A change already followed is not added again; a landed or withdrawn one is added with a warning. Untrack removes only what track added, and a ref naming tracked changes in several projects removes none.

klaus failed-checks, klaus restack-conflicts #

One pass of what the dashboard does every minute: dispatch fix runs for failed valley checks, and runs for restack conflicts, on changes klaus owns.

klaus cleanup #

klaus cleanup <run-id> | --done | --all [--force] kills a run's pane, removes its worktree and scratch directory, deletes its local branch and its state, keeping its cost and duration in the session's ledger (cleared.jsonl). --done removes the runs of work that is merged, closed, integrated, withdrawn or gone, and the older runs of open work, keeping each open item's latest run, runs needing attention and running runs, with a line for each. --all removes every run and the session's unused consult thread snapshots, and the detached agents session once no run holds a pane in it and no pane runs a command. Running runs are skipped unless --force.

klaus push-log, klaus report time #

klaus push-log <run-id> [--push] commits a log held back by the sensitivity scan to the data ref after you reviewed it; --push also pushes the ref once.

klaus report time [--since 7d] [--repo <r>] [--current] [--json] reads every session's event log (--current: this one) and reports, per repository and overall, for runs started in the window (0: all time): runs by dispatch reason, time by phase, checks by kind, idle time between a change's runs, time from the last run to the first approval, follow-ups per change, consult and review time, and cost. Runs sharing a change ID in a repository, or GitHub work, are one change. --repo takes a key, valley name or short name; --json gives durations in milliseconds. Runs without phase events count from agent:started to their last event; a run without a reason counts as unknown.

klaus target, klaus project, klaus sync #

klaus target [name | owner/repo] sets the session's default repository (target.json); without an argument it shows it, and --clear removes it.

klaus project add <owner/repo | name> [--path <dir>] [-d <description>] clones into the projects directory (or registers an existing checkout) and records it in ~/.klaus/projects.json; a bare name searches your GitHub repositories, and without -d the description comes from gh repo view. project list, project remove <name> (keeps the clone), project describe <name> <text> (empty clears) and project set-dir <path> complete it. Descriptions appear in the coordinator's ## Registered projects block. klaus sync fetches and fast-forwards every registered project.

klaus scaffold, klaus init #

klaus scaffold <project-name> [--description <d>] [--type web|cli] [--budget <usd>] [--backend <kind>] creates a GitHub repository, registers it, and launches an agent that scaffolds it from .klaus/principles.md in the current directory (else built-in principles), without templates. It must run inside tmux.

klaus init writes .klaus/config.json (the defaults) and .klaus/prompt.md in a repository, or ~/.klaus/config.json outside one.

klaus webhook #

klaus webhook check shows each registered project's webhook state; klaus webhook setup [project] creates missing ones. Both need webhook.relay_url; setup also needs webhook.secret_file. Hooks subscribe to push, check_run, check_suite, pull_request, pull_request_review and issue_comment.

klaus self-update #

Off until the host config has self_update (repo, and branch, default main); a repository's .klaus/config.json cannot set it. repo is an https://, ssh://, git:// or file:/// URL, an absolute path, or user@host:path (read as ssh://user@host/path; write user@host:~/path for a home-relative path). Other transports (ext::, fd::) and characters outside [A-Za-z0-9._~/:@-] are refused; git and nix read the same URL, with GIT_ALLOW_PROTOCOL=https:ssh:git:file. A git:// repository needs a nix that accepts git+git:// flake references; nix 2.31 refuses them. A run:

  1. takes a lock under $XDG_STATE_HOME/klaus/ (a run finding another exits 0, saying so); a pinned install exits 0 with a note;
  2. resolves the branch with git ls-remote <repo> refs/heads/<branch>;
  3. exits 0 when the installed klaus was built from that commit (-v says so);
  4. reads the packages the flake offers at that commit and, unless it offers packages.<system>.klaus, refuses with nothing built or changed. The refusal asks for self_update.repo to name a repository whose flake offers it, such as the-valley's; the next run then builds, smoke-tests and installs from there, whatever the state file remembers of the repository before;
  5. exits 0 when that commit already failed (retried when the branch moves, or with --retry);
  6. builds exactly git+<repo>?ref=refs/heads/<branch>&rev=<sha>#packages.<system>.klaus, never a default package;
  7. smoke-tests it: klaus --version must report the commit and klaus status must exit 0; a failure records the commit as failed, installs nothing and exits non-zero;
  8. replaces the nix profile element klaus, leaving other elements and the system klaus alone;
  9. records current and previous store paths and commits, the time and any failure in $XDG_STATE_HOME/klaus/self-update.json.

--rollback reinstalls the previous store path (again to return); --pin holds the current install until --unpin; --retry, --rollback, --pin and --unpin are exclusive.

Internal commands #

CommandUse
klaus _finalize <run-id>Finalize a run; the pane runs it after the worker
klaus _format-stream [--sandbox]Format a worker's JSONL stream; time its checks
klaus _pre-review [--dir <worktree>]Forbidden terms, linters, peer review and prose rewrites
klaus _forbidden-terms [--repo <r>] [<base>] [<head>]Check a range for forbidden terms; exit 1 on a match
klaus _event --run-id <id> --type <t> --data <json>Append an event to the session's log

_pre-review runs forbidden terms first, even with pre_review.enabled false, then the linters (pre_review.linters, else detected), then the peer review with the cross-review choice (printing the reviewer), then the prose pass. It exits 1, saying the delivery should be blocked, on a forbidden term, a lint failure, or findings at or above pre_review.block_on.

Forbidden terms, peer review and the prose pass each read the change since its merge base with origin/<default_branch> (the local branch only when the clone has no origin copy), as committed: no textconv or external diff runs on it. A file that is not text (not valid UTF-8, or holding a NUL byte) reaches the reviewer and the prose writer by name, without its content, and with its size unless git itself takes it for binary.

Configuration #

Configuration layers: built-in defaults, then the host config ~/.klaus/config.json, then the repository's .klaus/config.json. Two keys are read from the host config only: forbidden_terms (a repository's value is ignored) and self_update. Finalize reads ready_at_finalize and push_data_ref from the checkout the run's worktree belongs to, never from the agent's worktree.

Configuration keys #

KeyDefaultMeaning
worktree_base$TMPDIR/klaus-sessionsWhere worktrees and .repos/ clones go
default_branchmainThe repository's default branch
default_budget5.00Claude spending cap in USD
data_refrefs/klaus/dataThe data ref
push_data_reffalsePush the data ref to origin after every run
replay_threshold_kb300Largest trajectory replayed
default_coordinator_backendclaudeCoordinator backend
default_agent_backendclaudeWorker backend
backends.<kind>.model, .effortunsetPer-backend model and effort for workers and consults
backends.<kind>.review_backendunsetReviewer family for work this family wrote
backends.<kind>.review_modelunsetModel when this family reviews
default_agent_model, default_agent_effortunsetLegacy Claude worker defaults
agent_displaydetacheddetached session windows, or pane splits
sandbox_hostunsetSSH host for agent runs
formatnix fmt if the flake has a formatterFormatter command line for the pre-commit hook
house_rules.repo, .pathunsetHouse rules file
forbidden_termsunsetHost only: forbidden terms
trusted_reviewers["gemini-code-assist[bot]"]Logins whose comments dispatch fix agents
pr_reviewerpicked at launchLogin an agent requests review from
require_approvaltrueklaus merge requires approval
auto_merge_on_approvalfalseThe pipeline merges approved, green, conflict-free work
merge_verify_commandgo build ./... with go.modVerification before a merge's force-push
ready_at_finalizetrueMark a valley change ready at finalize, or leave a draft
pre_review.enabledtrueRun linters and peer review
pre_review.lintersdetectedLinter commands
pre_review.review_modelhaikuClaude reviewer model
pre_review.max_fix_rounds2Review fix rounds
pre_review.block_onhighLowest finding severity that blocks
pre_review.prose.enabledtrueRun the prose pass
pre_review.prose.orderagy, codex, claudeWriter preference
pre_review.prose.pathsnoneFiles beyond Markdown and READMEs whose added lines are prose
pre_review.prose.timeout_seconds600Per model call
pre_review.prose.max_input_bytes40000Diff sent to the models
pre_review.prose.writer.<kind>, .checker.<kind>backend defaultsmodel and effort for the writer and checker
cross_review.enabledtruefalse keeps the author's family
cross_review.ordercodex, claude, agyReviewer preference
cross_review.postfalseDefault for klaus review --post
cross_review.max_rounds2Posted cross-reviews per GitHub work
consult.ordercodex, claude, agyConsult family preference
consult.default_rolepartnerConsult role
dashboard.hide_finished_after_minutes60Hide older done rows; negative never hides
dashboard.approve_commandemptyFooter approve template (submit_command: deprecated name)
webhook.*absentWebhook receiver
self_update.repo, .branchabsent, mainHost only: self-update source

Cross-review choice. The reviewer family is backends.<author>.review_backend, else the first cross_review.order entry that is not the author and whose CLI is on PATH, else the author's own; enabled: false skips the order. The model is backends.<reviewer>.review_model, else pre_review.review_model for Claude, else the CLI default.

Prose pass. Prose is the added lines of Markdown files and READMEs and of files paths matches (a pattern without / matches a file name anywhere; dir/** a tree), plus the head commit message; a change with no prose beyond a short commit message is skipped. The writer is the first installed family in order other than the author's, the checker the next (else the author's); each runs at writer.<kind>/checker.<kind>, else backend defaults, except that an agy writer's model defaults to gemini-4-hydrogen-high. The writer lists each passage's claims in a ledger before rewriting, following the writing sections of the repository's AGENTS.md and CLAUDE.md and the house rules; the checker reports each rewrite that changes the meaning.

pr_reviewer. Used as given. Unset, launch lists the repository's collaborators with push access, drops bots and the gh user, and picks the owner if present, else the only one left; with several left or a failed gh call it warns and requests no review. Runs that open nothing new skip it.

trusted_reviewers. Inline review comments and conversation comments both count; a comment stops counting once a newer commit is pushed, and an edit counts as new. A conversation comment by the work's author counts only if its first non-blank line is /klaus fix or it holds <!-- klaus-actionable --> on a line of its own; quoted lines do not count. Agent replies carry <!-- klaus-agent-reply --> and are ignored. A review carrying the cross-review marker counts as trusted when its author is the authenticated gh user.

Prompts and house rules #

.klaus/prompt.md is the worker system prompt template, .klaus/session-prompt.md the coordinator's and .klaus/pr-fix-prompt.md the fix agents'. They are Go templates:

VariableValue
{{.RunID}}the run ID
{{.Issue}}the GitHub issue, if any
{{.Branch}}the agent's branch
{{.RepoName}}the repository's name
{{.Reviewer}}the login to request review from; empty when none, and for direct push
{{.DirectPush}}true when origin is not on github.com
{{.PR}}(fix prompt) the number of the work being fixed <!-- prose-allow: vocabulary -->

klaus appends its worker rules to every worker prompt: the run ends with the agent's turn, so long builds run in the foreground; the test guidance; scratch output stays out of the worktree; a broken environment is reported, not worked around; work whose cost is out of proportion stops and reports what it taught; and the final report has the headings Intent, Decisions, Shape, What the implementation taught us, Checks, Diff summary.

house_rules ({"repo": "<registered project>", "path": "guidance/house-rules.md"}) is read at launch with git show from the project's freshly fetched origin default branch, never a working tree, and appended after the worker rules, and to the context of klaus consult --repo, the _pre-review reviewer, and the prose writer and checker. The run records its source, commit and sha256, and launch prints them. An unreadable file is warned about once, recorded as missing, and skipped. A repository's config may name other rules.

Forbidden terms #

"forbidden_terms": {
  "site": {"terms": ["internal-host", "corp.example.org", "10.0.2."], "allow_paths": ["docs/hosts.md"]}
}

A key is a registered project name (its checkout, worktrees, and clones with the same GitHub origin) or owner/repo (any checkout with that GitHub origin); both apply when both match. The check fails when a term appears, case-insensitively as a literal substring, in a line the change adds since its merge base with origin/<default_branch> (binary files too), in an added or renamed file's name, or in a new commit's message. Deleted lines do not count; a moved file's lines count at the new path. Files equal to or under an allow_paths entry are skipped. The report lists file:line: term or commit <sha>: term, naming only the terms found.

Environment variables #

VariableSet byMeaning
KLAUS_SESSION_IDsession, agent panesThe session; without it, commands use the most recent session
KLAUS_BACKENDsession, launchThe running agent's backend: consults pick another family; _pre-review takes it as the author's
KLAUS_AGENT_BACKENDsessionThe session's worker backend default
KLAUS_RUN_IDlaunchThe run, in the agent's pane (and on a sandbox host)
KLAUS_RUN_EVENTSlaunch, sandbox runsoutput: _pre-review prints its check as a stream line
KLAUS_SCRATCHlaunch, local workersThe run's scratch directory
KLAUS_TMUX_SOCKETlaunch, local workersThe real tmux server's socket, for klaus's own commands
TMUX_TMPDIRlaunch, local workersThe run's own empty tmux directory; TMUX, TMUX_PANE unset
XDG_STATE_HOMEuserSelf-update's lock and state go in $XDG_STATE_HOME/klaus (default ~/.local/state/klaus)
CODEX_HOMEuserCodex authentication, also for consults

Files and state #

PathHolds
~/.klaus/config.jsonHost config
~/.klaus/projects.jsonThe project registry
~/.klaus/memory/Shared Claude coordinator memory
~/.klaus/sync.logBackground project syncs
~/.klaus/consult-snapshots/One-shot consult snapshots
~/.klaus/sessions/<id>/A session (below); machine-local
<worktree_base>/Run and coordinator worktrees; .repos/ clones
<clone's git common dir>/klaus-continue.lockThe continuation lock
$XDG_STATE_HOME/klaus/self-update.json, .lockSelf-update state and lock

In a session directory:

PathHolds
runs/<run-id>.jsonRun state (the coordinator's too)
logs/<run-id>.jsonlThe worker's raw stream
prompts/<run-id>.md, .system.md, .input.mdThe brief and the prompts workers read
tmux/<run-id>/, scratch/<run-id>/The run's TMUX_TMPDIR and KLAUS_SCRATCH (mode 0700)
events.jsonlThe event log
jobs/, consults/Job records; consult threads
locks/Per-review posting locks
pr-transitions.json, change-transitions.json (+ .lock)Transitions already reported
checks-dispatches.json, restack-dispatches.jsonWhat the dispatchers did
cleared.jsonlCost and duration of removed runs
target.json, notifications-markerSession target; last notifications check
dashboard.logDashboard notes
workspace/The coordinator's workspace outside a repository

Run state records, among others: id, prompt, issue, pr, pr_url, branch, worktree, tmux_pane, budget, log_file, created_at, cost_usd, duration_ms, backend, model, resolved_model, effort, target_repo, clone_dir, host, approved, merged_at, failure_reason, needs_attention, pushed_branch, pushed_sha, pushed_subject, change_id, delivery (pr or push), valley, unready, change_repo, knot, dispatch_reason, repo_key, head_sha, took_over, house_rules and shared_git.

The data ref #

At finalize klaus commits, with a temporary index and without touching any working tree, to data_ref (default refs/klaus/data) in the local clone: runs/<run-id>.json, logs/<run-id>.jsonl and the Claude conversation sessions/<run-id>.jsonl. Before a log is stored, a scan looks for private IP addresses, SSH keys, credential patterns and .age secret references (the repository's own remote hosts are exempt); a log that matches, or cannot be scanned in full, is held back, only the state is stored, and klaus push-log stores it after review. A trajectory with sensitive content is not stored. The ref is pushed to origin only when push_data_ref is true; a push sends its whole history, and anyone who can read the repository can read it.

Commit hooks and trailers #

Every commit an agent makes ends with:

Change-Id: <change id>
Klaus-Run: <run id>

Change-Id is in jj's change-id form (32 characters from k to z); Klaus-Run leads to the run and its prompt, log, cost and trajectory. They label commits for finding and auditing; they grant nothing, and no tool may trust a commit or skip a check because of them.

Launch installs, for the agent's worktree only (core.hooksPath set with git config --worktree, enabling extensions.worktreeConfig once on the clone):

  • commit-msg: strips Claude/Anthropic attribution, adds Change-Id unless present and Klaus-Run unless that run is listed (an amend by a later run keeps the change ID and lists both runs), then runs the repository's own commit-msg hook. A message empty or made only of # lines is left alone.
  • pre-commit: runs format from the worktree root, re-stages the files that were staged, then runs the repository's own pre-commit hook; unstaged changes stay unstaged, and a failing formatter stops the commit.

A shared core.hooksPath pointing inside .git/worktrees/ is removed; any other shared value is the repository's, and its hooks run. The coordinator's worktree gets the hooks without trailers. Finalize's own salvage and budget-pause commits skip hooks and add the trailers themselves.

Delivery and finalize #

delivery is decided at launch from the clone's origin: a github.com URL (git@github.com:o/r.git, https://github.com/o/r, ssh://git@github.com/o/r.git) is pr, anything else push; a --pr fix is always pr. A push run never records GitHub work, whatever URLs its log holds.

Finalize parses the log for cost, duration, session ID and, for pr runs, the URL; checks the clone's shared git files against the launch snapshot (a difference beyond git push -u tracking emits agent:shared-git-changed and marks the run needing attention); on Linux records processes still running in the worktree as failure_reason (background work still running (<commands>)); stores the run on the data ref; and removes the worktree and scratch directory. It deletes the local branch only when its work is on the default branch or origin's live tip (git ls-remote) matches.

Pushed branches. A clean run whose branch is on origin records pushed_branch and pushed_sha and emits agent:completed and agent:branch-pushed (repo, branch, sha); the local branch is deleted. Of the branches the worktree ends on and launch made (not the default branch), a head on origin counts as pushed when the local branch holds it. The run's change is the pushed head whose Change-Id matches the final head's, else the head of the branch the worktree ends on; when that differs from launch's, agent:change-recorded (change_id, branch, head, launch_change_id, launch_branch, and pushed when several changes were pushed) precedes agent:completed, and runs recorded as taken over are dropped.

Integration checks (each look, never written to the run): one git ls-remote per repository, a fetch of the default branch and pushed branches, then per run: integrated when the pushed SHA or the branch's tip is an ancestor of the default branch; integrated by content (INTEGRATED~) when a first-parent commit made after the run started has the same git patch-id --stable as the branch's diff from the merge base (searching at most 500 commits); branch-gone when the branch was deleted and neither matched; else awaiting-integration. A missing clone, an unreachable origin, a pruned SHA, a too-shallow history or the 500-commit cap leave it awaiting.

Salvage. A run that ends without delivering, or crashes, gets a commit of everything uncommitted that .gitignore does not exclude (wip: klaus finalize salvage <id>), a plain git push -u unless origin's live tip already matches (not for runs with GitHub work), keeps its local branch, and emits agent:needs-attention with branch, pushed and reason (no_pr, session_limit, background work, or the crash). The worktree stays if the commit failed. The attention passes to a later run of the change once it records took_over (at launch, when it continues a branch holding the salvaged head; at finalize, when its head contains it) and is running or finished. A run with no commits beyond the default branch and no background work finishes as agent:completed.

Budget pause. A Claude run stopped at its budget gets WIP from klaus run <id> (budget paused), a --force-with-lease push, a draft opened or updated with the label klaus:budget-paused and a one-line comment, and cleanup. The label is the persisted state; a follow-up's finalize removes it and emits agent:resumed. Claude's structured result is authoritative when the CLI exits non-zero at its budget or turn limit.

Valley delivery #

A repository delivers to a valley when its origin is not GitHub, the pushed head (at launch: the commit the worktree starts from) has policy/valley or a policy/instance/ directory, and valley help lists ready and changes. valley ready, valley unready and every knot call are bounded by 30 seconds; valley changes gets three minutes.

  • Finalize runs valley ready --change <change_id> --head <pushed_sha> <branch>, expecting <repo> <handle> v<n> ready, records valley (repo, handle, version, title) and emits agent:change-ready (repo, change_id, handle, version, title, head). Any other outcome is recorded as valley.error and warned about; the run shows SUBMIT with the reason.
  • With ready_at_finalize false, it then runs valley unready <change_id>, records valley.draft and emits agent:change-draft instead. A valley without unready gets no ready at all; a failed unready leaves the change ready and emits agent:change-ready.
  • Follow-up launches return an inherited change to draft first (valley unready <change_id>, expecting <repo> <handle> v<N> draft or <repo> <handle> draft) and record unready; a change that was not ready is left alone, and a failure is recorded as unready.error and the launch goes on (unless --expect-draft).

Repository names #

A run's valley repository is the one valley ready reported; else, for a follow-up, the repository of the run it continues (change_repo); else the one valley unready reported; else the last component of the target repository without .git. Runs share a change when they share a change ID and repository name. repo_key is valley:<name> for these, owner/repo on GitHub, else the short name.

Valley change states #

klaus status and the dashboard read valley changes --all --json once per look (the valley-changes/v1 view; other schemas are refused) and match a run to the version, in its repository and change, whose head is its pushed SHA.

Dashboardklaus statusGroupMeaning
REVIEWawaiting-reviewpipelinea draft left by finalize for review; approve refuses it
READYawaiting-approvalyoursthe active version, ready, awaiting approval
APPROVEDapprovedpipelinean integration request is filed and undecided, or stale only because checks are pending
INTEGRATEDintegrateddonethe change landed (every version shows it)
UNCERTAINuncertainyoursa request consumed or failed without landing evidence, or an unknown value
CHECKS FAILEDchecks-failedyoursstale, and the version's checks failed
CONFLICTINGconflictingyoursstale, and the current restack report says conflict
STALE, REJECTED, FAILEDstale, rejected, failedyoursthe integrator's decision
WITHDRAWNwithdrawndonethe change was withdrawn
OLDER VERSIONolder-versiondonea newer version exists and the change has not landed
DRAFTdraftyoursreturned to draft with no run of it running

Landing is the change's landed_version, else any version landed or landed-recorded. A run the listing lacks, or a failed listing, falls back to the git integration check, reading READY (or REVIEW) rather than GONE. A row the dashboard has seen keeps its last verdict marked (last known). While a listing fails, the dashboard shows valley unreachable: <reason>; showing git's view and klaus status prints it on stderr. valley changes --checks adds checks; a valley refusing the flag is listed without it, and the refusal is remembered for 10 minutes.

Restack-conflict dispatch #

klaus owns a change when its record's owner is the clone's valley.principal. A report (refs/the-valley/restack/main/<change-id>) counts while the valley calls it current and the change's record, active version, head and branch match it; klaus re-reads origin's refs before acting. The dispatch is valley unready, then klaus launch [--repo <project>] --change <change-id> --run-id <id> --expect-owner <principal> --expect-branch <branch> --expect-head <head> --expect-draft --reason restack-conflict "<brief>". The brief names the change, version, head, branch and main's tip, never the report's paths or text. Limits: no second run on a change, 60 seconds between dispatches, at most 3 runs until a clean report, once per input set (head, main's tip), 16 input sets remembered per change. An attempt is given back only when no worker started (stopped before launching, or exit status 3). Events: change:restack-dispatched, and change:restack-stalled with a reason once per input set. klaus status shows restack in CONFLICTS.

Failed-check dispatch #

For each failed head of a ready change klaus owns, the dispatch is klaus launch --change <change-id> --run-id <id> --expect-owner <principal> --expect-branch <branch> --expect-head <head> --reason checks-failed <brief>. Once per failed head, never while a run works on the change, and at most 3 failed attempts (a fix whose next version still fails counts) until the checks pass; recorded in checks-dispatches.json.

Knots #

--issue is a knot when its form is oc-, bd-, ida- or qn- with 7 hex digits, optionally <project>: first. Launch refuses it with --pr, outside a valley repository, without valley knot, and for a knot that is not an active outcome or bug, or that a running or unknown run claims; a claim left by a run klaus knows has ended is released (--if claimed_by=<run>) and taken over. The knot, parents and comments go into the brief in a ## Project notes (untrusted) block between marker lines carrying a random token. Just before the worker starts, valley knot claim <id> --run <run-id> (a refusal fails the launch). Finalize, once the head is ready, runs valley knot link <id> --change valley:<repo>/<change-id> and valley knot unclaim <id> --if claimed_by=<run-id>; a failed run comments (valley knot comment) and releases instead. When the change lands, the dashboard comments with the version and commit and sets the knot done (outcome) or closed (bug) only if every linked change landed, no child is active and nobody claims it, with --if conditions on status, claim and links. Recorded as knot.landed, knot.closed, knot.error.

Events #

Each line of events.jsonl is {"timestamp": <RFC3339>, "run_id": ..., "type": ..., "data": {...}}.

TypeWhen
agent:started, agent:completedA run started; finished
agent:pr-createdA run opened GitHub work
agent:branch-pushedA run finished with its branch on origin, no GitHub work
agent:change-recordedFinalize recorded another change or branch than launch
agent:change-ready, agent:change-draftA pushed head became a ready, or draft, version
agent:needs-attentionSalvaged or failed; needs the operator
agent:shared-git-changedThe clone's shared git files changed during the run
agent:paused, agent:resumedBudget pause; its follow-up finalized
agent:ci-passed, agent:ci-failedCI on an agent's GitHub work
pr:awaiting-approval, pr:approved, pr:mergedGitHub work ready for approval; approved; merged (once each)
pr:approval-changedklaus approve changed klaus's approval
pipeline:stalledThe pipeline gave up on GitHub work
change:approved, change:integratedA ready version got a request; the change landed (landed_commit)
change:stale, change:rejected, change:failedThe integrator's decision on the active version
change:withdrawnThe change was withdrawn
change:new-versionA version this session did not record (uploader)
change:checks-failed, change:checks-passedThe host's verdict on a ready version's checks (failed)
change:restack-dispatched, change:restack-stalledA restack run launched; klaus stops short
consult:started, consult:completedA consult backend call
review:started, review:completedA klaus review
phase:started, phase:completedA run phase (setup, agent, finalize)
check:started, check:completedA check an agent ran

The default klaus watch filter is every type above except agent:started, agent:completed, agent:paused, agent:resumed, agent:ci-*, agent:change-recorded, agent:shared-git-changed, pr:awaiting-approval, pr:approval-changed, phase:* and check:*, plus the reserved types agent:error, ci:failed, ci:passed and pr:comment, which nothing emits.

pr:approved and pr:merged fire once per piece of GitHub work across restarts; work already merged when first seen emits neither. Change transitions fire once per mark, under the change's handle, from the dashboard's minute check; each carries repo, handle, change_id, version, head, title, repo_key and key. A change first seen is recorded as it stands, without events. Dashboards on one session share the transition files under their .lock. klaus status emits nothing.

Consult events share a run_id consult-YYYYMMDD-HHMM-xxxxxxxx (one pair per panel member) and carry backend, model, effort, role, thread, dir, repo, commit, panel, prompt (first line, up to 120 characters) and prompt_file; consult:completed adds duration_ms, success and on failure a short error (timeout after 10m0s, interrupted), never model output. Review events carry backend, model, repo, pr_number, author, post, then duration_ms, success, findings, review_url or error. SIGINT and SIGTERM still emit the completion; outside a session nothing is emitted.

Run fields on events #

Run events (agent:*, phase:*, check:*, pr:approval-changed) also carry:

FieldMeaning
repo_keyowner/repo, valley:<name>, else the repository's short name
change_id, pr_numberThe run's change; its GitHub number once it has one
keyowner/repo#12, else <repo_key>@<change_id>
dispatch_reasonlaunch, pr-follow-up, budget-resume, change-follow-up, resume, ci-fix, review-fix, review-comment-fix, conflict-fix, restack-conflict, checks-failed, or a --reason
head_shaThe tip finalize found on origin, else the worktree's HEAD at the end or start

Pipeline and change events carry repo_key and key when known; consult events carry repo_key. Unknown fields are left out.

phase:completed carries phase, started_at, ended_at, duration_ms (and cost_usd for agent where known): setup is launch's work before the agent; agent runs from pane start to finalize; finalize up to killing the pane. check:* carry kind (pre-review, build, test, lint), command, source, duration_ms and success; _pre-review adds lint_ms, review_ms, findings, blocking, lint_failed. _format-stream times the build, test and lint commands it recognises in the stream (go test, go vet, cargo build, npm test, make <target>, nix build, nix flake check, ...); a command line that also runs klaus _pre-review is marked includes_pre_review. On a sandbox host _pre-review prints klaus-check-completed: {...} and the pane's _format-stream records it (via: stream).

Sandbox hosts #

With sandbox_host set (or --host), launch checks the host (ssh -o ConnectTimeout=3 -o BatchMode=yes <host> true), creates the worktree path there and syncs the worktree with rsync -az --delete; the agent runs over SSH and its stream, formatting and finalize stay local. An unreachable host falls back to local execution. A sandbox worker gets no KLAUS_SCRATCH or private TMUX_TMPDIR; its prompt says to keep scratch files in a mktemp -d directory, and nothing removes the worktree copy. The dashboard tags such runs [sandbox] and shows reachability; klaus status shows HOST. Claude conversations stay on the sandbox host, so its runs are never replayed.

Webhook receiver #

KeyDefaultMeaning
webhook.port9800Port the dashboard listens on
webhook.path/webhook/githubPath of deliveries
webhook.relay_urlnonePublic URL of the relay
webhook.secret_filenoneFile holding the secret setup gives GitHub to sign deliveries
webhook.poll_fallbackfalseAlso poll every 30 seconds
webhook.reconcile_interval_seconds300Full re-fetch interval when not polling; negative disables

A delivery names the work or repository to re-fetch from GitHub; the receiver builds no status from it and checks no signature. Only one dashboard per user holds the port; another polls as if no webhook were configured, and its source line says so. The source line shows the age of the last delivery (· last event 5m), dim under 30 minutes, yellow under 2 hours, red beyond; a long silence may be a quiet repository or a broken path.

Constraints #

  • Sessions, launches and klaus scaffold run inside tmux; agents are headless and take no input.
  • A run ends with its agent's turn; background work still running is interrupted and recorded.
  • No approval is automated: klaus posts no approving review, and klaus ready never approves.
  • The pipeline dispatches nothing on work a fix run is on, spaces dispatches 60 seconds apart, and stalls work after 3 failed attempts of a kind.
  • Briefs of any length go through files; inline pane content is capped at 12000 bytes.
  • Budgets, budget pause and --replay are Claude-only; --resume-from never moves a conversation between backends or machines.
  • Consult attachments total at most 200 KB; each consult call has a deadline (default 10 minutes); klaus merge waits at most 10 minutes for CI; the continuation lock waits at most 5 minutes.
  • valley ready, valley unready and knot calls are bounded by 30 seconds, valley changes by three minutes; the dashboard holds one telemetry follow slot per valley host.