Ranking|Claude Code Mods

ModsCode / Claude Code Mods / Ranking / context-bar

context-bar

Your context window as a meter above the prompt: the conversation, the overhead every request carries, and the room left before compaction, with a drill-down into the overhead. Toggle it with /context-bar.

Code you can checkTerminal + desktopPaneBandBoxButtonText
draws, remembers

What it does

  • Draws a band above the prompt, a pane
  • Adds /context-bar
  • Hooks session.attach, session.compact, session.end, session.measure and 2 more
  • Keeps its own state between turns

Good points

  • No network calls
  • Starts no processes
  • Written in TypeScript
  • Handles errors

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)

register.tsx
import type { Register } from 'claude-code'

// Drawn like context-bar by David Lambl (pane, band), as ModsCode read it from the mod's code:
// https://modscode.com/claude-mods/mods/davidlambl-context-bar/
// 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 total = '…'
    const limit = '…'
    const compacts = '…'
    const badge = '…'
    const glyph = '…'
    const glyph2 = '…'
    const glyph3 = '…'
    const label = '…'
    const amount = '…'
    const label2 = '…'
    const amount2 = '…'
    const label3 = '…'
    const amount3 = '…'
    const label4 = '…'
    const amount4 = '…'
    const label5 = '…'
    const amount5 = '…'
    const label6 = '…'
    const amount6 = '…'
    const label7 = '…'
    const amount7 = '…'
    const label8 = '…'
    const amount8 = '…'
    const label9 = '…'
    const amount9 = '…'
    const label10 = '…'
    const amount10 = '…'
    const label11 = '…'
    const amount11 = '…'
    const label12 = '…'
    const amount12 = '…'
    const label13 = '…'
    const amount13 = '…'
    const label14 = '…'
    const amount14 = '…'
    const label15 = '…'
    const amount15 = '…'
    const label16 = '…'
    const amount16 = '…'
    const label17 = '…'
    const amount17 = '…'
    const label18 = '…'
    const amount18 = '…'
    const label19 = '…'
    const amount19 = '…'
    const label20 = '…'
    const amount20 = '…'
    const label21 = '…'
    const amount21 = '…'
    const label22 = '…'
    const amount22 = '…'
    const label23 = '…'
    const amount23 = '…'
    const label24 = '…'
    const amount24 = '…'
    return (
      <Box flexDirection="column">
        <Box justifyContent="space-between">
          <Text>
            <Text color="claude">
              ◆
            </Text>
            {" "}
            <Text bold>
              context
            </Text>
          </Text>
          <Text>
            <Text bold>
              {total}
            </Text>
            <Text dimColor>
              {limit}
              {compacts}
            </Text>
            {" "}
            <Text color="inverseText">
              {badge}
            </Text>
          </Text>
        </Box>
        <Box>
          <Text>
            {glyph}
          </Text>
          <Text>
            {glyph2}
          </Text>
          <Text>
            {glyph3}
          </Text>
        </Box>
        <Box flexDirection="column">
          <Box columnGap={3}>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label}
              {" "}
              <Text bold>
                {amount}
              </Text>
            </Text>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label2}
              {" "}
              <Text bold>
                {amount2}
              </Text>
            </Text>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label3}
              {" "}
              <Text bold>
                {amount3}
              </Text>
            </Text>
          </Box>
          <Box columnGap={3}>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label4}
              {" "}
              <Text bold>
                {amount4}
              </Text>
            </Text>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label5}
              {" "}
              <Text bold>
                {amount5}
              </Text>
            </Text>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label6}
              {" "}
              <Text bold>
                {amount6}
              </Text>
            </Text>
          </Box>
          <Box columnGap={3}>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label7}
              {" "}
              <Text bold>
                {amount7}
              </Text>
            </Text>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label8}
              {" "}
              <Text bold>
                {amount8}
              </Text>
            </Text>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label9}
              {" "}
              <Text bold>
                {amount9}
              </Text>
            </Text>
          </Box>
        </Box>
        <Box flexDirection="column">
          <Box>
            <Text>
              {"  "}
            </Text>
            <Text>
              {label10}
            </Text>
            <Text>
              {"        "}
              <Text color="inactive">
                ▉▉▉▉▉▉▉▉
              </Text>
              {" "}
              <Text bold>
                {amount10}
              </Text>
            </Text>
          </Box>
          <Box flexDirection="column">
            <Box>
              <Text>
                {"        "}
                {label11}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount11}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
                {label12}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount12}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
                {label13}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount13}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
              </Text>
              <Button plain dimColor label="show fewer ▴" />
            </Box>
          </Box>
          <Box>
            <Text>
              {"  "}
            </Text>
            <Text>
              {label14}
            </Text>
            <Text>
              {"        "}
              <Text color="inactive">
                ▉▉▉▉▉▉▉▉
              </Text>
              {" "}
              <Text bold>
                {amount14}
              </Text>
            </Text>
          </Box>
          <Box flexDirection="column">
            <Box>
              <Text>
                {"        "}
                {label15}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount15}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
                {label16}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount16}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
                {label17}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount17}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
              </Text>
              <Button plain dimColor label="show fewer ▴" />
            </Box>
          </Box>
          <Box>
            <Text>
              {"  "}
            </Text>
            <Text>
              {label18}
            </Text>
            <Text>
              {"        "}
              <Text color="inactive">
                ▉▉▉▉▉▉▉▉
              </Text>
              {" "}
              <Text bold>
                {amount18}
              </Text>
            </Text>
          </Box>
          <Box flexDirection="column">
            <Box>
              <Text>
                {"        "}
                {label19}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount19}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
                {label20}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount20}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
                {label21}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount21}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
              </Text>
              <Button plain dimColor label="show fewer ▴" />
            </Box>
          </Box>
        </Box>
        <Box flexDirection="column">
          <Text dimColor>
            <Box>
              <Text>
                {"  "}
              </Text>
              <Text>
                {label22}
              </Text>
              <Text>
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount22}
                </Text>
              </Text>
            </Box>
          </Text>
          <Text dimColor>
            <Box>
              <Text>
                {"  "}
              </Text>
              <Text>
                {label23}
              </Text>
              <Text>
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount23}
                </Text>
              </Text>
            </Box>
          </Text>
          <Text dimColor>
            <Box>
              <Text>
                {"  "}
              </Text>
              <Text>
                {label24}
              </Text>
              <Text>
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount24}
                </Text>
              </Text>
            </Box>
          </Text>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "context" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const total = '…'
    const limit = '…'
    const compacts = '…'
    const badge = '…'
    const glyph = '…'
    const glyph2 = '…'
    const glyph3 = '…'
    const label = '…'
    const amount = '…'
    const label2 = '…'
    const amount2 = '…'
    const label3 = '…'
    const amount3 = '…'
    const label4 = '…'
    const amount4 = '…'
    const label5 = '…'
    const amount5 = '…'
    const label6 = '…'
    const amount6 = '…'
    const label7 = '…'
    const amount7 = '…'
    const label8 = '…'
    const amount8 = '…'
    const label9 = '…'
    const amount9 = '…'
    const label10 = '…'
    const amount10 = '…'
    const label11 = '…'
    const amount11 = '…'
    const label12 = '…'
    const amount12 = '…'
    const label13 = '…'
    const amount13 = '…'
    const label14 = '…'
    const amount14 = '…'
    const label15 = '…'
    const amount15 = '…'
    const label16 = '…'
    const amount16 = '…'
    const label17 = '…'
    const amount17 = '…'
    const label18 = '…'
    const amount18 = '…'
    const label19 = '…'
    const amount19 = '…'
    const label20 = '…'
    const amount20 = '…'
    const label21 = '…'
    const amount21 = '…'
    const label22 = '…'
    const amount22 = '…'
    const label23 = '…'
    const amount23 = '…'
    const label24 = '…'
    const amount24 = '…'
    return (
      <Box flexDirection="column">
        <Box justifyContent="space-between">
          <Text>
            <Text color="claude">
              ◆
            </Text>
            {" "}
            <Text bold>
              context
            </Text>
          </Text>
          <Text>
            <Text bold>
              {total}
            </Text>
            <Text dimColor>
              {limit}
              {compacts}
            </Text>
            {" "}
            <Text color="inverseText">
              {badge}
            </Text>
          </Text>
        </Box>
        <Box>
          <Text>
            {glyph}
          </Text>
          <Text>
            {glyph2}
          </Text>
          <Text>
            {glyph3}
          </Text>
        </Box>
        <Box flexDirection="column">
          <Box columnGap={3}>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label}
              {" "}
              <Text bold>
                {amount}
              </Text>
            </Text>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label2}
              {" "}
              <Text bold>
                {amount2}
              </Text>
            </Text>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label3}
              {" "}
              <Text bold>
                {amount3}
              </Text>
            </Text>
          </Box>
          <Box columnGap={3}>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label4}
              {" "}
              <Text bold>
                {amount4}
              </Text>
            </Text>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label5}
              {" "}
              <Text bold>
                {amount5}
              </Text>
            </Text>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label6}
              {" "}
              <Text bold>
                {amount6}
              </Text>
            </Text>
          </Box>
          <Box columnGap={3}>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label7}
              {" "}
              <Text bold>
                {amount7}
              </Text>
            </Text>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label8}
              {" "}
              <Text bold>
                {amount8}
              </Text>
            </Text>
            <Text>
              <Text>
                ▉
              </Text>
              {" "}
              {label9}
              {" "}
              <Text bold>
                {amount9}
              </Text>
            </Text>
          </Box>
        </Box>
        <Box flexDirection="column">
          <Box>
            <Text>
              {"  "}
            </Text>
            <Text>
              {label10}
            </Text>
            <Text>
              {"        "}
              <Text color="inactive">
                ▉▉▉▉▉▉▉▉
              </Text>
              {" "}
              <Text bold>
                {amount10}
              </Text>
            </Text>
          </Box>
          <Box flexDirection="column">
            <Box>
              <Text>
                {"        "}
                {label11}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount11}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
                {label12}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount12}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
                {label13}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount13}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
              </Text>
              <Button plain dimColor label="show fewer ▴" />
            </Box>
          </Box>
          <Box>
            <Text>
              {"  "}
            </Text>
            <Text>
              {label14}
            </Text>
            <Text>
              {"        "}
              <Text color="inactive">
                ▉▉▉▉▉▉▉▉
              </Text>
              {" "}
              <Text bold>
                {amount14}
              </Text>
            </Text>
          </Box>
          <Box flexDirection="column">
            <Box>
              <Text>
                {"        "}
                {label15}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount15}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
                {label16}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount16}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
                {label17}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount17}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
              </Text>
              <Button plain dimColor label="show fewer ▴" />
            </Box>
          </Box>
          <Box>
            <Text>
              {"  "}
            </Text>
            <Text>
              {label18}
            </Text>
            <Text>
              {"        "}
              <Text color="inactive">
                ▉▉▉▉▉▉▉▉
              </Text>
              {" "}
              <Text bold>
                {amount18}
              </Text>
            </Text>
          </Box>
          <Box flexDirection="column">
            <Box>
              <Text>
                {"        "}
                {label19}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount19}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
                {label20}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount20}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
                {label21}
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount21}
                </Text>
              </Text>
            </Box>
            <Box>
              <Text>
                {"        "}
              </Text>
              <Button plain dimColor label="show fewer ▴" />
            </Box>
          </Box>
        </Box>
        <Box flexDirection="column">
          <Text dimColor>
            <Box>
              <Text>
                {"  "}
              </Text>
              <Text>
                {label22}
              </Text>
              <Text>
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount22}
                </Text>
              </Text>
            </Box>
          </Text>
          <Text dimColor>
            <Box>
              <Text>
                {"  "}
              </Text>
              <Text>
                {label23}
              </Text>
              <Text>
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount23}
                </Text>
              </Text>
            </Box>
          </Text>
          <Text dimColor>
            <Box>
              <Text>
                {"  "}
              </Text>
              <Text>
                {label24}
              </Text>
              <Text>
                {"        "}
                <Text color="inactive">
                  ▉▉▉▉▉▉▉▉
                </Text>
                {" "}
                <Text bold>
                  {amount24}
                </Text>
              </Text>
            </Box>
          </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.

mods/context-bar/hooks/register.tsx lines 313–320 · Band
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    if (e.props.hasSurvey || !(await read($, isVisible))) return next(e)

    const measured = await read($, usage)
    if (measured === null) return next(e)

    return card($, $.ui.resolve(e), measured, e.props.bodyColumns, true)
  })
mods/context-bar/hooks/register.tsx lines 339–498 · Band
async function card($: EngineInterface, ui: ElementTable, measured: ContextBarUsage, columns: number, isFramed: boolean) {
  const { Box, Button, Text } = ui
  const drilled = await read($, isDrilled)
  const open = await read($, openCategory)
  const expanded = await read($, expandedCategory)
  const m = meter(measured)
  const inner = isFramed ? columns - CHROME : columns
  const total = formatTokens(m.used)
  const limit = measured.compactsAt === null ? ` of ${formatTokens(measured.maxTokens)}` : ' used'
  const compacts = measured.compactsAt === null ? '' : ` · compacts at ${formatTokens(measured.compactsAt)}`
  const badge = ` ${m.percent}% `
  const hasRoom = TITLE.length + 1 + total.length + limit.length + compacts.length + 1 + badge.length <= inner

  const fills = [
    { label: 'overhead', tokens: m.overhead.tokens, color: FILL.overhead },
    { label: 'messages', tokens: m.messages, color: FILL.messages },
    { label: 'free', tokens: m.free, color: FILL.free },
  ].map(fill => ({ ...fill, amount: formatTokens(fill.tokens) }))
  const opener = `overhead ${fills[0]!.amount} ${drilled ? '▾' : '▸'}`
  const rows = packRows(
    fills.map((fill, i) => 2 + (i === 0 ? opener.length : fill.label.length + 1 + fill.amount.length)),
    inner,
    GAP,
  )

  const parts = m.overhead.parts
  const isOpenable = (part: (typeof parts)[number]) => (part.items?.length ?? 0) > 0
  const arrow = (part: (typeof parts)[number]) => (isOpenable(part) ? (open === part.label ? ' ▾' : ' ▸') : '')
  const ranked = rankRows(
    parts.map(part => ({ label: `${part.label}${arrow(part)}`, tokens: part.tokens })),
    inner - INDENT,
  )
  const opened = parts.find(part => part.label === open && isOpenable(part))
  const showsAll = opened !== undefined && opened.label === expanded
  const top = opened === undefined ? null : topItems(opened.items!, showsAll ? Infinity : MAX_ITEMS)
  const canFold = showsAll && opened.items!.length > MAX_ITEMS
  const items =
    top === null
      ? null
      : rankRows(
          top.shown.map(item => ({ label: item.name, tokens: item.tokens })),
          inner - INDENT - 2,
          ITEM_LABEL,
        )
  const breakdown = breakdownLines(parts, inner)

  return (
    <Box flexDirection="column" {...(isFramed ? { borderStyle: 'round', borderColor: 'subtle', paddingX: 1 } : {})}>
      <Box key="header" justifyContent="space-between">
        <Text>
          <Text color="claude">◆</Text> <Text bold>context</Text>
        </Text>
        <Text>
          <Text bold>{total}</Text>
          <Text dimColor>
            {limit}
            {hasRoom ? compacts : ''}
          </Text>{' '}
          <Text color="inverseText" backgroundColor={badgeColor(m)}>
            {badge}
          </Text>
        </Text>
      </Box>
      <Box key="bar">
        {barRuns(fills, inner).map(({ glyph, length, color }) => (
          <Text color={color}>{glyph.repeat(length)}</Text>
        ))}
      </Box>
      <Box key="legend" flexDirection="column">
        {rows.map(row => (
          <Box columnGap={GAP}>
            {row.map(i => {
              const fill = fills[i]!
              if (i === 0) {
                return (
                  <Box>
                    <Text>
                      <Text color={fill.color}>{SWATCH}</Text>{' '}
                    </Text>
                    <Button key="overhead" plain label={opener} onPress={() => update($, isDrilled, shown => !shown)} />
                  </Box>
                )
              }

              return (
                <Text>
                  <Text color={fill.color}>{SWATCH}</Text> {fill.label} <Text bold>{fill.amount}</Text>
                </Text>
              )
            })}
          </Box>
        ))}
      </Box>
      {drilled && parts.length > 0 && (
        <Box key="drill" flexDirection="column">
          {parts.flatMap((part, i) => {
            const row = ranked.rows[i]!
            const line = (
              <Box key={`row:${part.label}`}>
                <Text>{' '.repeat(INDENT)}</Text>
                {isOpenable(part) ? (
                  <Button
                    key={`category:${part.label}`}
                    plain
                    label={row.label}
                    onPress={async () => {
                      await update($, expandedCategory, () => null)
                      await update($, openCategory, current => (current === part.label ? null : part.label))
                    }}
                  />
                ) : (
                  <Text>{row.label}</Text>
                )}
                <Text>
                  {' '.repeat(row.pad + 2)}
                  <Text color={FILL.overhead}>{CELL.repeat(row.cells)}</Text> <Text bold>{row.amount}</Text>
                </Text>
              </Box>
            )
            if (part !== opened || top === null || items === null) return [line]

            return [
              line,
              <Box key="items" flexDirection="column">
                {items.rows.map((item, j) => (
                  <Box key={`row:item:${j}`}>
                    <Text>
                      {' '.repeat(INDENT + 2)}
                      {item.label}
                      {' '.repeat(item.pad + 2)}
                      <Text color={FILL.overhead}>{CELL.repeat(item.cells)}</Text> <Text bold>{item.amount}</Text>
                    </Text>
                  </Box>
                ))}
                {(top.rest !== null || canFold) && (
                  <Box key="more-row">
                    <Text>{' '.repeat(INDENT + 2)}</Text>
                    <Button
                      key="more"
                      plain
                      dimColor
                      label={
                        top.rest === null
                          ? 'show fewer ▴'
                          : `+ ${top.rest.count} more ${formatTokens(top.rest.tokens)} ▸`
                      }
                      onPress={() => update($, expandedCategory, () => (top.rest === null ? null : part.label))}
                    />
                  </Box>
                )}
              </Box>,
            ]
          })}
        </Box>
      )}
      {!drilled && breakdown.length > 0 && (
        <Box key="breakdown" flexDirection="column">
          {breakdown.map(line => (
            <Text dimColor>{line}</Text>
          ))}
mods/context-bar/hooks/register.tsx lines 323–331 · Pane
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const measured = await read($, usage)
    if (measured === null) {
      const { Text } = $.ui.resolve(e)
      return <Text dimColor>measuring the context window…</Text>
    }

    return card($, $.ui.resolve(e), measured, e.props.bodyColumns, false)
  })
Licence text (MIT)
MIT License

Copyright (c) 2026 David Lambl

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), Add a slash command

What its code calls

remembers

What its code shows

Read from the source at commit 20b7ebfe3ddb on 2026-10-11. 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 readEvery module hooks/hooks.json names was read.mods/context-bar/hooks/register.tsx
ParsesEvery file parses as TypeScript or JavaScript.2 files parsed
All its code is in the modEvery import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod
ReadableNo 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 openNetwork 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 drawsThe 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 lineWhether 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 WindowsWhether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks
NetworkWhether every fetch names its https host in the code.no network
ProgramsWhether 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 sendsWhether it both reads something of yours (files, environment variables, the transcript, settings) and reaches outside (the network, an MCP server, another session, telemetry).reaches nothing outside
Keys in the sourceWhether the source holds what looks like an API key or a private key.no keys in the source
LicenceAn 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 hooksHooks 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 shipsMCP 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, agentsWhat 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 MCPWhether 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 modelCompletions it runs ($.model.complete, fork, classify), subagents it spawns, prompts it submits as you, and the tools, commands and agents it adds.adds command context-bar
Events it hooksBy 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: command.run (context-bar) · also: session.start, session.measure, session.compact, session.end (+3) · timers: clock.after
Reads, by nameThe environment variables and files it names, and whether it reads the transcript, settings.json, the prompt box or the mouse selection.reads no files, environment variables, settings or transcript
Writes, by nameThe 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.writes no files, environment variables, settings or conversation rows

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 davidlambl/claude-extensions
/plugin install context-bar@davidlambl
/reload-plugins

This installs the marketplace's latest commit, which may not be the one read here (20b7ebfe3ddb). 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/davidlambl/claude-extensions
git -C claude-extensions checkout 20b7ebfe3ddb2903ccca33c5fb6363f83cb19ba4
claude plugin validate claude-extensions/mods/context-bar
claude --plugin-dir claude-extensions/mods/context-bar

The 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 about it

With the ModsCode connector added, Claude can read this mod's code and what it reaches, and build on them. Ask it like this:

Read the ModsCode mod "davidlambl-context-bar" with its code and make me one like it

Search them from Claude: the MCP connector

Similar mods

Badge for your README

If this is your mod, paste this into your README. It links to this page.

README.md
[![ModsCode](https://modscode.com/badge/davidlambl-context-bar.svg)](https://modscode.com/claude-mods/mods/davidlambl-context-bar/)