Teaching example: count successful Read events.

Try from the kit root: claude --plugin-dir ./templates/starter-mod. Ask Claude to read a file, then run /readcount. It prints successful reads seen since this module's session start. Reloading may reset this simple in-memory counter. Exit that session to unload. Rename the plugin and command before turning this into another plugin. It is not in the kit marketplace.
hooks/starter.mjs 17 lines1// Minimal teaching example. Counter is scoped to this module instance.
2export function register(on) {
3 let count = 0;
4 on("session.start", async ($, e, next) => {
5 const result = await next(e);
6 count = 0;
7 await $.command.register({ name: "readcount", description: "Show successful reads observed by this example" });
8 return result;
9 });
10 on("tool.call", { tool: "Read" }, async ($, e, next) => {
11 const result = await next(e);
12 if (!result.isError && result.deny === undefined) count += 1;
13 return result;
14 });
15 on("command.run", { command: "readcount" }, async () => ({ text: `Successful reads observed: ${count}` }));
16}
17