Claude Code のステータスラインは、画面下部に常時表示される 1 行のカスタムバーです。いま動いているモデル・ブランチ・推定コスト・コンテキスト使用率などを、API トークンを消費せずローカルで表示できます。本稿は公式ドキュメント(2026-07-01 検証)に基づき、設定方法・実行モデル・stdin で渡る JSON フィールド・プラットフォーム別の注意点を、逐語引用付きで整理します。
ステータスラインとは何か
a customizable bar at the bottom of Claude Code that runs any shell script
ステータスラインは、設定した任意のシェルスクリプトを実行する、Claude Code 下部のカスタマイズ可能なバーです。
receives JSON session data on stdin and displays whatever your script prints
スクリプトは stdin で JSON セッションデータを受け取り、stdout に出力した内容がそのまま表示されます。表示の中身はスクリプト次第です。
renders in its own row above the built-in footer badges
描画位置は組み込みフッターバッジの上の独自の行で、フッターバッジを置き換えるものではありません。
設定方法
/statusline コマンド(自動生成)
The /statusline command accepts natural language instructions describing what you want displayed
/statusline は自然言語の指示を受け付けます。Claude Code が ~/.claude/ にスクリプトファイルを生成し、settings を自動更新します。
手動設定(settings.json)
~/.claude/settings.json またはプロジェクトの settings.json に statusLine フィールドを追加し、type を "command" にします。
point command to a script path or an inline shell command
command にはスクリプトパス、またはインラインのシェルコマンドを指定します。
{
"statusLine": {
"type": "command",
"command": "~/.claude/statusline.sh"
}
}
実行モデル
Your script runs after each new assistant message, after /compact finishes
スクリプトは、アシスタントメッセージの後・/compact 完了後のほか、パーミッションモード変更時・vim モード切替時に実行されます。
Updates are debounced at 300ms, meaning rapid changes batch together
更新は 300ms でデバウンスされ、短時間の連続変更はまとめて 1 回の実行になります。
the in-flight execution is cancelled
スクリプト実行中に新しい更新がトリガーされた場合、実行中の処理はキャンセルされます。
The status line runs locally and does not consume API tokens
ステータスラインはローカルで実行され、API トークンを消費しません。
stdin で渡る主な JSON フィールド
コスト
Estimated session cost in USD, computed client-side. May differ from your actual bill
cost.total_cost_usd はクライアント側で計算された USD 建ての推定セッションコストで、実際の請求額と異なる場合があります。
コンテキストウィンドウ
reflect current context usage, not cumulative session totals
v2.1.132 以降、context_window.total_input_tokens と total_output_tokens は現在のコンテキスト使用量を反映し、セッション累計ではありません。
200000 by default, or 1000000 for models with extended context
context_window.context_window_size はデフォルト 200,000 トークン、拡張コンテキスト対応モデルでは 1,000,000 トークンです。
なお context_window.used_percentage は入力トークン(input_tokens と cache_creation_input_tokens と cache_read_input_tokens)のみから計算され、output_tokens を含みません(公式ドキュメント記載)。
null before the first API call in a session, and again after /compact
context_window.current_usage は、セッション最初の API 呼び出し前と、/compact 実行後から次の API 呼び出しまでの間は null になります。
effort(推論の努力度)
Ultracode is not a distinct level and reports as xhigh
effort.level は low・medium・high・xhigh・max の 5 段階です。Ultracode は独立レベルではなく xhigh として報告されます。
レート制限・prompt_id・200k 判定
appears only for Claude.ai subscribers (Pro/Max) after the first API response
rate_limits は Claude.ai の Pro/Max サブスクライバーに対してのみ、セッション内で最初の API レスポンス後に表示されます。
Absent until the first user input. Requires Claude Code v2.1.196 or later
prompt_id は最初のユーザー入力があるまで存在せず、Claude Code v2.1.196 以降が必要です。
This is a fixed threshold regardless of actual context window size
exceeds_200k_tokens は直近の API レスポンスの入力・キャッシュ・出力トークン合計が 200k を超えるかの真偽値で、実際のコンテキストウィンドウサイズに関わらず固定の 200k 閾値を使います。
作業ディレクトリ
workspace.current_dir is preferred for consistency with workspace.project_dir
cwd と workspace.current_dir は同じ値ですが、workspace.project_dir との一貫性のため workspace.current_dir の使用が推奨されます。
キャッシュファイルの命名
it's stable for the lifetime of a session and unique per session
キャッシュファイル名には $$ や os.getpid() ではなく JSON の session_id を使います。session_id はセッション中は固定で、セッションごとに一意です。
サブエージェント表示(subagentStatusLine)
renders a custom row body for each subagent shown in the agent panel
subagentStatusLine は、プロンプト下のエージェントパネルに表示される各サブエージェント行のカスタムボディを描画します。
runs once per refresh tick with all visible subagent rows
コマンドはリフレッシュごとに 1 回実行され、全可視サブエージェント行が単一の JSON オブジェクトとして stdin に渡されます。入力には基本フックフィールドと columns(使用可能な行幅)、tasks 配列(各タスクに id・name・type・status・description・label・startTime・tokenCount・tokenSamples・cwd)が含まれます。
プラットフォーム別の注意点
Windows
runs status line commands through Git Bash when Git Bash is installed
Windows では、Git Bash があれば Git Bash 経由、なければ PowerShell 経由で実行されます。
Git Bash treats unquoted backslashes as escape characters
Git Bash はクォートされていないバックスラッシュをエスケープ文字として扱うため、Windows 形式パスの区切りが除去され、エラーメッセージなしにコマンドが失敗します。
ターミナル幅
tput cols and language-level width detection cannot read the terminal size
Claude Code はスクリプトの出力をキャプチャするため、tput cols や言語レベルの幅検出でターミナルサイズを読み取れません。幅を使うなら columns を参照します。
workspace trust
you'll see the notification statusline skipped · restart to fix
workspace trust ダイアログを承認していないとステータスラインコマンドは実行されず、この通知が表示されます。承認は hook など他のシェル実行系設定と同じ扱いです。