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 }} ๏‹ {{ .TokenGauge }} "
}

Template (info)โ€‹

default template
\udb82\udfc9 {{ .Model.DisplayName }} \uf2d0 {{ .TokenGauge }}

Optionsโ€‹

NameTypeDefaultDescription
gauge_marked_charstringโ–ฐCharacter used for filled blocks in gauge visualizations
gauge_unmarked_charstringโ–ฑCharacter used for empty blocks in gauge visualizations

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)
.TokenGaugestringGauge showing remaining context capacity using configured characters (e.g., โ–ฐโ–ฐโ–ฐโ–ฑโ–ฑ)
.TokenGaugeUsedstringGauge showing used context capacity using configured characters (e.g., โ–ฐโ–ฐโ–ฑโ–ฑโ–ฑ)
.FiveHourGaugestringGauge showing 5-hour rate limit usage using configured characters
.SevenDayGaugestringGauge showing 7-day rate limit usage using configured characters
.FiveHourResetsAttime.Time5-hour rate limit window reset time
.SevenDayResetsAttime.Time7-day rate limit window reset time
.FiveHourResetsIntime.Durationtime until 5-hour resets; 0=unavailable, neg=past
.SevenDayResetsIntime.Durationtime until 7-day resets; 0=unavailable, neg=past
.FormattedCoststringFormatted cost string (e.g., "$0.15" or "$0.0012")
.FormattedTokensstringHuman-readable token count (e.g., "1.2K", "15.3M")
.FormattedDurationstringTotal session duration (e.g., "2m 5s")
.FormattedAPIDurationstringAPI wait time (e.g., "0m 45s")
.FiveHourUsagePercentage5-hour rolling rate limit usage (0-100)
.SevenDayUsagePercentage7-day rate limit usage (0-100)

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
.GitWorktreestringPath to the linked git worktree, empty when not inside a linked git worktree

Cost Propertiesโ€‹

NameTypeDescription
.TotalCostUSDfloat64Total cost in USD
.TotalDurationMSDurationMSTotal session duration in milliseconds (formats as "Xm Ys")
.TotalAPIDurationMSDurationMSTime spent waiting for API responses (formats as "Xm Ys")
.TotalLinesAddedintLines of code added in the session
.TotalLinesRemovedintLines of code removed in the session

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

RateLimits Propertiesโ€‹

Available when Claude Code provides rate limit data (Pro/Max subscribers). Access via .RateLimits.

NameTypeDescription
.FiveHourRateLimitWindow5-hour rolling window
.SevenDayRateLimitWindow7-day rolling window

RateLimitWindow Propertiesโ€‹

NameTypeDescription
.UsedPercentage*float64Usage percentage (0-100), nil if unknown
.ResetsAt*int64Unix epoch seconds when window resets

Percentage Methodsโ€‹

The Percentage type (returned by .TokenUsagePercent, .FiveHourUsage, .SevenDayUsage) provides additional methods for direct use in templates:

MethodReturnsDescription
.GaugestringVisual gauge showing remaining capacity using hardcoded โ–ฐ/โ–ฑ characters
.GaugeUsedstringVisual gauge showing used capacity using hardcoded โ–ฐ/โ–ฑ characters
.StringstringNumeric percentage value (e.g., "75" for use in templates)
Custom gauge characters

Use .TokenGauge, .TokenGaugeUsed, .FiveHourGauge, and .SevenDayGauge instead of the raw .Percentage methods above โ€” they respect the gauge_marked_char and gauge_unmarked_char options.

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.