0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Claude Codeでモデル名とコンテキスト使用率を表示する(jq不要)

0
Posted at

やること

Claude Codeのプロンプト入力欄に、以下をそのまま入力するだけです。

/statusline show model name and context percentage, written as a Node.js script so it doesn't need jq

これで何が起きるか

/statusline は、表示したい内容を自然言語で伝えるとステータスライン(画面下部の常時表示バー)を自動設定してくれるコマンドです。

上記を実行すると、Claude Codeが自動で次を行います。

  1. ~/.claude/ にステータスライン用のNode.jsスクリプトを作成
  2. ~/.claude/settings.json にそのスクリプトを呼び出す設定を追記

設定後、画面下部に次のように表示されます。

[Opus 4.8] 12% context
  • [Opus 4.8] … 現在使用中のモデル名
  • 12% contextコンテキストウィンドウの使用率。モデルが一度に覚えていられる情報量(会話履歴・読み込んだファイルなど)の上限に対して、今どれくらい埋まっているかを示します。100%に近づくと古い内容が圧縮・切り捨てられ、Claudeが前の話を忘れ始めるため、この数値が高くなってきたら会話を整理したり新しいセッションを始める目安になります。

なぜ「Node.js」と書くのか

標準のサンプルは jq(JSON解析ツール)を使いますが、jqは別途インストールが必要で、特にWindowsではつまずきやすいです。

Node.jsはClaude Codeが動く時点で必ず入っているため、「Node.jsで書いて」と指定すれば追加インストールなしで済みます。それが末尾の written as a Node.js script so it doesn't need jq の意図です。

表示されないとき

  • モデル名だけ空 → 起動直後の既知の挙動。メッセージを1回送れば表示されます。
  • 消したい/statusline clear を実行。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?