cjmellor/mella-marketplace/tree/main/plugins/session-stats
session-stats
プロンプトの上にモデル、コンテキスト使用量、レート制限の使用状況を表示し、コンテキストウィンドウの内訳を示すペインも提供する Claude Code mod です。
この mod について
モデル、コンテキスト使用量、レート制限の使用状況を常に見えるようにする Claude Code mod です。これらを表示する statusline スクリプトを用意できます。
Mods はあなたのマシン上で Claude Code 内のコードを実行します。インストール前にソースを読んでください。この mod は1つのファイル
hooks/register.tsxだけで構成され、セッション自身の数値だけを読み取ります。シェルコマンドもネットワーク呼び出しも実行しません。
バンド
プロンプトの上に表示されます。
Sonnet 5.5 ◼◼◼◼◼ 12% 5h 8% (34m) W 13% (4d 2h) +
/modelに表示されるモデル名の後に、推論 effort のアイコンを表示します。○は low、◐は medium、●は high、◉は xhigh、◈は max(effort が token budget の場合は数値)です。/modelの切り替えはすぐに表示され、新しいモデルの最初のターンまで effort アイコンを消します。他の場所(Alt+P ピッカー、フォールバック、IDE)で行った切り替えは次のターンから表示されます。Effort は各リクエストから読み取るため最初のターン後に現れます。/effort <level>はすぐに表示され、メニューで選んだレベルは次のターンから表示されます。Effort 設定のないモデルにはアイコンがありません。- コンテキストウィンドウの5マスのバーと割合。
- 各レート制限ウィンドウ(
5h、W)の割合とリセットまでの時間。ウィンドウは最初のレスポンスが報告した後に表示され、サブスクリプションでのみ使えます。 - バーと割合は緑で、60% で黄色、85% で赤になります。
- 右のボタンはペインを閉じていると
+、開いていると−です。押すとペインを開閉します。
アンケートが表示されている間、バンドは非表示です。
ペイン
+ ボタンまたは /session-stats で開きます。
- モデル、コンテキスト使用量、各レート制限ウィンドウを、リセットのカウントダウン付き20マスのバーで表示します。セッション(
5h)と週次のウィンドウはSession limitとWeekly · all modelsとして表示されます。エンジンが報告するモデル別の週次ウィンドウ(Fable など)はWeekly · <model>、バンドではW <model>です。 - このセッション: コスト、ターン時間、キャッシュヒット、各モデルの token 比率。
- 内訳: 入力、出力、キャッシュ読み取り、キャッシュ書き込みの token。
- コンテキストウィンドウ: カテゴリ(システムプロンプト、ツール、メッセージ、空き領域)ごとにローカル推定値の大きい順で表示します。
セッションの数値は、mod の読み込み後に完了したターンを合計したものです。リロードしても保持され、/clear ではリセットされません。「Turns」は完了したターンの壁時計時間であり、API 自体の時間ではありません。
r で更新します。Esc でキーボードをプロンプトに戻し、ペインを閉じます。
最新性
エンジンは各ターンの後とレート制限ウィンドウが整数ポイント動いたときにデータを送り、/model と /effort の直後にも更新します。リセットのカウントダウンは1分ごとに進みます。
インストール
/plugin marketplace add cjmellor/mella-marketplace
/plugin install session-stats@mella-marketplace
/reload-plugins
インストールせず、チェックアウトから試すこともできます。
claude --plugin-dir plugins/session-stats
開発
claude plugin validate plugins/session-stats
claude plugin test plugins/session-stats
validate はバンドが描画する内容までは確認しません。無効なレンダーツリーはエンジンに破棄され、バンドが表示されなくなります。編集後に消えた場合は --debug で Claude Code を実行し、ui.render (AbovePrompt): a hook returned a tree that does not validate という行を探してください。
制限
- status line に描画したり、それを隠したりはできません。ディレクトリ、ブランチ、PR は
statuslineに残すか、別の mod に移してください。 - バンドを描画できるフックは1つだけです。この mod は下位のフックにツリーを要求し、自分の行をその上に重ねます。そのため先に読み込まれた場合のみ
git-diffと組み合わせられます。要求せずに描画する mod があれば、この mod は置き換えられます。 - Mods が受け取るモデルや effort の変更イベントはなく、
/modelと/effortコマンドだけです。現在のモデルが拒否または下げる/effortのレベルも、次のターンで補正されるまでは入力されたまま表示されます。 - ペインは開いた時点のスナップショットです(
rで更新)。 - mod をホットリロードすると開いているペインは閉じます。
- ターミナルはポインター下のボタンを反転ブロックとして描画します。これはエンジン側の動作で、スタイルは変更できません。
インストール
まず作者の README で marketplace とプラグイン名を確認してください。コマンドはリポジトリの構成によって変わる場合があります。
claude plugin marketplace add cjmellor/mella-marketplace claude plugin install session-stats
原文 / README
session-stats
A Claude Code mod that keeps the model, context fill and rate-limit usage in
view, so you can drop a statusline script for them.
Mods run code inside Claude Code on your machine. Read the source before you install one — this one is a single file,
hooks/register.tsx, and only reads the session's own figures. It runs no shell commands and makes no network calls.
The band
Shown above the prompt:
Sonnet 5.5 ◼◼◼◼◼ 12% 5h 8% (34m) W 13% (4d 2h) +
- The model, as
/modelshows it, then an icon for the reasoning effort:○low,◐medium,●high,◉xhigh,◈max (a number if the effort is a token budget). A/modelswitch shows at once and clears the effort icon until the new model's first turn; one made elsewhere (the Alt+P picker, a fallback, the IDE) shows from the next turn. The effort is read from each request, so it appears after the first turn;/effort <level>shows at once, while a level picked from a menu shows from the next turn. Models without an effort setting show no icon. - A five-square bar and percentage for the context window.
- Each rate-limit window (
5h,W) with its percentage and the time until it resets. Windows appear once the first response has reported them, and only on a subscription. - Bars and percentages are green, turn yellow at 60% and red at 85%.
- The button on the right shows
+while the pane is closed and−while it is open. Press it to open or close the pane.
The band is hidden while a survey is up.
The pane
Open it with the + button or /session-stats.
- The model, context fill and each rate-limit window as a 20-square bar, with
reset countdowns. Session (
5h) and weekly windows show asSession limitandWeekly · all models; a per-model weekly window the engine reports, such as Fable, shows asWeekly · <model>, and asW <model>in the band. - This session: cost, turn time, cache hit and each model's share of tokens.
- Breakdown: input, output, cache read and cache write tokens.
- Context window: by category (system prompt, tools, messages, free space), largest first, estimated locally.
The session figures add up the turns finished since the mod loaded. A reload
keeps them, /clear does not reset them, and "Turns" is the wall-clock time
of finished turns, not the API's own time.
r refreshes. Esc hands the keyboard back and closes the pane.
Freshness
The figures are pushed by the engine after each turn and whenever a rate-limit
window moves a whole point, and refreshed straight after /model and /effort.
Reset countdowns tick once a minute.
Install
/plugin marketplace add cjmellor/mella-marketplace
/plugin install session-stats@mella-marketplace
/reload-plugins
To try it from a checkout without installing:
claude --plugin-dir plugins/session-stats
Develop
claude plugin validate plugins/session-stats
claude plugin test plugins/session-stats
validate does not check what the band draws: an invalid render tree is dropped
by the engine and the band simply does not appear. If it goes missing after an
edit, run Claude Code with --debug and look for a ui.render (AbovePrompt): a hook returned a tree that does not validate line.
Limits
- It cannot draw in the status line or hide it. Keep your
statuslinefor the directory, branch and PR, or move those into another mod. - Only one hook can draw the band. This mod asks the hooks beneath it for their
tree and stacks its own row on top, so it composes with
git-diffonly when it loads first. A mod that draws without asking replaces this one. - Mods get no event for a model or effort change, only for the
/modeland/effortcommands. A level/effortrefuses or lowers for the model still shows as typed until the next turn corrects it. - The pane is a snapshot taken when it opens (press
rto refresh). - A hot reload of the mod closes an open pane.
- The terminal draws a button under the pointer as an inverted block. That comes from the engine and cannot be styled.
