Skip to content
suit Usage counts
Login

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

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 skill you call by name in Claude Code (/NAME) is written to the records as a slash command, so the rule above records it as use command, under the skill's name. The tally keeps it so; suit curate counts a command use that matches no command asset as a use of the skill of that name (curate.md, "Where each number comes from"), so a call-only skill does not look unused.

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 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.

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

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.