Skip to main content

Module telemetry

Module telemetry 

Source
Expand description

Opt-in JSONL event log for debugging and calibration. Disabled by default — every entry point short-circuits unless telemetry is enabled, via either telemetry = true in ~/.config/ski/config.toml or a truthy SKI_TELEMETRY env var (1|true|yes|on, e.g. in the env block of ~/.claude/settings.json). Each entry point calls init right after Config::load to reflect the config flag into the process; enabled is then config-OR-env.

Two event kinds, appended one JSON object per line to $XDG_STATE_HOME/ski/telemetry.jsonl:

  • recommend — what ski hook decided on a prompt. Emitted on every ranked prompt, including the ones where ski injects nothing: the prompt, the stage, the top-K considered ranking (id + raw stage score) the chooser produced before the gate, the candidates that cleared the gate, which ids survived the char budget (injected), and an abstained reason when nothing was injected. The always-present considered list is what lets a later analysis see where ski ranked a skill on a prompt it stayed silent on.
  • use — a skill the model loaded itself (seen by ski observe) — i.e. the host’s own (native) skill chooser’s pick. Joining a use to the prompt’s recommend event by session + prompt tells us whether the native pick was something ski injected, ranked-but-abstained-on, or never surfaced.

Best-effort, like the rest of the hot path: any IO/serialization failure is swallowed so telemetry can never block or fail a prompt.

Functions§

enabled
Whether the event log is active. Cheap; called at every entry point so a disabled log costs one env lookup and nothing else. On when the config flag (via init) or a truthy SKI_TELEMETRY env var is set.
init
Reflect cfg.telemetry into the process so enabled sees it. Call once, right after Config::load, in any entry point that may record events.
record_recommend
Record the hook’s decision on a prompt. Emitted on every ranked prompt, even when ski injects nothing, so the always-present considered ranking records where ski placed each skill on a prompt it stayed silent on.
record_use
Record that the model loaded skill_id itself. via is "skill" (the Skill tool) or "read" (opened the SKILL.md). prompt is the active prompt the hook stashed in session state (empty if none), letting ski history tie a recall miss back to the call that triggered it.