Artifact edf7fd622fa79ae3485032a804280d50309a1f29043c690f01cd49ba49072d91:
- File
docs/usage.md
— part of check-in
[1ed63201f4]
at
2026-11-18 03:02:04
on branch trunk
— suit curate apply turns the page's choices into config changes
suit curate apply FILE reads the choices file the curation page makes and prints a plan: which outfits and wears it edits, which wardrobes it checks in and in what order, and the links that will appear and disappear at each scope. Without --yes nothing changes. With --yes it edits each wardrobe's suit.conf and checks it in, with a comment such as "Curate: 3 kept, 1 limited, 12 retired". It does not place anything; the next run sees the config changed and applies.
- keep leaves a worn asset as it is. A loose asset, or one coming back from the attic, goes to the outfit kept.WARDROBE, worn at user scope. - limit moves the asset from its user outfits to personal.WARDROBE.SLUG, worn by [wear personal PROJECT], created or reused wherever it is. - retire removes the asset from every outfit of its wardrobe and adds it to attic.WARDROBE, which nothing wears. Apply refuses if a wear reaches an attic. - Removing one name from an outfit that lists `*` turns the `*` into an explicit list of the names it reached, minus that one, and the plan says so: names added to the store later are then not included by that outfit. No exclusion syntax was added.
Outfit names carry the wardrobe because outfit names are one set across wardrobes; a name too long for that is refused for its line. A wardrobe that defines a new outfit is checked in before any wardrobe whose wear names it, so a failure part-way leaves only an outfit nothing wears; a run that would need the opposite order is refused before anything changes.
Configs are edited as text: only the lines that must change are rewritten, and comments, blank lines, alignment, line endings and the order of everything else are kept. Every edited config must parse and the combined set must pass the merge check before anything is written. A wardrobe with local changes is refused, so the check-in holds the curation only. A failed check-in puts that wardrobe's file back.
A malformed line, a duplicate, a bad header or a path given as a project refuses the whole file, listing every problem. An unknown asset is warned about and skipped; a choice already true is silent.
A new suite, test/curate_apply.sh, with 376 cases, is part of the gate, and a new fuzz target covers the choices parser and the line editor.
3669 unit checks (was 2993), 625 shell cases, 1153 store cases, 985 placement cases, 378 project cases, 236 usage cases, 288 curate cases and 376 curate-apply cases, under clang, under gcc 16, with no user name set, and under a strict umask, in one run of make gate (44 minutes). 100% coverage in all 32 source files. No existing case was changed. (user: dmestas, size: 13553) [annotate] [blame] [check-ins using]
Usage counts
Suit counts how often each skill, agent and command is invoked, so a wardrobe
can be curated from what is used. It does not ask the harness to report; it
reads the session records the harness already keeps, afterwards, and keeps a
tally of its own on each machine. Parts two and three build on the numbers this
part produces: part two is suit curate, the page that shows each asset beside
its use (curate.md); part three, suit curate apply, applies the choices
made on it (curate.md, "Applying the choices").
The model
- Counts come from the harnesses' own session records. A harness writes one JSON object per line (JSON Lines), appended as the session goes. Suit reads those files. There is no hook, nothing is installed in a harness, and a harness that is not running costs nothing.
- What a record looks like is data. The wardrobe's
[harness NAME]section says where the files are, where in a record the time and the working folder are, and what makes a record an invocation. There is no harness code in suit (decisions, 2026-11-16). Only a harness whose records are described can be counted. Claude Code's are, in harnesses.md; Codex, Cursor, Gemini and pi have no rules yet. - Suit keeps its own tally, because harnesses delete old records (Claude Code
after 30 days by default). The tally is this machine's history. It is in
$SUIT_HOME/usage/, never in a wardrobe: a wardrobe is shared between machines and the tally is not, and the working folders in it are paths on this disk. - An hourly pass reads only what is new. The tree of session files can be many gigabytes. Each file is read from where the last scan stopped, and a file that has not changed is not opened.
The keys
In a [harness NAME] section (conf-format.md):
sessions = ~/.claude/projects/*/*.jsonl
sessions = ~/.claude/projects/*/*/subagents/*.jsonl
session time = timestamp
session project = cwd
use skill = message.content[] where type=tool_use name=Skill name input.skill id id
use agent = message.content[] where type=tool_use name=Agent name input.subagent_type id id
use agent = message.content[] where type=tool_use name=Task name input.subagent_type id id
use command = . where type=user name message.content between <command-name>/ </command-name>
| Key | Meaning |
|---|---|
sessions = GLOB |
Files holding session records. Repeatable, at most 8 per harness. ~ is the home folder ($HOME), * matches any run of characters (including none) within one path part, and nothing else is a wildcard. The pattern is absolute or starts with ~/. Files only: a folder that matches is ignored. |
session time = PATH |
Where a record's time is. At most once. A string in ISO 8601, YYYY-MM-DDTHH:MM:SS and then anything (.123Z): suit reads it as UTC. |
session project = PATH |
Where a record's working folder is. At most once. |
use KIND = RULE |
What makes a record an invocation of a skill, an agent or a command (KIND). Repeatable, at most 16 per harness. |
A harness is scanned when it has at least one sessions and at least one use.
A harness with sessions and use but no session time is an error (exit 2).
A harness with no session project is counted, and its events have the
project -.
The rule language
IN [where FIELD=VALUE ...] name PATH [between A B] [id PATH]
Words are separated by spaces or tabs, in this order.
- A path is field names joined by dots (
message.content). A part ending in[]means each element of that array (message.content[])..alone means the record itself. A field name is 1 to 32 bytes and has no.,[or]; a path has at most 8 steps, a[]counting as one. OnlyINmay have[]. INis a path from the record's top to the thing examined. Formessage.content[]that is each block of the content array, one at a time.where FIELD=VALUEtests (up to 4) compare a string field of the thing examined, a path relative to it, with VALUE exactly. VALUE is 1 to 64 bytes and has no spaces. All the tests must hold. A field that is not a string, or is not there, fails the test.name PATHis the path, relative to the thing examined, of the string that is the asset's name. If it leads to an array of objects, each element'stextstring is tried: that covers a user record whose content is a list of text blocks. At most 8 names are taken from one thing.between A B(optional): the name is the text between the firstAfound in the first 512 bytes of that string and the nextB. A and B are 1 to 64 bytes and have no spaces. Without it the whole string is the name. IfAis not there the string is not an invocation (and is not counted as skipped). IfAis there andBis not, or the name is empty, it is skipped.id PATH(optional): a string that identifies the call. Without it the call is identified by its time, kind and name.
A name is kept only if it is 1 to 200 bytes of printable ASCII with no space,
control byte, <, > or ". Anything else is not counted, and is counted in
the skipped figure. An id is held to the same rule and 128 bytes; one that is
not is skipped too. An id that is not a string is no id.
A # after a space starts a comment in a config file, so a rule cannot hold one
there (there is no quoting). The parser rejects a rule that is malformed with a
message naming what is wrong: use skill: 'name PATH' is missing.
A rule is a sieve and the walk decides. Before it walks a line, the reader skips
the line unless it holds, as bytes, every where VALUE of at least one rule.
This is only a filter, to avoid walking lines that cannot match: it looks at the
raw text, so a VALUE that the harness writes with a JSON escape (Skill)
would be missed by it. Say the VALUE the way the harness writes it.
What counts
Only a real value at the declared path counts. A skill name that appears in a
listing, a reminder or quoted text is a string in some other place, or a string
inside a string; neither is a block at message.content[]. Records are not
guessed at: a harness with no rules is not counted.
A record that has nothing to say about a use (Agent with no subagent_type,
which stands for the default agent) is not counted.
The reader
The reader is src/usage.c. It is a streaming JSON reader for one line at a
time and it knows nothing of any harness.
- A line is read in chunks of 64 KiB and walked as it comes. No buffer grows
with the line, whatever its length (embedded images make lines of many
megabytes). A string is kept only up to its first 512 bytes (what
betweenlooks at); a longer one is skipped over. - Nesting deeper than 64 containers is not read: the line is skipped, not a crash.
- Escapes in strings are decoded:
\",\\,\/,\b\f\n\r\tand\uXXXXfor the basic plane. A surrogate escape is read as U+FFFD, so it is never a name. Another escape is not JSON and skips the line. - A line that is not valid JSON is skipped and counted in
skipped, not an error. A last line with no newline, a session still being written, is not read yet: the offset stays at its start and it is read when it is whole. - Resumed and forked sessions copy earlier records into a new file, so the same call can be in several files. See "Repeats" below.
The fuzz target is test/fuzz_usage.c: any bytes, read as lines against a fixed
set of rules, must never crash, read out of bounds or run forever.
What suit keeps
$SUIT_HOME/usage/events, one line per counted invocation, appended:
TIME HARNESS KIND NAME PROJECT ID
separated by single tabs. TIME is the record's time as written. KIND is skill,
agent or command. PROJECT is the project's remote key if the working folder
is inside a project suit knows (the list suit projects shows, the longest
folder that holds it), else the folder with the home folder written ~, or -
when the record has none. ID is the call's id, or -. A tab or newline in a field
makes the event skipped.
$SUIT_HOME/usage/offsets, one line for each session file known:
HARNESS PATH SIZE MTIME OFFSET HEADLEN HEAD
the file's size and modification time when it was read, the byte offset read up
to (the start of the first incomplete line), and a hash of the file's first
HEADLEN bytes (at most 256). A file that shrank, or whose first bytes changed,
is read again from the start. A file whose size and time are as recorded is not
opened. A file that is gone is dropped from the offsets; its events stay.
Both files are written with the atomic write the rest of suit uses, the events first. A failure leaves the old files whole and the scan is repeated next time: if only the offsets fail, the next scan reads the same bytes again and finds every event already there.
Repeats
An invocation whose (HARNESS, ID) is in events already is not added. With no
id, (HARNESS, TIME, KIND, NAME) is the identity. The identities are held as
64-bit hashes (FNV-1a) in memory while a scan runs, so two different calls are
taken for one only if their hashes are equal. The events older than 400 days are
dropped when the file is rewritten. At most 500000 events and 32 MiB are kept;
beyond that the oldest, at the front of the file, are dropped first.
The commands
| Command | What it does | Exit |
|---|---|---|
suit usage scan |
Reads what is new in every harness's session records. Prints usage: N files read, N invocations added, N records skipped, or usage: no harness has sessions. |
0, 1, 2, 20 |
suit usage [--since DAYS] [--kind KIND] [--harness NAME] [--project KEY] |
A scan, then a table of KIND NAME USES LAST PROJECTS, most used first, then by name, then kind, for the window (default 30 days, 1 to 400), then one line: invocations, names, the window and the date of the oldest event kept. |
0, 1, 2, 20 |
suit usage --tsv ... |
The same rows without a header or the summary, tab separated. | the same |
suit curate [--since DAYS] [--out FILE] |
A scan, then one HTML page of every asset beside its use, with choices (curate.md). | 0, 1, 2, 20 |
suit tend |
After tending the wardrobes, scans once. Its failure is reported and does not change the exit status. | the tend's |
files read is the files opened: a file whose size and time are as the offsets
say is not opened and is not counted. records skipped is invocations that were
found but are not events (bad name, no time, a tab in a field), and lines that
passed the filter but were not valid JSON. The scan takes the same lock the other
commands that write take (exit 20 if another suit holds it).
A first scan, when there is no offsets file, reads only the session files
modified in the last 45 days, to bound the first run. The older files are noted
in offsets as read up to nothing, and a later scan reads one only if it
changes, from its start. Later scans read every file with new bytes. A file that
is new after the first scan is read whatever its age.
LAST is the date, in UTC, of the newest use in the window. PROJECTS is the
number of distinct projects. Names that are in no wardrobe are listed all the
same; the report does not join with a wardrobe.
The --tsv form
One row per name, in the order above, with five columns:
KIND NAME USES LAST KEY=N,KEY=N
The last is every project with its count, in byte order of the project. A project
is written as in events, except that , is %2C and % is %25; split on
, and then at the last =. This format is stable.
Exit statuses
| 0 | done, or nothing to scan |
| 1 | a file could not be read, written or listed, a file of the tally is not in its form (events:LINE: not an event line), or a limit below is passed; nothing was written |
| 2 | arguments wrong, or the config cannot be used: no wardrobe, a config error, sessions with no session time |
| 20 | another suit holds the lock |
A failure of any kind in a scan writes nothing at all.
Limits
| files known | 16384, and a path of at most 1023 bytes (a longer one is skipped and counted) |
| bytes of file names | 4 MiB |
| events file | 32 MiB, 500000 events |
| new events in one scan | 8 MiB |
| offsets file | 4 MiB |
| names in one report | 65536 |
| a line | no limit; a string is kept to 512 bytes; nesting to 64 |
What is not counted
- A harness whose records are not described. Only Claude Code's are.
- A harness's records that have been deleted before the first scan.
- A record with no time, or a time not in ISO 8601:
api-request-blobrecords of Claude Code carry a copy of earlier calls and no time, and are skipped. - A call whose name or id is not a printable token, or whose fields hold a tab.
- Use that leaves no record: a skill the model read without invoking it.
- An
Agentcall with nosubagent_type.
Tests
test/unit.c (the rule parser, the paths, the reader on every case in the list
above, the helpers), test/usage.sh (the commands and the files, every
failing call), test/fuzz_usage.c with its seeds in test/corpus/usage.
test/make_usage_tree.sh makes the tree the speed figures in
evidence.md were taken on. A test build reads SUIT_NOW (seconds
since 1970) for the date and SUIT_USAGE_LIMITS (events=N,files=N,rows=N,new=N,
text=N,bytes=N,pool=N) to lower the limits above; a release build has neither.