ClaudeMods
☰
JA
● 0 人がオンライン ・閲覧 0 回
スポンサー作品を投稿
GitHub リポジトリ · 投稿者 myUdav4iik

context-bar

Claude Code のプラグインです。プロンプトの上にある帯にコンテキストウィンドウの内訳をリアルタイム表示し、カテゴリ別使用量、コンパクション閾値、レート制限ウィンドウを示します。/context-bar で切り替えます。

myUdav4iik@myUdav4iik

myUdav4iik/claude-mods/tree/main/context-bar

元の投稿の画像1
翻訳済み

この mod について

context-bar は、プロンプトの上の帯にコンテキストウィンドウの内訳をリアルタイムで描画する Claude Code mod です。ヘッダーには、使用中のウィンドウの割合を色分けしたバッジ(50% 未満は緑、80% 未満は黄、それ以上は赤)、使用中の token、ウィンドウサイズ、自動コンパクションが実行される位置が表示されます。バーには各カテゴリの割合に応じたセグメントが 1 つずつ並び、その後に空き領域のトラックが続きます。凡例には各カテゴリと token 数が、/context で使われる色で表示されます。オプションの使用量行には、プランのレート制限ウィンドウ(5h、7d、またはゲートウェイの利用上限)、使用割合、リセットまでのカウントダウンが表示されます。これはサブスクリプションでのみ表示されます。/context-bar、/context-bar on、/context-bar off で切り替え、選択はセッションをまたいで保持されます。使用するフックは session.start(登録、状態の復元、初回読み取り、カウントダウンタイマー)、turn.complete(各メイン会話ターン後の読み取り、サブエージェントはスキップ)、session.compact(コンパクション後の読み取り)、session.measure(ターン間の使用量更新)、AbovePrompt 上の ui.render(帯の描画、アンケート時は退避)です。読み取り元は $.session.usage({ breakdown: 'summary' }) で、ローカル推定のためリクエストは送りません。バーは flex box を使うため正確な割合で分割され、折り返しません。空き領域はターミナルでは暗い線、デスクトップアプリでは暗い塗りつぶしで表示します。既知の制限は、カテゴリの数値が推定値であること、1 ターンに 1 回だけ更新すること、次の API 応答まで使用率が古いままになること、初回読み取り前はプレースホルダーになること、他の mod と帯を共有することです。テストは tests/bar.test.tsx にあり、claude plugin test . で実行できます。

インストール

まず作者の README で marketplace とプラグイン名を確認してください。コマンドはリポジトリの構成によって変わる場合があります。

claude plugin marketplace add myUdav4iik/claude-mods
claude plugin install context-bar
原文 / README

context-bar

A live breakdown of the context window, drawn in the band above Claude Code's prompt.

In the terminal:

context-bar in the terminal: a context header at 18%, the category bar, its legend, and a usage row with 5h and 7d limits

In the desktop app:

context-bar in the Claude desktop app: a context header at 35%, the category bar on a dark free-space fill, and its legend

  • Header: the share of the window in use, as a badge that is green under 50%, yellow under 80% and red above. Then the tokens in use, the window size, and the point where auto-compaction runs.
  • Bar: one segment per category, in proportion to its share of the window, followed by a track for the free space.
  • Legend: each category with its token count, in the colours /context uses.
  • Usage: your plan's rate-limit windows (5h, 7d, or a gateway's spend limit), each with the share used, coloured like the context badge, and a countdown to when it resets. The row only appears on a subscription, where Claude Code receives these figures.

Usage

| Command | Does | | --- | --- | | /context-bar | Shows or hides the bar | | /context-bar on | Shows the bar | | /context-bar off | Hides the bar |

The command runs at once, even while Claude is working. The choice is remembered across sessions. Claude Code's own [-] control on the band collapses it as well.

How it works

| Hook | What it does | | --- | --- | | session.start | Registers /context-bar, restores the saved on/off choice, takes a first reading, and starts a once-a-minute timer for the reset countdowns. | | turn.complete | Takes a reading after each turn of the main conversation. Subagent turns are skipped. | | session.compact | Takes a reading after the conversation is compacted. | | session.measure | Updates the usage row when a rate-limit window moves, between turns too. | | ui.render on AbovePrompt | Draws the band. It steps aside while Claude Code shows a survey there. |

Readings come from $.session.usage({ breakdown: 'summary' }), the same per-category breakdown /context shows. The summary mode estimates locally, so a reading sends no requests and costs nothing. The same call returns the rate-limit windows from the last API response; the usage row shows those, so it sends no requests either.

The bar is built from flex boxes, each growing by its share of the window, so it splits in exact proportion at any width and never wraps. Small categories still get at least one cell. Free space is drawn differently per surface:

  • Terminal: a dim line, because Claude Code's colour for free space there is bright enough to read as used.
  • Desktop app: a dark fill. The desktop wraps long runs of text rather than clipping them, so a line of characters doesn't work there.

The compaction reserve is drawn as part of the free track; the header shows where compaction runs.

Limitations

  • Estimates: the category figures are estimates, as in /context, so the total can differ slightly from the status line.
  • Once per turn: the bar updates after each turn, not while Claude is working.
  • Usage after a reset: the percentages come from the last API response. Once a window's reset time passes, the row shows "resetting" until the next response brings a new figure.
  • Before the first reply: the bar shows "waiting for the first reading…".
  • Shared band: the band above the prompt holds one mod at a time. If another installed mod draws there, only one of them shows.

Tests

tests/bar.test.tsx feeds the mod a sample breakdown, draws the band on the terminal and desktop surfaces, and fails if either surface refuses the drawing. Claude Code drops a drawing it can't validate without an error you'd see, so run the tests after changing how the bar is drawn:

claude plugin test .

同名の他の作品

関連作品