claude-cli
Overview
claude-cli is a provider-specific Rust CLI for Claude-oriented helpers that should not live in shell glue. The initial surface owns
Claude Code prompt-segment rendering, including Keychain credential lookup, usage refresh, cache fallback, and completion export.
Usage
Usage:
claude-cli prompt-segment [options]
claude-cli prompt-segment check
claude-cli prompt-segment status [--format text|json]
claude-cli completion <bash|zsh>
Help:
claude-cli help
claude-cli prompt-segment --help
Scope boundary
| Job | Primary owner |
|---|---|
| Claude prompt-segment auth, cache refresh, usage rendering, completion export | claude-cli |
| Shell aliases, Starship module wiring, PATH/fpath registration, wrapper dispatch | zsh-kit shell glue |
claude-cli owns provider-specific Claude behavior. zsh-kit should keep only the small compatibility wrapper and shell integration.
Commands
prompt-segment
prompt-segment [--ttl <duration>] [--time-format <strftime>] [--refresh] [--is-enabled]: Render Claude 5h / weekly usage.prompt-segment check: Exit0when a Claude OAuth access token is available, otherwise1.prompt-segment status [--format text|json]: Report readiness and cache state without exposing token material.
The output mirrors the former zsh-kit claude-prompt-segment helper:
5h:<remaining>% W:<remaining>% <weekly_reset_time>[<stale_suffix>]
The cache remains compatible with the former shell script:
~/Library/Caches/claude-prompt-segment/usage.json
completion
completion <bash|zsh>: Export shell completion script to stdout.
Environment
CLAUDE_PROMPT_TTLorCLAUDE_PROMPT_SEGMENT_TTLoverrides the cache TTL. The default is60seconds.0forces refresh.CLAUDE_PROMPT_STALE_SUFFIXorCLAUDE_PROMPT_SEGMENT_STALE_SUFFIXcontrols stale cache suffix text. The default is one leading space followed by(stale).CLAUDE_PROMPT_SEGMENT_CACHE_DIRoverrides the cache directory.CLAUDE_PROMPT_SEGMENT_ENDPOINToverrides the usage endpoint. The default ishttps://api.anthropic.com/api/oauth/usage.CLAUDE_PROMPT_SEGMENT_ACCESS_TOKENorCLAUDE_PROMPT_SEGMENT_CREDENTIALS_JSONcan supply credentials for automation.CLAUDE_PROMPT_SEGMENT_KEYCHAIN_DISABLED=1disables macOS Keychain lookup.CLAUDE_PROMPT_SEGMENT_KEYCHAIN_SERVICEoverrides the macOS Keychain service name. The default isClaude Code-credentials.NO_COLOR=1disables ANSI color.
Dependencies
- macOS
securityis used for Keychain credential lookup unless an automation credential override is supplied. - No
curl,jq, or Python runtime is required for prompt-segment rendering.
Exit codes
0: success, help output, or no prompt output needed.1: operational false/failed state such asprompt-segment checkwithout credentials.64: usage or argument errors.