Open-Source Wikis

/

Starship

/

Features

/

Claude Code statusline

starship/starship

Claude Code statusline

Starship ships a built-in Claude Code statusLine provider. Configure Claude Code to call starship statusline claude-code, and Starship will render the active model, context-window utilization, and accumulated cost.

How to wire it up

In your Claude Code settings (~/.claude/settings.json or per-project .claude/settings.json), set:

{
  "statusLine": {
    "type": "command",
    "command": "starship statusline claude-code"
  }
}

Claude Code pipes a JSON document into stdin every time it wants a statusline update. Starship reads it as ClaudeCodeData, attaches it to the Context, and renders the built-in claude-code profile.

Default profile

"$claude_model$git_branch$claude_context$claude_cost"

Defined in default_profiles() inside src/configs/starship_root.rs. It includes:

  • $claude_model — the model name, with optional aliases.
  • $git_branch — the standard git module (so the statusline shows your branch).
  • $claude_context — context-window usage.
  • $claude_cost — USD spend.

Customizing it

You can override the built-in profile by defining your own:

[profiles]
claude-code = "$claude_model on $git_branch | $claude_cost"

User profiles win over internal profiles (load_formatter_and_modules in src/print.rs).

You can also customize the modules themselves:

[claude_model]
symbol = "🤖 "
[claude_model.model_aliases]
"global.anthropic.claude-sonnet-4-5-20250929-v1:0" = "Sonnet 4.5"

[claude_context]
format = "[$used_percentage% used]($style) "
threshold = 80

[claude_cost]
format = "[\\$$total_cost_usd]($style) "

What's available in the data

ClaudeCodeData (in src/utils/statusline.rs):

ClaudeCodeData
├─ cwd:           Option<String>
├─ model:
│  ├─ id:           String
│  └─ display_name: String
├─ context_window:
│  ├─ context_window_size:        u64
│  ├─ total_input_tokens:         u64
│  ├─ total_output_tokens:        u64
│  ├─ used_percentage:            f32
│  └─ current_usage:
│     ├─ input_tokens:                  u64
│     ├─ output_tokens:                 u64
│     ├─ cache_creation_input_tokens:   u64
│     └─ cache_read_input_tokens:       u64
├─ cost:          Option<{
│  ├─ total_cost_usd:           f64
│  ├─ total_duration_ms:        u64
│  ├─ total_api_duration_ms:    u64
│  ├─ total_lines_added:        u64
│  └─ total_lines_removed:      u64
│  }>
└─ workspace:     Option<{
   ├─ current_dir: String
   └─ project_dir: String
   }>

Every field is optional — if Claude Code does not provide a cost block, $claude_cost returns nothing instead of erroring.

What modules are special here

Three modules read context.claude_code_data and only render under the statusline:

These modules are not in PROMPT_ORDER and have no detection logic — they trigger purely on the presence of the data.

Implementation

The path is described in Statusline subsystem. Briefly:

  1. Commands::Statusline { provider: ClaudeCode, .. } in src/main.rs.
  2. print::prompt_with_claude_code reads stdin, parses to ClaudeCodeData, attaches to Context, sets shell = Shell::Unknown.
  3. get_prompt(context) runs through the standard rendering path with Target::Profile("claude-code").
  4. The Claude modules return their segments; the rest of the format renders normally.

Limitations

  • Statusline rendering does not use the user's normal format. It uses the profile only.
  • The shell-specific PS1 wrapping (\[\], %{%}, etc.) is bypassed because Shell::Unknown doesn't match any of the wrap rules.
  • Adding a non-Claude statusline provider requires Rust changes — see Statusline subsystem.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Claude Code statusline – Starship wiki | Factory