Skip to content

Inside The cycle s record

Ilia edited this page Nov 9, 2026 · 1 revision

One line survives it: the cycle's own record. Everything the cycle measures about itself is in that state.json — when each step started and finished, how many fixing sessions a red regression needed, which friction reviews committed and which found every ban deliberate — and all of it used to die with the tree. So the questions the record answers could not be asked at all: is the cycle getting faster, which step actually holds it up, are two fixing attempts enough or generous.

Just before the clean-up, and before the worktree in sclaude drop too, the state is flattened into one record and appended to ~/.claude/sclaude/cycles.jsonl. Outside every repository, for the reason the epilogue's state and the QA watch are: $REPO is the product's tree, where steps 2-4 work and git add -A is an everyday thing, and a service file with timings would ride into somebody else's commit.

Append-only, JSON Lines. A finished feature is a fact, and in a format where the last line is the only writable one a machine dying mid-write cannot corrupt the nineteen above it. Each line parses on its own, so the file is read with jq without loading all of it:

jq -s '[.[] | select(.outcome == "done") | .steps.code.seconds] | add / length' \
  ~/.claude/sclaude/cycles.jsonl

Deliberately not aggregated by sclaude and deliberately not a database. Twenty lines of JSON answer a question in one command; a schema would have to be decided now, before anybody has looked at the data, and that is the wrong order.

Each record names who ran the cycle (developer, from developer.sh; null where nobody could be named) and the product (repo, its main checkout). A product whose team wants its cycles in one place names a git repository of its own under metrics in its .sclaude/config.json; each developer's records of that product — only that product's — are then published there as <developer>.jsonl after every record. One file per person, so publishing never conflicts, and a second machine of the same person adds its lines rather than replacing the first's. A clone per remote is kept under ~/.cache/sclaude/metrics/.

The remote used to be one file per person (~/.config/sclaude/metrics-remote), and somebody working on two products published both into one team's repository, where one team saw the other's feature names and paths. Now each product's records go only where that product says. Not this repository, on purpose: the records carry the team's feature names and paths, and instruments is shared by everybody who installs it. No key, no publishing.

outcome is what keeps a finished feature and an abandoned one apart — done against dropped — and they must never be averaged together: an abandoned feature's timings describe a decision to stop, not a cycle that ran its course. It is recorded rather than inferred, because a feature dropped at step 4 looks exactly like one that finished.

Throughout, a value that is not known is null rather than zero. A step nobody reached and a step that took no time are different facts, and the second is what a zero would average in as. The whole call is best-effort down to the || true: a record that cannot be written is one measurement lost, and losing it must not stand in the way of cleaning up a merged feature.


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

Clone this wiki locally