modscode / Gallery / context-xray
context-xray
A pane with the exact breakdown of what fills Claude's context: system prompt, tools, memory files, skills, messages, and which tools load on every request.
What it does
- Draws a pane
- Adds /xray
- Hooks session.start
Good points
- No network calls
- Starts no processes
- Small: 257 lines
- Written in TypeScript
Code to start from
Two kinds: a starter modscode writes from the design above, and the lines of the mod's own code that draw it.
Starter (register.tsx)
import type { Register } from 'claude-code'
// Drawn like context-xray by Vedant Andhale (pane), as modscode read it from the mod's code:
// https://modscode.com/gallery/vedantandhale-context-xray/
// 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 pane: open it with $.ui.open({ id: 'my-pane', title: "Context X-ray" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Button } = $.ui.resolve(e)
const model = '…'
const failed = '…'
const tokens = '…'
const percentage = '…'
const note = '…'
const name = '…'
const pct = '…'
const name2 = '…'
const tokens2 = '…'
const pct2 = '…'
const name3 = '…'
const tokens3 = '…'
const pct3 = '…'
const name4 = '…'
const tokens4 = '…'
const pct4 = '…'
const name5 = '…'
const tokens5 = '…'
const pct5 = '…'
const name6 = '…'
const tokens6 = '…'
const pct6 = '…'
const length = '…'
const mcpDeferredCount = '…'
const shortTool = '…'
const tokens7 = '…'
const pct7 = '…'
const shortTool2 = '…'
const tokens8 = '…'
const pct8 = '…'
const shortTool3 = '…'
const tokens9 = '…'
const pct9 = '…'
const note2 = '…'
const baseName = '…'
const tokens10 = '…'
const pct10 = '…'
const baseName2 = '…'
const tokens11 = '…'
const pct11 = '…'
const baseName3 = '…'
const tokens12 = '…'
const pct12 = '…'
const note3 = '…'
const included = '…'
const total = '…'
const tokens13 = '…'
const pct13 = '…'
const tokens14 = '…'
const pct14 = '…'
const tokens15 = '…'
const pct15 = '…'
const tokens16 = '…'
const pct16 = '…'
const tokens17 = '…'
const pct17 = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row" justifyContent="space-between" alignItems="flex-start">
<Box flexDirection="column" flexShrink={1}>
<Text dimColor wrap="truncate-end">
Measuring…
</Text>
<Text dimColor wrap="truncate-end">
{model}
</Text>
</Box>
<Button label="Refresh" hotkey="r" />
</Box>
<Text color="error">
{failed}
</Text>
<Box flexDirection="row" flexWrap="wrap" marginTop={1}>
<Text bold>
{`${tokens} `}
</Text>
<Text dimColor>
{`of ${tokens} tokens`}
</Text>
<Text dimColor>
{` · ${percentage}% full`}
</Text>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text bold wrap="truncate-end">
Sent with every request
</Text>
<Text dimColor wrap="truncate-end">
{note}
</Text>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{name}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{name2}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens2}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct2}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{name3}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens3}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct3}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text bold wrap="truncate-end">
Loaded on demand
</Text>
<Text dimColor wrap="truncate-end">
listed by name, schema fetched when used
</Text>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{name4}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens4}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct4}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{name5}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens5}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct5}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{name6}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens6}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct6}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text bold wrap="truncate-end">
MCP tools loaded every request
</Text>
<Text dimColor wrap="truncate-end">
{`${length} loaded · ${mcpDeferredCount} on demand`}
</Text>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{shortTool}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens7}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct7}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{shortTool2}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens8}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct8}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{shortTool3}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens9}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct9}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text bold wrap="truncate-end">
Memory files
</Text>
<Text dimColor wrap="truncate-end">
{note2}
</Text>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{baseName}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens10}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct10}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{baseName2}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens11}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct11}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{baseName3}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens12}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct12}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text bold wrap="truncate-end">
Listings
</Text>
<Text dimColor wrap="truncate-end">
{note3}
</Text>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{`Skills (${included}/${total})`}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens13}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct13}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{`Commands (${included}/${total})`}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens14}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct14}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{`Agent: ${name}`}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens15}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct15}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{`Agent: ${name}`}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens16}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct16}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" alignItems="center">
<Box flexShrink={0}>
<Text wrap="truncate-end">
{`Agent: ${name}`}
</Text>
</Box>
<Box width={10} flexShrink={0} justifyContent="flex-end">
<Text bold>
{tokens17}
</Text>
</Box>
<Box width={7} flexShrink={0} justifyContent="flex-end">
<Text dimColor>
{pct17}
</Text>
</Box>
<Box marginLeft={1}>
<Text color="claude">
━━━━━━━━────────
</Text>
</Box>
</Box>
<Box flexDirection="row" marginTop={1}>
<Text dimColor>
{`Free ${tokens} · compaction buffer ${tokens}`}
</Text>
</Box>
</Box>
)
})
}
The mod's own code
Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.
plugins/context-xray/hooks/register.tsx lines 112–222 · Pane
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
const { Box, Text, Button } = $.ui.resolve(e)
const s = await read($, snapshot)
const busy = await read($, isMeasuring)
const failed = await read($, error)
const now = await $.clock.now()
const svg = e.surface !== 'terminal' && e.surface !== 'mobile'
const Svg = svg ? $.ui.resolve(e).Svg : undefined
// Columns sized to the pane: label, figure, share, then the bar in what is
// left, so a narrow pane shrinks the bar and never cuts a figure.
const cols = e.props.bodyColumns
const NUM = 10
const PCT = 7
const labelWidth = Math.max(10, Math.min(26, Math.floor(cols * 0.42)))
const barCells = cols - labelWidth - NUM - PCT - 1
const bar = (part: number, whole: number, fill = BAR_FILL) => {
if (barCells < 4) return null
return Svg ? (
<Box flexGrow={1} flexShrink={1} marginLeft={1}>
<Svg source={barSvg(part, whole, fill)} alt={pct(part, whole)} height={BAR_HEIGHT} />
</Box>
) : (
<Box marginLeft={1}>
<Text color={fill === BAR_FILL ? 'claude' : undefined} dimColor={fill !== BAR_FILL}>
{textBar(part, whole, Math.min(20, barCells))}
</Text>
</Box>
)
}
const row = (key: string, label: string, part: number, whole: number, fill?: string) => (
<Box key={key} flexDirection="row" alignItems="center">
<Box width={labelWidth} flexShrink={0}>
<Text wrap="truncate-end">{label}</Text>
</Box>
<Box width={NUM} flexShrink={0} justifyContent="flex-end">
<Text bold>{tokens(part)}</Text>
</Box>
<Box width={PCT} flexShrink={0} justifyContent="flex-end">
<Text dimColor>{pct(part, whole)}</Text>
</Box>
{bar(part, whole, fill)}
</Box>
)
const heading = (text: string, note?: string) => (
<Box flexDirection="column" marginTop={1}>
<Text bold wrap="truncate-end">{text}</Text>
{note && <Text dimColor wrap="truncate-end">{note}</Text>}
</Box>
)
const header = (
<Box flexDirection="row" justifyContent="space-between" alignItems="flex-start">
<Box flexDirection="column" flexShrink={1}>
<Text dimColor wrap="truncate-end">
{busy ? 'Measuring…' : s ? `Measured ${Math.max(0, Math.round((now - s.at) / 1000))}s ago` : ''}
</Text>
{s && <Text dimColor wrap="truncate-end">{s.model}</Text>}
</Box>
<Button key="refresh" label="Refresh" hotkey="r" onPress={() => measure($)} />
</Box>
)
if (!s) {
return (
<Box flexDirection="column">
{header}
<Text dimColor>{failed ?? 'Measuring the context window…'}</Text>
</Box>
)
}
const used = s.totalTokens
return (
<Box flexDirection="column">
{header}
{failed && <Text color="error">{failed}</Text>}
<Box flexDirection="row" flexWrap="wrap" marginTop={1}>
<Text bold>{`${tokens(used)} `}</Text>
<Text dimColor>{`of ${tokens(s.maxTokens)} tokens`}</Text>
<Text dimColor>{` · ${s.percentage}% full`}</Text>
</Box>
{heading('Sent with every request')}
{s.used.map(c => row(`u:${c.name}`, c.name, c.tokens, used))}
{s.deferred.length > 0 && heading('Loaded on demand', 'listed by name, schema fetched when used')}
{s.deferred.map(c => row(`d:${c.name}`, c.name, c.tokens, used, BAR_DEFERRED))}
{s.mcpLoaded.length > 0 &&
heading('MCP tools loaded every request', `${s.mcpLoaded.length} loaded · ${s.mcpDeferredCount} on demand`)}
{s.mcpLoaded.slice(0, TOP).map((t: XrayRow & { server: string }) => row(`m:${t.name}`, shortTool(t.name, t.server), t.tokens, used))}
{s.memoryFiles.length > 0 && heading('Memory files')}
{s.memoryFiles.map(f => row(`f:${f.name}`, baseName(f.name), f.tokens, used))}
{(s.skills || s.commands || s.agents.length > 0) && heading('Listings')}
{s.skills && row('skills', `Skills (${s.skills.included}/${s.skills.total})`, s.skills.tokens, used)}
{s.commands && row('commands', `Commands (${s.commands.included}/${s.commands.total})`, s.commands.tokens, used)}
{s.agents.slice(0, TOP).map(a => row(`a:${a.name}`, `Agent: ${a.name}`, a.tokens, used))}
<Box flexDirection="row" marginTop={1}>
<Text dimColor>{`Free ${tokens(s.free)} · compaction buffer ${tokens(s.buffer)}`}</Text>
</Box>
</Box>
)
})Licence text (MIT)
MIT License Copyright (c) 2026 Vedant Andhale 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.
What its code calls
nothing found
The design, read from code
Drawn from the mod's source at the commit read, not from a run: a list is drawn three times, a condition takes its first branch that draws in the desktop app, and a value only the run time knows is shown as a made-up sample (dotted underline) or left out. Colours and type are this site's.
What its code shows
Read from the source at commit 316522ef1a4d on 2026-10-06. 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.plugins/context-xray/hooks/register.tsx |
| Parses | Every file parses as TypeScript or JavaScript.1 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 files or environment variables and reaches the network.reaches no network |
| 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 |
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 the code below (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.
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 VedantAndhale/claude-pro-kit/plugin install context-xray@claude-pro-kitThis installs the marketplace's latest commit, which may not be the one read here (316522ef1a4d). Compare them before you install.
Ask Claude about it
With the modscode connector added, Claude can read this design, what its code reaches and its code, and build on them. Ask it like this:
Read the modscode design "vedantandhale-context-xray" with its code and make me a pane like itSearch them from Claude: the MCP connector
Similar designs
-
Ask Claude…Approved appsApproved appsComputer use can control these apps without asking.High riskAlways allowed (3)None. Allow one below.Not installed (3)This conversation (3)None.Allow an app App name, bundle id or path allowbuilda1b2c3dbuilda1b2c3dbuilda1b2c3d
-
Ask Claude…AgentsFix loginExpand≈$1.24 · 12.4k tokens · 2h 10mNo subagents yet.Running · 3▸ Finished · 3Planned · 3▢ 3. Fix login ◷ Plan · · after Planned▢ 3. Fix login ◷ Plan · · after Planned▢ 3. Fix login ◷ Plan · · after Planned
-
Ask Claude…Fix loginRemoveCopy markdownacme/app · mainCopy linkCopy markdownbuild2h 10mbuild2h 10mbuild2h 10mHosted on uploads.sh, not committed to the repo.They will appear in a comment on the pull request once opened.
-
What it does
- Draws a band above the prompt, a pane
- Adds /progress
- Watches tool calls and can refuse them
- Hooks classic.SessionStart, prompt.compose, prompt.submit, session.start and 2 more
-
Ask Claude…Skins0 Your promptadd rate limiting to the hub api0 Tool rows: finished, running, failedYour prompt Spinner0 Folded group of reads and searches●main · note 3 · note 3 · note 30 Edit diff cardDesktop only; the terminal keeps Claude Code's diff.0 Shell output cardDesktop only.0 Code block cardDesktop only; the terminal keeps Claude Code's markdown.0 TableAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopyAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopyAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopy0 SpinnerAccent SpinnerSpinnerSpinner… 2h 10m0 Band above the prompt: normal, then nudging to compact█████░░░ 42% build█████░░░ 42% build█████░░░ 42% buildContext is 42% full0 Compact now0 Band above a questionTable BashBashBash0 Turn footer (terminal)3 build in 2h 10m · Grep · +3 −3
-
spending-effort-with-jev: no TypeSafe API key, so effort tips are off. Set it in /plugin.⚠ effort: long run, fuzzy spec → have Claude interview you, then go maxAsk Claude…