Skip to main content

Claude Code

What

Display Claude Code session information including the current AI model, token usage, costs, and workspace details. Shows a visual gauge of context window usage and formatted cost/token information for monitoring your Claude usage.

This segment integrates with Claude Code's statusline functionality to provide real-time session data in your prompt.

Sample Configuration

{
"type": "claude",
"style": "diamond",
"leading_diamond": "",
"trailing_diamond": "",
"foreground": "#FFFFFF",
"background": "#FF6B35",
"template": " 󰯉 {{ .Model.DisplayName }}  {{ .TokenUsagePercent.Gauge }} "
}

Template (info)

default template
 \udb82\udfc9 {{ .Model.DisplayName }} \uf2d0 {{ .TokenUsagePercent.Gauge }}

Properties

NameTypeDescription
.SessionIDstringUnique identifier for the Claude session
.ModelModelAI model information
.WorkspaceWorkspaceWorkspace directory information
.CostCostCost and duration information
.ContextWindowContextWindowToken usage information
.TokenUsagePercentPercentagePercentage of context window used (0-100)
.FormattedCoststringFormatted cost string (e.g., "$0.15" or "$0.0012")
.FormattedTokensstringHuman-readable token count (e.g., "1.2K", "15.3M")

Model Properties

NameTypeDescription
.IDstringTechnical model identifier
.DisplayNamestringHuman-readable model name (e.g., "Claude 3.5 Sonnet")

Workspace Properties

NameTypeDescription
.CurrentDirstringCurrent working directory
.ProjectDirstringRoot project directory

Cost Properties

NameTypeDescription
.TotalCostUSDfloat64Total cost in USD
.TotalDurationMSint64Total session duration in milliseconds

ContextWindow Properties

NameTypeDescription
.TotalInputTokensintTotal input tokens used in the session
.TotalOutputTokensintTotal output tokens generated in the session
.ContextWindowSizeintMaximum context window size for the model
.CurrentUsageCurrentUsageCurrent message token usage

CurrentUsage Properties

NameTypeDescription
.InputTokensintInput tokens for the current message
.OutputTokensintOutput tokens for the current message

Percentage Methods

The TokenUsagePercent property is a Percentage type that provides additional functionality:

MethodReturnsDescription
.GaugestringVisual gauge showing remaining capacity using 5 bar blocks (▰▰▰▰▱)
.StringstringNumeric percentage value (e.g., "75" for use in templates)

How it works

The segment reads session information from the POSH_CLAUDE_STATUS environment variable, which is automatically set when using the oh-my-posh claude command. The data includes:

  • Current AI model information
  • Token usage and context window utilization
  • Session costs and duration
  • Workspace directory information

The segment only displays when Claude Code is actively providing session data.