ModsCode / Claude Code Mods / Ranking / turn-profiler
turn-profiler
A performance profiler for Claude's turns: a live waterfall of every model request and tool call, how much went to approvals, and the fixes that win the time back
What it does
- Draws a band above the prompt, a pane, toasts
- Adds /profile
- Watches tool calls
- Hooks classic.PermissionRequest, classic.PostToolUse, classic.PostToolUseFailure, session.start and 3 more
Good points
- No network calls
- Starts no processes
- Written in TypeScript
- Has a desktop-specific branch
Code to start from
A starter ModsCode writes from the drawing it read, and the mod's own lines that draw, where there are any.
Starter (register.tsx)
import type { Register } from 'claude-code'
// Drawn like turn-profiler by brahim1o1 (pane, band, toast), as ModsCode read it from the mod's code:
// https://modscode.com/claude-mods/mods/brahim1o1-turn-profiler/
// Written by ModsCode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
// the band above the prompt; what else goes there is drawn under it
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const { Box, Text, Button } = $.ui.resolve(e)
const NAME = '…'
const p = '…'
const NAME2 = '…'
const p2 = '…'
const NAME3 = '…'
const p3 = '…'
const spark = '…'
const text = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row" gap={1}>
<Text bold>
{"⏱ "}
0
</Text>
<Text>
<Text>
████████
</Text>
<Text>
████████
</Text>
<Text>
████████
</Text>
</Text>
<Text>
<Text>
{" · "}
<Text>
{NAME}
</Text>
<Text dimColor>
{" "}
{p}
%
</Text>
</Text>
<Text>
{" · "}
<Text>
{NAME2}
</Text>
<Text dimColor>
{" "}
{p2}
%
</Text>
</Text>
<Text>
{" · "}
<Text>
{NAME3}
</Text>
<Text dimColor>
{" "}
{p3}
%
</Text>
</Text>
</Text>
<Text dimColor>
{spark}
</Text>
<Button label="Profile" />
<Button label="Hide" />
</Box>
<Box flexDirection="row" gap={1}>
<Text dimColor wrap="truncate-end">
{"↳ "}
{text}
</Text>
<Button label="Copy rule" />
</Box>
{await next(e)}
</Box>
)
})
// the pane: open it with $.ui.open({ id: 'my-pane', title: "Turn profiler" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Button, Svg } = $.ui.resolve(e)
const prompt = '…'
const fmtMs = '…'
const models = '…'
const tools = '…'
const out = '…'
const droppedSpans = '…'
const NAME = '…'
const p = '…'
const NAME2 = '…'
const p2 = '…'
const NAME3 = '…'
const p3 = '…'
const text = '…'
const text2 = '…'
const text3 = '…'
const source = '…'
const length = '…'
const hidden = '…'
const name = '…'
const calls = '…'
const fmtMs2 = '…'
const fmtMs3 = '…'
const failed = '…'
const name2 = '…'
const calls2 = '…'
const fmtMs4 = '…'
const fmtMs5 = '…'
const failed2 = '…'
const name3 = '…'
const calls3 = '…'
const fmtMs6 = '…'
const fmtMs7 = '…'
const failed3 = '…'
return (
<Box flexDirection="column" gap={1}>
<Box flexDirection="column" gap={1}>
<Box flexDirection="row" gap={1}>
<Text bold color="success">
● live
</Text>
<Text dimColor wrap="truncate-end">
“
{prompt}
”
</Text>
<Button label={`‹ Prev`} />
<Button label="Next ›" />
<Button label="Latest" />
</Box>
<Box flexDirection="column">
<Text>
<Text bold>
{fmtMs}
</Text>
<Text dimColor>
{" so far"}
</Text>
<Text color="warning">
{" interrupted"}
</Text>
<Text dimColor>
{" "}
{"· "}
{models}
{" model request"}
{" · "}
{tools}
{" tool call"}
{` · ${out} output tokens`}
{` · ${droppedSpans} spans over the cap`}
</Text>
</Text>
<Box flexDirection="row" gap={1}>
<Text>
<Text>
████████
</Text>
<Text>
████████
</Text>
<Text>
████████
</Text>
</Text>
<Text>
<Text>
{" · "}
<Text>
{NAME}
</Text>
<Text dimColor>
{" "}
{p}
%
</Text>
</Text>
<Text>
{" · "}
<Text>
{NAME2}
</Text>
<Text dimColor>
{" "}
{p2}
%
</Text>
</Text>
<Text>
{" · "}
<Text>
{NAME3}
</Text>
<Text dimColor>
{" "}
{p3}
%
</Text>
</Text>
</Text>
</Box>
</Box>
<Box flexDirection="column">
<Box flexDirection="row" gap={1}>
<Text color="warning">
▲
</Text>
<Text wrap="wrap">
{text}
</Text>
<Button label="Copy rule" />
</Box>
<Box flexDirection="row" gap={1}>
<Text color="warning">
▲
</Text>
<Text wrap="wrap">
{text2}
</Text>
<Button label="Copy rule" />
</Box>
<Box flexDirection="row" gap={1}>
<Text color="warning">
▲
</Text>
<Text wrap="wrap">
{text3}
</Text>
<Button label="Copy rule" />
</Box>
</Box>
</Box>
<Box flexDirection="column">
<Text dimColor>
<Text color="merged">
█
</Text>
{" model "}
<Text color="merged" dimColor>
░
</Text>
{" to first token"}
{" "}
<Text color="suggestion">
█
</Text>
{" tool "}
<Text color="warning">
█
</Text>
{" approval "}
<Text color="error">
█
</Text>
{" failed"}
</Text>
<Svg source={`${source}`} alt={`Waterfall of ${length} model requests and tool calls over ${fmtMs}`} isInteractive />
<Text dimColor>
+
{hidden}
{" shorter spans not drawn"}
</Text>
</Box>
<Box flexDirection="column" gap={1}>
<Box flexDirection="column">
<Box flexDirection="row">
<Box width={16}>
<Text dimColor>
tool
</Text>
</Box>
<Box width={8}>
<Text dimColor>
calls
</Text>
</Box>
<Box width={10}>
<Text dimColor>
total
</Text>
</Box>
<Box width={10}>
<Text dimColor>
slowest
</Text>
</Box>
<Text dimColor>
failed
</Text>
</Box>
<Box flexDirection="row">
<Box width={16}>
<Text wrap="truncate-end">
{name}
</Text>
</Box>
<Box width={8}>
<Text>
{calls}
</Text>
</Box>
<Box width={10}>
<Text>
{fmtMs2}
</Text>
</Box>
<Box width={10}>
<Text>
{fmtMs3}
</Text>
</Box>
<Text color="error">
{failed}
</Text>
</Box>
<Box flexDirection="row">
<Box width={16}>
<Text wrap="truncate-end">
{name2}
</Text>
</Box>
<Box width={8}>
<Text>
{calls2}
</Text>
</Box>
<Box width={10}>
<Text>
{fmtMs4}
</Text>
</Box>
<Box width={10}>
<Text>
{fmtMs5}
</Text>
</Box>
<Text color="error">
{failed2}
</Text>
</Box>
<Box flexDirection="row">
<Box width={16}>
<Text wrap="truncate-end">
{name3}
</Text>
</Box>
<Box width={8}>
<Text>
{calls3}
</Text>
</Box>
<Box width={10}>
<Text>
{fmtMs6}
</Text>
</Box>
<Box width={10}>
<Text>
{fmtMs7}
</Text>
</Box>
<Text color="error">
{failed3}
</Text>
</Box>
</Box>
<Box flexDirection="row" gap={1}>
<Button label="Export trace" />
<Button label="Show band" />
<Text dimColor>
Export opens in ui.perfetto.dev
</Text>
</Box>
</Box>
</Box>
)
})
on('session.start', async ($, e, next) => {
const text = '…'
const line = '…'
await $.ui.toast(`Copied ${text}`)
await $.ui.toast(`${line}. ${text}`)
return next(e)
})
}
The mod's own code
Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.
hooks/register.tsx lines 296–314 · Band
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (e.props.hasSurvey || e.props.isWorking || (await read($, isBandHidden))) return next(e)
const list = await read($, turns)
const last = list[list.length - 1]
if (last === undefined || (last.durationMs ?? 0) < bandMinMs) return next(e)
const now = last.durationMs ?? 0
const els = $.ui.resolve(e)
return BandView(els, {
turn: last,
breakdown: breakdown(last, now),
insight: insights(last, list.slice(0, -1), now)[0],
spark: sparkline(list.slice(-12).map(t => t.durationMs ?? 0)),
columns: e.props.bodyColumns,
onOpen: () => void $.ui.open({ id: PANE, title: 'Turn profiler' }),
onHide: () => void update($, isBandHidden, () => true),
onCopy: rule => void copy($, rule),
})
})hooks/views.tsx lines 72–97 · Band
export function BandView(els: Els, d: BandData) {
const { Box, Text, Button } = els
const isNarrow = d.columns < 80
return (
<Box flexDirection="column">
<Box flexDirection="row" gap={1}>
<Text bold>⏱ {fmtMs(d.turn.durationMs ?? 0)}</Text>
{StackBar(els, d.breakdown, isNarrow ? 10 : 16)}
{Legend(els, d.breakdown, isNarrow)}
{!isNarrow && d.spark.length > 1 && <Text dimColor>{d.spark}</Text>}
<Button key="open" label="Profile" onPress={d.onOpen} />
<Button key="hide" label="Hide" onPress={d.onHide} />
</Box>
{d.insight !== undefined && (
<Box flexDirection="row" gap={1}>
<Text dimColor wrap="truncate-end">
↳ {d.insight.text}
</Text>
{d.insight.rule !== undefined && (
<Button key="copy-rule" label="Copy rule" onPress={() => d.onCopy(d.insight!.rule!)} />
)}
</Box>
)}
</Box>
)
}hooks/views.tsx lines 34–43 · Band
function StackBar({ Text }: Els, b: Breakdown, width: number) {
const n = cells(b, width)
return (
<Text>
{ORDER.filter(c => n[c] > 0).map(c => (
<Text color={THEME[c]}>{'█'.repeat(n[c])}</Text>
))}
</Text>
)
}hooks/views.tsx lines 45–59 · Band
function Legend({ Text }: Els, b: Breakdown, isShort: boolean) {
const p = percentages(b)
const shown = ORDER.filter(c => p[c] > 0 && (c !== 'other' || !isShort))
return (
<Text>
{shown.map((c, i) => (
<Text>
{i > 0 ? ' · ' : ''}
<Text color={THEME[c]}>{NAME[c]}</Text>
<Text dimColor> {p[c]}%</Text>
</Text>
))}
</Text>
)
}hooks/register.tsx lines 316–380 · Pane
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
const { turn, index, list, isLive } = await shown($)
const els = $.ui.resolve(e)
if (turn === null) return Empty(els)
if (isLive) await read($, tick)
const now = turn.durationMs ?? (await $.clock.now()) - turn.startedAt
const columns = e.props.bodyColumns
const rows = Math.max(6, (e.viewport?.rows ?? 40) - 18)
const ids = list.map(t => t.id)
const go = (id: string | null) => () => void update($, viewing, () => id)
const data = {
turn,
isLive,
position: { index, count: list.length },
breakdown: breakdown(turn, now),
insights: insights(turn, list.slice(0, Math.max(0, index)), now),
now,
columns,
isBandHidden: await read($, isBandHidden),
onPrev: go(ids[Math.max(0, index - 1)] ?? null),
onNext: go(index + 1 < ids.length ? ids[index + 1]! : null),
onLatest: go(null),
onExport: () => void exportTrace($).then(text => $.ui.toast(text)),
onToggleBand: () => void update($, isBandHidden, h => !h),
onCopy: (rule: string) => void copy($, rule),
}
const { Box } = els
if (e.surface === 'terminal') {
return (
<Box flexDirection="column" gap={1}>
{PaneHead(els, data)}
<Box flexDirection="column">
{Legendary(els)}
{WaterfallText(els, turn.spans, now, now, columns, rows)}
</Box>
{PaneFoot(els, data)}
</Box>
)
}
const { Svg } = $.ui.resolve(e)
const width = Math.max(360, Math.min(1200, Math.round(columns * 7.6)))
const chart = waterfallSvg(turn.spans, now, now, width, rows + 10)
return (
<Box flexDirection="column" gap={1}>
{PaneHead(els, data)}
{turn.spans.length > 0 && (
<Box flexDirection="column">
{Legendary(els)}
<Svg
source={chart.source}
alt={`Waterfall of ${turn.spans.length} model requests and tool calls over ${fmtMs(now)}`}
width={width}
height={chart.height}
isInteractive
/>
{chart.hidden > 0 && <els.Text dimColor>+{chart.hidden} shorter spans not drawn</els.Text>}
</Box>
)}
{PaneFoot(els, data)}
</Box>
)
})hooks/views.tsx lines 375–377 · Pane
export function Empty({ Text }: Els) {
return <Text dimColor>No turn profiled yet. Send a prompt and this pane fills in while Claude works.</Text>
}Licence text (MIT)
MIT License Copyright (c) 2026 brahim1o1 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
How to build this: Pane (panel), Deny a tool call
What its code calls
writes filesenv varstool calls
What its code shows
Read from the source at commit d48e604dfb43. The first group decides whether a mod is listed; the rest is for you to weigh. A later commit is not read until the next crawl.
| Decides the listing: code you can check | |
|---|---|
| Entry read | Every module hooks/hooks.json names was read.hooks/register.tsx |
| Parses | Every file parses as TypeScript or JavaScript.3 files parsed |
| All its code is in the mod | Every import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod |
| Readable | No minified lines, no eval or new Function, no import of a computed path, no encoded blobs.no minified code, no eval, no encoded blobs |
| Calls in the open | Network and programs are reached as $.http.fetch and $.process.run in place, never passed around.every call outside goes through $ in the open |
| For you to weigh before installing | |
| Where it draws | The terminal, the desktop app, both, or nothing (hooks only: a guard or a prompt rewriter), as its code says. Shown, never a reason to leave a mod out.draws in the terminal and the desktop app, the same in both |
| Install line | Whether its repository's own .claude-plugin/marketplace.json lists it, so it installs from that marketplace with the lines on its page.listed in its repository's .claude-plugin/marketplace.json: installs from there |
| Programs on Windows | Whether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks |
| Network | Whether every fetch names its https host in the code.no network |
| Programs | Whether every program it starts is named in the code and is not a shell, an interpreter or a network tool.starts no programs |
| Reads and sends | Whether it both reads something of yours (files, environment variables, the transcript, settings) and reaches outside (the network, an MCP server, another session, telemetry).reads environment variables, files, but reaches nothing outside |
| Keys in the source | Whether the source holds what looks like an API key or a private key.no keys in the source |
| Licence | An open licence (MIT, Apache-2.0, BSD, ISC, Unlicense, 0BSD, CC0) with its text lets ModsCode show its code; otherwise the code is linked.MIT |
| Settings hooks | Hooks declared in hooks/hooks.json or plugin.json beside the module: a command (a shell when it has no args), an HTTP request, an MCP tool or a model prompt at an event. They run outside $.no settings hooks: its function hooks alone |
| Servers it ships | MCP servers (a program, or a URL; a headersHelper is a shell command; a .mcpb bundle is unpacked at run time), LSP servers, monitors (a shell command for the whole session) and bin/ (on the PATH of the Bash tool).ships no MCP or LSP server, no monitor, no bin/ |
| Skills, commands, agents | What its Markdown declares beyond text: allowed-tools granted for the turn, hooks added when a skill is invoked, a command run before Claude reads the skill.no skills, commands, agents or workflows |
| Tools and MCP | Whether every tool it calls through $.tool.call and $.mcp.call is named in the code, and none is a shell (Bash through the tool runs a shell without $.process).calls no tool, MCP server or command |
| Asks of the model | Completions it runs ($.model.complete, fork, classify), subagents it spawns, prompts it submits as you, and the tools, commands and agents it adds.adds command profile, adds tool ? |
| Events it hooks | By what a hook there can do: gates (refuse a tool call, a prompt, a setting, another plugin), shapes (what the model reads: the system prompt, tool descriptions, each request), reads (your input, the events of the settings hooks, every event with *), and the rest.gates: tool.call, classic.PermissionRequest, command.run (profile) · shapes: turn.step · reads: classic.PostToolUse, classic.PostToolUseFailure · also: session.start, turn.start, turn.complete, ui.render (AbovePrompt, Pane) · timers: clock.every |
| Reads, by name | The environment variables and files it names, and whether it reads the transcript, settings.json, the prompt box or the mouse selection.env: HOME |
| Writes, by name | The files and environment variables it names, and whether it changes settings, the prompt box, the clipboard, the conversation (a row the model reads) or another session.files: …/.claude/turn-profiler/….trace.json; the clipboard |
This is a reading of the code text, not a security review: it does not run the mod, and it cannot see what a program the mod starts does. The check before installing is yours. How mods are chosen
Install it
Check it yourself before you install it. Mods run unsandboxed, with your permissions, and ModsCode does not vouch for what this code does. Read its code (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.
From its marketplace
Its repository is its marketplace. Add that marketplace (in the terminal with these commands, or in the desktop app's plugin settings) and install the mod from it:
/plugin marketplace add brahim1o1/claude-turn-profiler/plugin install turn-profiler@claude-turn-profiler/reload-pluginsThis installs the marketplace's latest commit, which may not be the one read here (d48e604dfb43). Compare them before you install. /reload-plugins loads it into a session that is already open.
Try the commit ModsCode read
No marketplace needed. In a terminal, clone the repository, check out the commit read, validate the mod, and load it for one session:
git clone https://github.com/brahim1o1/claude-turn-profilergit -C claude-turn-profiler checkout d48e604dfb439aa070877e8f285ea88096df0dcfclaude plugin validate claude-turn-profilerclaude --plugin-dir claude-turn-profilerThe validate line lists the events the mod hooks and what it asks Claude Code to do, without running it. The last line loads the mod for this session only and writes nothing to your settings. If the author has rewritten history, the commit may no longer exist.
Ask Claude or ChatGPT about it
With ModsCode added as a connector, Claude or ChatGPT can read this mod's code, what it reaches and how its controls are wired, and build on them. Ask it like this:
Read the ModsCode mod "brahim1o1-turn-profiler" with its code and make me one like itAdd the ModsCode MCP to Claude or ChatGPT
Similar mods
- explain-asSumit Paul★ 20
- uploadsBuild Internet★ 18
- ccprogressamigoer★ 14
- flow-scenesRob Macrae★ 11
- laurelsKOZMOS★ 9
- spending-effort-with-jevYaxin Luo★ 6
Badge for your README
If this is your mod, paste this into your README. It links to this page.
[](https://modscode.com/claude-mods/mods/brahim1o1-turn-profiler/)