starship/starship
Claude Code modules
Three modules that exist purely for Anthropic's Claude Code CLI's statusLine integration. They render information about the in-flight Claude Code session — the model in use, context-window utilization, and accumulated cost.
When they run
Claude Code can be configured to invoke an external command for every status line update. Starship ships a built-in claude-code profile (defined in default_profiles in src/configs/starship_root.rs) that renders these three modules plus a git branch:
$claude_model$git_branch$claude_context$claude_costUsers wire it up by configuring Claude Code's statusLine to starship statusline claude-code. Internally:
Commands::Statusline { provider: ClaudeCode, .. }insrc/main.rscallsprint::prompt_with_claude_code.prompt_with_claude_codeinsrc/print.rsreads JSON from stdin into aClaudeCodeDatastruct, then callsContext::with_claude_code_datato attach it.- The render target is
Target::Profile("claude-code"), which maps to the built-in profile string. - Each Claude module reads
context.claude_code_data.as_ref()?— returningNoneif the data is absent.
The data shape is in src/utils/statusline.rs. The relevant types:
pub struct ClaudeCodeData {
pub cwd: Option<String>,
pub model: ModelInfo,
pub context_window: ContextWindow,
pub cost: Option<CostInfo>,
pub workspace: Option<Workspace>,
}The modules
claude_model
Source: src/modules/claude_model.rs.
Config: src/configs/claude_model.rs.
Shows the Claude model in use. The user can rename verbose model identifiers via [claude_model.model_aliases], looked up first by model.id and then by model.display_name:
[claude_model]
symbol = "🤖 "
[claude_model.model_aliases]
"global.anthropic.claude-sonnet-4-5-20250929-v1:0" = "Sonnet 4.5"claude_context
Source: src/modules/claude_context.rs.
Config: src/configs/claude_context.rs.
Shows context-window usage. Variables supported:
| Variable | Meaning |
|---|---|
$used_percentage |
Pre-computed percentage from Claude Code |
$total_input_tokens / $total_output_tokens |
Cumulative token counts |
$context_window_size |
Configured window size |
$current_input_tokens, $current_output_tokens, $cache_creation_input_tokens, $cache_read_input_tokens |
Most-recent API call breakdown |
The module includes thresholds so the percentage can be styled differently as it climbs.
claude_cost
Source: src/modules/claude_cost.rs.
Config: src/configs/claude_cost.rs.
Shows accumulated USD spend on the session, plus optional duration and lines-changed counters from CostInfo:
| Variable | Source |
|---|---|
$total_cost_usd |
cost.total_cost_usd |
$total_duration_ms |
cost.total_duration_ms |
$total_api_duration_ms |
cost.total_api_duration_ms |
$total_lines_added / $total_lines_removed |
cost.total_lines_added/removed |
If Claude Code did not provide a cost block (cost: None), the module returns None and renders nothing.
Why these modules are special
Unlike every other module, these three:
- Have no project detection — they trigger purely on the presence of
claude_code_dataon theContext. - Are not in
PROMPT_ORDER— they would have nothing to render in a normal prompt. - Live behind a different command —
starship statusline claude-coderather thanstarship prompt. - Rewrite
context.shelltoShell::Unknownbecause the rendering target is not a real shell.
Entry points for modification
- To add a new statusline provider (besides Claude Code), add a variant to
Statuslinesinsrc/main.rs, a parser for its JSON payload (mirroringClaudeCodeDatainsrc/utils/statusline.rs), a built-in profile entry indefault_profiles, and one or more new modules. - To change rendering of an existing module, edit its
module(context)function insrc/modules/claude_*.rs.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.