Measure observed tool latency, call counts, and failures.

Measure observed tool latency, call counts, and failures.
Use it when: Find tools that slow down a session.

Screenshot of this mod's render tree in the fixture preview, with sample data. This is not a capture of the Claude Code application. How previews are made.
claude plugin marketplace add whyashthakker/awesome-claude-code-mods
claude plugin install tool-timing@awesome-claude-code-mods
Run /reload-plugins in an existing session, then /tool-timing. Use Tab and Enter to operate controls; Esc closes the pane. Terminal and Desktop Code tab supported; pane UI is unavailable in claude -p and the VS Code chat panel.
Try the source without installing:
claude --plugin-dir ./mods/tool-timing
Observes tool names, results, and clock; does not store arguments.
Module variables reset on hot reload. Diagnostic history begins when the mod loads and lasts until reload or process exit; it does not reconstruct earlier activity. All display output is bounded; viewers may truncate long content to 9,000 characters. Relative file paths and Git commands use the session working directory.
Tested with Claude Code 2.1.288. Minimum documented mods version: 2.1.287. The API can change; validate against your installed version.
claude plugin validate mods/tool-timing --strict
claude plugin test mods/tool-timing
Tests cover plugin commands, pane isolation, both UI surfaces, and the behavior described in tests/register.test.ts. Drawing tests validate element trees; they do not verify pixels painted by the native apps. Validation details.
MIT licensed. No runtime packages or build step required.
hooks/register.js 47 lines1import { clean, text, code, row, frame, bar, pretty, bounded, entries, safePath } from './ui.js'
2const ID = "tool-timing"
3let stats = {}
4export function register(on) {
5 on('session.start', async ($, e, next) => {
6
7 await $.command.register({name:ID, description:"Measure observed tool latency, call counts, and failures.", immediate:true, argumentHint:""})
8 return next(e)
9 })
10 on('command.run', {command:"tool-timing"}, async ($, e) => {
11
12 await $.ui.open({id:ID,title:"Tool Timing",focus:true,closeOnEscape:true})
13 return {}
14 })
15
16on('tool.call', async ($, e, next) => {
17 const t = await $.clock.now()
18 try {
19 const r = await next(e)
20 const ms = Math.max(0, (await $.clock.now()) - t)
21 const s = stats[e.tool] || {calls:0,ms:0,failed:0}
22 stats[e.tool] = {calls:s.calls+1,ms:s.ms+ms,failed:s.failed+(r.deny||r.isError ? 1:0)}
23 $.ui.invalidate('ui.render')
24 return r
25 } catch(error) { throw error }
26})
27
28 on('ui.render', {component:'Pane'}, async ($, e, next) => {
29 if(e.requestId !== ID) return next(e)
30 const E = $.ui.resolve(e)
31 try {
32 const body = await draw($, E)
33 return frame(E,"Tool Timing","Measure observed tool latency, call counts, and failures.",body)
34 } catch(error) {
35 return frame(E,"Tool Timing",'Unable to inspect this data.',[text(E,error.message,{color:'yellow'}),E.Button({key:'refresh',label:'Refresh',onPress:()=>$.ui.invalidate('ui.render')})])
36 }
37 })
38}
39async function draw($, E) {
40 const refresh = E.Button({key:'refresh',label:'Refresh',hotkey:'r',plain:true,onPress:()=>$.ui.invalidate('ui.render')})
41
42return [text(E,'Tool calls avg ms failed',{bold:true}),
43 ...Object.entries(stats).sort((a,b)=>b[1].ms-a[1].ms).map(([name,s])=>text(E,name.padEnd(28)+String(s.calls).padEnd(8)+Math.round(s.ms/s.calls).toString().padEnd(9)+s.failed)),
44 ...(Object.keys(stats).length ? [] : [text(E,'No tool calls observed yet.')]),refresh]
45
46}
47hooks/ui.js 36 lines1// Pure UI helpers. No engine access; each plugin contains its own copy.
2export function clean(value, limit = 9000) {
3 return String(value ?? '').replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g, '').slice(0, limit)
4}
5export function text(E, value, props = {}) {
6 return E.Text({ ...props, children: [clean(value)] })
7}
8export function code(E, value, language = 'text') {
9 return E.Code({ source: clean(value), language })
10}
11export function row(E, children) {
12 return E.Box({ flexDirection: 'row', columnGap: 2, flexWrap: 'wrap', children })
13}
14export function frame(E, title, subtitle, children) {
15 return E.Box({ flexDirection: 'column', gap: 1, children: [
16 text(E, title, { bold: true, color: 'cyan' }),
17 text(E, subtitle, { dimColor: true }), ...children,
18 ] })
19}
20export function bar(percent, width = 24) {
21 const p = Math.max(0, Math.min(100, Number(percent) || 0))
22 const n = Math.round(p / 100 * width)
23 return '[' + '#'.repeat(n) + '-'.repeat(width - n) + '] ' + p.toFixed(1) + '%'
24}
25export function pretty(value) { return JSON.stringify(value, null, 2) }
26export function bounded(value, max = 9000) {
27 if (value.length > max) throw new Error('Input exceeds ' + max + ' characters. Use a smaller selection.')
28 return value
29}
30export function entries(value) { return value && typeof value === 'object' ? Object.entries(value) : [] }
31export function safePath(value) {
32 const path = value.trim()
33 if (!path || path.startsWith('-') || /[\x00-\x1f]/.test(path)) throw new Error('Enter a path without control characters or leading flags.')
34 return path
35}
36