A background Haiku watches the session and, at the right moment, suggests one of your installed skills above the prompt.

Skill Nudge watches your Claude Code session in the background and tells you when one of your installed skills fits what you're doing. After a turn finishes, Haiku reads the recent conversation and your skill list. When a skill fits the next step well, a tip appears above the prompt:
✦ Skill tip · /ravn-core:research
You're weighing approaches; see what others did first.
1: Use 2: Dismiss
Type 1 or 2 into the empty prompt to pick, as you answer a survey, or click. Use puts /<skill> in the prompt box, ahead of anything you already typed, so your draft becomes the skill's arguments. A skill marked user-invocable: false can't be typed as a command, so for one of those Use writes Use the <skill> skill. ahead of your draft instead, and Claude runs it. Dismiss hides the tip. Sending your next prompt also clears it.
Requires Claude Code 2.1.287 or later.
/plugin marketplace add ravnhq/ravn-core
/plugin install skill-nudge@ravn
For a local session:
claude --plugin-dir ./plugins/mods/skill-nudge
/skill-nudge turns it off or back on, and Claude Code's plugin store keeps the choice across sessions. /skill-nudge stats shows how tips fared.claude -p never trigger it./name, is never suggested. Skill Nudge suggests each skill at most once per session.Each judgment is one Haiku request on your session's own Claude Code client and account. It sends the names and descriptions of the listed skills, cached across requests, plus the last eight messages of the conversation, each cut to 1,500 characters, along with the names of the tools each message used. Tool inputs and outputs aren't sent. Skill Nudge never changes what the main model reads.
Skill Nudge keeps a local record of how its tips fare, so you can see whether they help and share the numbers with the team.
Run /skill-nudge stats to see judgments, tips shown, and how many you took (pressed Use or ran the skill yourself), dismissed, or ignored by sending a different prompt, overall and per skill. The command also copies a JSON summary to the clipboard. Paste it wherever the team collects feedback.
The record stays in Claude Code's plugin store on your machine. Nothing is sent anywhere. Each event holds only:
Events never include conversation text, Haiku's reason, file paths, repository names, or your identity. Skill Nudge keeps the newest 500 events per session and the newest 50 sessions.
The tip draws in the band above the prompt, so it shows in the terminal and the Desktop Code tab only. A survey in that band takes priority over the tip.
hooks/register.tsx 336 lines1import { atom, read, update } from "claude-code";
2import type { EngineInterface, Register } from "claude-code";
3
4import {
5 MAX_TOKENS,
6 SYSTEM,
7 catalog,
8 listing,
9 parse,
10 transcript,
11 usedSkills,
12} from "../lib/nudge.ts";
13import {
14 parseEvents,
15 promptVersion,
16 report,
17 summarize,
18} from "../lib/telemetry.ts";
19import type { NudgeEvent, TipFate } from "../lib/telemetry.ts";
20
21const COMMAND = "skill-nudge";
22
23const ENABLED_KEY = "enabled";
24
25const MODEL = "haiku";
26
27const INSTALL_KEY = "installId";
28
29// One store key per session, so concurrent sessions never overwrite each other's events.
30const EVENTS_PREFIX = "events:";
31
32const MAX_EVENTS_PER_SESSION = 500;
33
34const MAX_SESSIONS = 50;
35
36// Haiku judges at most once per this many finished turns.
37const TURNS_BETWEEN_JUDGMENTS = 2;
38
39const nudge = atom({ plugin: "skill-nudge", key: "nudge" } as const, null);
40
41const offered = atom({ plugin: "skill-nudge", key: "offered" } as const, []);
42
43const turnsSinceJudgment = atom(
44 { plugin: "skill-nudge", key: "turnsSinceJudgment" } as const,
45 0,
46);
47
48async function isEnabled($: EngineInterface): Promise<boolean> {
49 return (await $.store.get(ENABLED_KEY)) !== false;
50}
51
52let isInteractive = false;
53
54let isJudging = false;
55
56// Commands the engine keeps out of the typeahead, `user-invocable: false` skills
57// among them. `$.command.list()` still returns them, but typing one fails, so
58// Use asks Claude to run it instead.
59let hidden = new Set<string>();
60
61// Bumped by each prompt, so a judgment that lands after the user moved on is dropped.
62let epoch = 0;
63
64// Appends run one at a time, so this session's events never overwrite each other.
65let recording: Promise<void> = Promise.resolve();
66
67function record($: EngineInterface, event: NudgeEvent): Promise<void> {
68 recording = recording.then(() => append($, event)).catch(() => undefined);
69
70 return recording;
71}
72
73async function append($: EngineInterface, event: NudgeEvent): Promise<void> {
74 const key = EVENTS_PREFIX + (await $.session.id());
75 const events = await eventsAt($, key);
76 await $.store.set(
77 key,
78 JSON.stringify([...events, event].slice(-MAX_EVENTS_PER_SESSION)),
79 );
80}
81
82async function eventsAt(
83 $: EngineInterface,
84 key: string,
85): Promise<NudgeEvent[]> {
86 return parseEvents(String((await $.store.get(key)) ?? "[]"));
87}
88
89async function fate(
90 $: EngineInterface,
91 type: TipFate["type"],
92 skill: string,
93): Promise<void> {
94 await record($, {
95 type,
96 skill,
97 at: await $.clock.now(),
98 prompt: await promptVersion(SYSTEM),
99 });
100}
101
102async function dismissTip($: EngineInterface, skill: string): Promise<void> {
103 await update($, nudge, () => null);
104 await fate($, "dismissed", skill);
105}
106
107async function prepareTelemetry($: EngineInterface): Promise<void> {
108 if ((await $.store.get(INSTALL_KEY)) === undefined)
109 await $.store.set(INSTALL_KEY, crypto.randomUUID());
110
111 const sessions = (await $.store.keys()).filter((key) =>
112 key.startsWith(EVENTS_PREFIX),
113 );
114
115 for (const key of sessions.slice(0, -MAX_SESSIONS)) await $.store.delete(key);
116}
117
118async function stats($: EngineInterface): Promise<string> {
119 await recording;
120
121 const keys = (await $.store.keys()).filter((key) =>
122 key.startsWith(EVENTS_PREFIX),
123 );
124
125 const sessions: NudgeEvent[][] = [];
126
127 for (const key of keys) sessions.push(await eventsAt($, key));
128
129 const summary = summarize(String(await $.store.get(INSTALL_KEY)), sessions);
130 const json = JSON.stringify(summary, null, 2);
131 const { isCopied } = await $.ui.copy({ text: json });
132
133 return `${report(summary)}\n\n${
134 isCopied
135 ? "Copied the JSON summary to the clipboard."
136 : `JSON summary:\n${json}`
137 }`;
138}
139
140async function judge($: EngineInterface, at: number): Promise<void> {
141 const messages = await $.session.messages();
142
143 const exclude = new Set([
144 ...usedSkills(messages),
145 ...(await read($, offered)),
146 ]);
147
148 const skills = catalog(await $.command.list(), exclude);
149
150 if (skills.length === 0) return;
151
152 const startedAt = await $.clock.now();
153
154 const reply = await $.model.complete({
155 model: MODEL,
156 system: SYSTEM,
157 prompt: [
158 { text: listing(skills), cache: true },
159 { text: transcript(messages) },
160 ],
161 maxTokens: MAX_TOKENS,
162 timeoutMs: 20000,
163 });
164
165 const now = await $.clock.now();
166 const found = reply.isAnswered ? parse(reply.text, skills) : undefined;
167 const isStale = at !== epoch;
168 const shows = found !== undefined && !isStale;
169
170 // The tip shows first; recording it never delays it.
171 if (shows) {
172 await update($, nudge, () => ({
173 ...found,
174 asksClaude: hidden.has(found.skill),
175 }));
176 await update($, offered, (list) => [...list, found.skill]);
177 }
178
179 await record($, {
180 type: "judged",
181 at: now,
182 prompt: await promptVersion(SYSTEM),
183 outcome: reply.isAnswered
184 ? isStale
185 ? "stale"
186 : found === undefined
187 ? "none"
188 : "nudge"
189 : "error",
190 skill: found?.skill ?? null,
191 skills: skills.length,
192 latencyMs: now - startedAt,
193 inputTokens: reply.usage.input_tokens,
194 outputTokens: reply.usage.output_tokens,
195 cacheReadTokens: reply.usage.cache_read_input_tokens,
196 });
197}
198
199export const register: Register = (on) => {
200 // Each load starts fresh, as a reload's new environment does.
201 isInteractive = false;
202 isJudging = false;
203 hidden = new Set();
204 epoch = 0;
205 recording = Promise.resolve();
206
207 on("session.start", async ($, e, next) => {
208 isInteractive = e.isInteractive;
209 await $.command.register({
210 name: COMMAND,
211 description: "Turn skill nudges on or off; `stats` shows how tips fared",
212 argumentHint: "[stats]",
213 });
214 await prepareTelemetry($).catch(() => undefined);
215 // A reload starts with an empty set, so ask the engine to describe every command again.
216 $.ui.invalidate("command.describe");
217
218 return next(e);
219 });
220
221 on("command.describe", async ($, e, next) => {
222 const result = await next(e);
223
224 if (result.isHidden) hidden.add(e.command);
225 else hidden.delete(e.command);
226
227 return result;
228 });
229
230 on("command.run", { command: COMMAND }, async ($, e) => {
231 if (e.args.trim() === "stats") return { text: await stats($) };
232
233 const isOn = !(await isEnabled($));
234 await $.store.set(ENABLED_KEY, isOn);
235 const shown = await read($, nudge);
236
237 if (!isOn && shown !== null) await dismissTip($, shown.skill);
238
239 return { text: `Skill nudges ${isOn ? "on" : "off"}.` };
240 });
241
242 on("prompt.submit", async ($, e, next) => {
243 epoch += 1;
244 const shown = await read($, nudge);
245
246 if (shown !== null) {
247 await update($, nudge, () => null);
248 const [command = ""] = e.text.trimStart().split(/\s/, 1);
249 const typed = command === `/${shown.skill}`;
250 await fate($, typed ? "typed" : "ignored", shown.skill);
251 }
252
253 return next(e);
254 });
255
256 on("turn.complete", async ($, e, next) => {
257 const result = await next(e);
258
259 if (e.agentId !== undefined || e.reason !== "answer" || !isInteractive)
260 return result;
261
262 const turns = (await read($, turnsSinceJudgment)) + 1;
263 await update($, turnsSinceJudgment, () => turns);
264
265 if (isJudging || turns < TURNS_BETWEEN_JUDGMENTS || !(await isEnabled($)))
266 return result;
267
268 isJudging = true;
269 await update($, turnsSinceJudgment, () => 0);
270 const at = epoch;
271 $.clock.after(0, () => {
272 void judge($, at)
273 .catch(() => undefined)
274 .finally(() => {
275 isJudging = false;
276 });
277 });
278
279 return result;
280 });
281
282 on("ui.render", { component: "AbovePrompt" }, async ($, e, next) => {
283 const shown = await read($, nudge);
284
285 if (shown === null || e.props.hasSurvey) return next(e);
286
287 const { Box, Button, Text } = $.ui.resolve(e);
288
289 const dismiss = () => dismissTip($, shown.skill);
290
291 const use = async () => {
292 // A draft the user already typed becomes the skill's arguments.
293 const { text } = await $.prompt.read();
294 const draft = text.trimStart();
295 await $.prompt.fill({
296 text: shown.asksClaude
297 ? `Use the ${shown.skill} skill.${draft ? ` ${draft}` : ""}`
298 : `/${shown.skill} ${draft}`,
299 });
300 await update($, nudge, () => null);
301 await fate($, "used", shown.skill);
302 };
303
304 // Digit hotkeys, as a survey's: a bare digit in the empty prompt presses
305 // them, while a letter works only after the person focuses the band.
306 return (
307 <Box flexDirection="column" padding={1}>
308 <Text>
309 <Text color="suggestion" bold>
310 ✦ Skill tip
311 </Text>
312 <Text dimColor> · </Text>
313 <Text bold>
314 {shown.asksClaude ? "" : "/"}
315 {shown.skill}
316 </Text>
317 </Text>
318 <Box paddingLeft={2} flexDirection="column">
319 <Text>{shown.reason}</Text>
320 <Box columnGap={2}>
321 <Button key="use" label="Use" hotkey="1" plain onPress={use} />
322 <Button
323 key="dismiss"
324 label="Dismiss"
325 hotkey="2"
326 plain
327 role="dismiss"
328 onPress={dismiss}
329 />
330 </Box>
331 </Box>
332 </Box>
333 );
334 });
335};
336lib/nudge.ts 173 lines1// Structural types, not the `claude-code` ones, so evals/skill-nudge can run this
2// prompt code under plain Node.
3export type Command = {
4 name: string;
5 description: string;
6 source: string;
7 plugin?: string;
8};
9
10export type Message = {
11 role: "user" | "assistant";
12 text: string;
13 toolUses: readonly { tool: string; input: { skill?: unknown } }[];
14};
15
16export type Skill = { name: string; description: string };
17
18export type Suggestion = { skill: string; reason: string };
19
20type Json = null | boolean | number | string | Json[] | JsonObject;
21
22type JsonObject = { [key: string]: Json };
23
24const RECENT_MESSAGES = 8;
25
26const MESSAGE_CHARS = 1500;
27
28// Haiku's reply cap; the eval sends the same, so a reply cut short there is cut short here.
29export const MAX_TOKENS = 200;
30
31// The band wraps long text; this cap only stops a runaway reply.
32const REASON_CHARS = 300;
33
34// The format rule closes the transcript too: Haiku follows what it read last.
35const REPLY_FORMAT =
36 "Reply with exactly one JSON object: no code fence, and no text before or after it.";
37
38export const SYSTEM = `You watch a Claude Code session from the side. After each turn you decide whether the user should run one of their installed skills next, and which one. You are not in the conversation: never answer the user, continue the work, or explain your choice.
39
40Each skill's description says what situations it is for ("Use when...", "Apply when..."). Match the situation in the latest exchange to those descriptions, not just the topic.
41
42First check whether to suggest nothing. Suggest nothing when:
43- the turn was small talk, a trivial edit, or a complete self-contained answer;
44- the assistant already did what the skill would do: ran it, verified against the real artifact, or wrote and ran the regression test (a test that was run, or output checked against real data, is that check);
45- the assistant is mid-task and simply continuing: it reports progress and names its next step, without asking the user anything.
46
47Otherwise, suggest a skill when:
48- the user's goal is what a skill is for, and the assistant answered without that skill's process: it guessed, gave a quick summary, or proposed a shortcut;
49- the work just done calls for a check that a skill provides, and the assistant has not done that check;
50- the user is about to start, plan, pause, resume, hand off, or ship work, and a skill covers that step;
51- the assistant made, or is about to make, a mistake that a principle skill ("Apply when...") names.
52
53Choosing between skills:
54- Prefer a principle skill that names the assistant's specific mistake over a broad workflow skill that covers the same topic.
55- A description that assumes something exists ("the supplied PR", "a handoff note") fits only once the session has it; before that, pick the skill that creates it.
56- Match whose knowledge the question needs. Why this repo chose something is in its own history; what other teams or the wider field do needs outside sources.
57- Tests of the changed code do not check the code that calls it.
58
59Pick the single most specific skill.
60
61${REPLY_FORMAT}
62{"skill": "<a name exactly as listed>", "reason": "<one short sentence to the user, under 120 characters, saying why now; address them as \\"you\\", never as \\"the user\\">"}
63or, when nothing fits:
64{"skill": null}`;
65
66/** The user's own skills: plugin and user slash commands, less the ones already used or offered. */
67export function catalog(
68 commands: readonly Command[],
69 exclude: ReadonlySet<string>,
70): Skill[] {
71 return commands.flatMap(({ name, description, source, plugin }) =>
72 (source === "plugin" || source === "user") &&
73 plugin !== "skill-nudge" &&
74 !exclude.has(name)
75 ? [{ name, description }]
76 : [],
77 );
78}
79
80/** Skills the session already ran, by the Skill tool or typed as `/name`. */
81export function usedSkills(messages: readonly Message[]): Set<string> {
82 const used = new Set<string>();
83
84 for (const message of messages) {
85 for (const call of message.toolUses) {
86 const skill = call.tool === "Skill" ? String(call.input.skill ?? "") : "";
87
88 if (skill) used.add(skill);
89 }
90
91 const typed = /^\/([\w:-]+)/.exec(message.text.trimStart());
92
93 if (message.role === "user" && typed) used.add(typed[1]!);
94 }
95
96 return used;
97}
98
99export function listing(skills: readonly Skill[]): string {
100 const lines = skills.map(
101 ({ name, description }) => `- ${name}: ${description}`,
102 );
103
104 return `Installed skills:\n${lines.join("\n")}\n\n`;
105}
106
107export function transcript(messages: readonly Message[]): string {
108 const lines = messages.slice(-RECENT_MESSAGES).map((message) => {
109 const tools = message.toolUses.map((call) => call.tool);
110 const text = clip(message.text.trim(), MESSAGE_CHARS);
111 const used = tools.length > 0 ? ` [tools: ${tools.join(", ")}]` : "";
112
113 return `${message.role}: ${text}${used}`;
114 });
115
116 return `Recent conversation, oldest first:\n${lines.join("\n\n")}\n\n${REPLY_FORMAT}`;
117}
118
119/** Reads the model's reply; anything but a listed skill with a reason is no nudge. */
120export function parse(
121 reply: string,
122 skills: readonly Skill[],
123): Suggestion | undefined {
124 const source = /\{[\s\S]*\}/.exec(reply)?.[0];
125
126 if (source === undefined) return undefined;
127
128 let value: Json;
129
130 try {
131 value = JSON.parse(source);
132 } catch {
133 return undefined;
134 }
135
136 if (!isJsonObject(value)) return undefined;
137
138 const { skill, reason } = value;
139
140 if (!isString(skill) || !isString(reason) || reason.trim() === "")
141 return undefined;
142
143 const listed = listedName(skill, skills);
144
145 if (listed === undefined) return undefined;
146
147 return { skill: listed, reason: clip(reason.trim(), REASON_CHARS) };
148}
149
150// Haiku sometimes drops a plugin prefix; a bare name counts when one listed skill ends with it.
151function listedName(
152 name: string,
153 skills: readonly Skill[],
154): string | undefined {
155 if (skills.some((one) => one.name === name)) return name;
156
157 const matches = skills.filter((one) => one.name.endsWith(`:${name}`));
158
159 return matches.length === 1 ? matches[0]!.name : undefined;
160}
161
162function isJsonObject(value: Json | undefined): value is JsonObject {
163 return value === Object(value) && !Array.isArray(value);
164}
165
166function isString(value: Json | undefined): value is string {
167 return value === String(value);
168}
169
170function clip(text: string, limit: number): string {
171 return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
172}
173lib/telemetry.ts 229 lines1// Outcome events, kept on the user's machine. They hold no conversation text and
2// no Haiku reason: only what happened, which skill, and what it cost.
3
4export type Judgment = {
5 type: "judged";
6 at: number;
7 prompt: string;
8 // `stale`: Haiku answered after the user had already sent another prompt.
9 outcome: "nudge" | "none" | "error" | "stale";
10 skill: string | null;
11 skills: number;
12 latencyMs: number;
13 inputTokens: number;
14 outputTokens: number;
15 cacheReadTokens: number;
16};
17
18export type TipFate = {
19 // `typed`: the user ran the suggested skill without pressing Use.
20 type: "used" | "typed" | "dismissed" | "ignored";
21 at: number;
22 prompt: string;
23 skill: string;
24};
25
26export type NudgeEvent = Judgment | TipFate;
27
28type Fates = {
29 shown: number;
30 used: number;
31 typed: number;
32 dismissed: number;
33 ignored: number;
34};
35
36export type Summary = {
37 installId: string;
38 sessions: number;
39 from: string | null;
40 to: string | null;
41 judgments: { total: number } & Record<Judgment["outcome"], number>;
42 averageLatencyMs: number;
43 tokens: { input: number; output: number; cacheRead: number };
44 tips: Fates;
45 bySkill: Record<string, Fates>;
46 byPrompt: Record<string, Fates & { judged: number }>;
47};
48
49const emptyFates = (): Fates => ({
50 shown: 0,
51 used: 0,
52 typed: 0,
53 dismissed: 0,
54 ignored: 0,
55});
56
57type Json = null | boolean | number | string | Json[] | JsonObject;
58
59type JsonObject = { [key: string]: Json };
60
61const OUTCOMES = ["nudge", "none", "error", "stale"] as const;
62
63const FATES = ["used", "typed", "dismissed", "ignored"] as const;
64
65/** Reads a session's stored events, keeping only well-formed ones. */
66export function parseEvents(text: string): NudgeEvent[] {
67 let value: Json;
68
69 try {
70 value = JSON.parse(text);
71 } catch {
72 return [];
73 }
74
75 return Array.isArray(value) ? value.flatMap(eventOf) : [];
76}
77
78function eventOf(value: Json): NudgeEvent[] {
79 if (!isJsonObject(value)) return [];
80
81 const row = value;
82 const { type, at, prompt, skill } = row;
83
84 if (!isNumber(at) || !isString(prompt)) return [];
85
86 if (type === "judged") {
87 const outcome = OUTCOMES.find((one) => one === row.outcome);
88
89 const numbers = [
90 row.skills,
91 row.latencyMs,
92 row.inputTokens,
93 row.outputTokens,
94 row.cacheReadTokens,
95 ];
96
97 if (outcome === undefined || !numbers.every(isNumber)) return [];
98
99 return [
100 {
101 type,
102 at,
103 prompt,
104 outcome,
105 skill: isString(skill) ? skill : null,
106 skills: Number(row.skills),
107 latencyMs: Number(row.latencyMs),
108 inputTokens: Number(row.inputTokens),
109 outputTokens: Number(row.outputTokens),
110 cacheReadTokens: Number(row.cacheReadTokens),
111 },
112 ];
113 }
114
115 const fate = FATES.find((one) => one === type);
116
117 return fate !== undefined && isString(skill)
118 ? [{ type: fate, at, prompt, skill }]
119 : [];
120}
121
122function isJsonObject(value: Json): value is JsonObject {
123 return value === Object(value) && !Array.isArray(value);
124}
125
126function isNumber(value: Json | undefined): value is number {
127 return Number.isFinite(value);
128}
129
130function isString(value: Json | undefined): value is string {
131 return value === String(value);
132}
133
134/** A short, stable name for a system prompt, so results compare across prompt changes. */
135export async function promptVersion(system: string): Promise<string> {
136 const digest = await crypto.subtle.digest(
137 "SHA-256",
138 new TextEncoder().encode(system),
139 );
140
141 return [...new Uint8Array(digest).slice(0, 4)]
142 .map((byte) => byte.toString(16).padStart(2, "0"))
143 .join("");
144}
145
146export function summarize(
147 installId: string,
148 sessions: readonly (readonly NudgeEvent[])[],
149): Summary {
150 const events = sessions.flat().sort((a, b) => a.at - b.at);
151 const judgments = { total: 0, nudge: 0, none: 0, error: 0, stale: 0 };
152 const tokens = { input: 0, output: 0, cacheRead: 0 };
153 const tips = emptyFates();
154 const bySkill: Record<string, Fates> = {};
155 const byPrompt: Record<string, Fates & { judged: number }> = {};
156 let latency = 0;
157
158 for (const event of events) {
159 const prompt = (byPrompt[event.prompt] ??= { judged: 0, ...emptyFates() });
160
161 if (event.type === "judged") {
162 judgments.total += 1;
163 judgments[event.outcome] += 1;
164 prompt.judged += 1;
165 latency += event.latencyMs;
166 tokens.input += event.inputTokens;
167 tokens.output += event.outputTokens;
168 tokens.cacheRead += event.cacheReadTokens;
169
170 if (event.outcome !== "nudge" || event.skill === null) continue;
171
172 tips.shown += 1;
173 prompt.shown += 1;
174 (bySkill[event.skill] ??= emptyFates()).shown += 1;
175 continue;
176 }
177
178 tips[event.type] += 1;
179 prompt[event.type] += 1;
180 (bySkill[event.skill] ??= emptyFates())[event.type] += 1;
181 }
182
183 return {
184 installId,
185 sessions: sessions.filter((one) => one.length > 0).length,
186 from: dateOf(events.at(0)),
187 to: dateOf(events.at(-1)),
188 judgments,
189 averageLatencyMs:
190 judgments.total === 0 ? 0 : Math.round(latency / judgments.total),
191 tokens,
192 tips,
193 bySkill,
194 byPrompt,
195 };
196}
197
198export function report(summary: Summary): string {
199 const { judgments, tips } = summary;
200
201 if (judgments.total === 0) return "Skill Nudge has not judged a turn yet.";
202
203 const taken = tips.used + tips.typed;
204
205 const skills = Object.entries(summary.bySkill)
206 .sort(([, a], [, b]) => b.shown - a.shown)
207 .map(
208 ([skill, fates]) =>
209 ` /${skill}: shown ${fates.shown}, taken ${fates.used + fates.typed}, dismissed ${fates.dismissed}, ignored ${fates.ignored}`,
210 );
211
212 return [
213 `Skill Nudge, ${summary.from} to ${summary.to} (${summary.sessions} sessions)`,
214 `Judgments: ${judgments.total} (${judgments.nudge} tips, ${judgments.none} quiet, ${judgments.error} errors, ${judgments.stale} too late), ${summary.averageLatencyMs} ms average`,
215 `Tips: ${tips.shown} shown, ${taken} taken (${percent(taken, tips.shown)}), ${tips.dismissed} dismissed, ${tips.ignored} ignored`,
216 ...skills,
217 ].join("\n");
218}
219
220function dateOf(event: NudgeEvent | undefined): string | null {
221 return event === undefined
222 ? null
223 : new Date(event.at).toISOString().slice(0, 10);
224}
225
226function percent(part: number, whole: number): string {
227 return whole === 0 ? "0%" : `${Math.round((part / whole) * 100)}%`;
228}
229types/index.d.ts 13 lines1// `asksClaude`: the skill is hidden from the `/` menu, so Use asks Claude to run it.
2export type Nudge = { skill: string; reason: string; asksClaude: boolean };
3
4declare module "claude-code" {
5 interface PluginState {
6 "skill-nudge": {
7 nudge: Nudge | null;
8 offered: string[];
9 turnsSinceJudgment: number;
10 };
11 }
12}
13