Version 0.13.7 | Changelog
Real-time session analytics and optimization insights for Claude Code. TypeScript-powered with multi-line status display, git integration, tool activity tracking, and efficiency metrics.
- Node.js 18+ - Check:
node --version(Download) - Claude Code - Latest version recommended
Windows:
# Double-click or run:
install.batLinux/macOS:
./install.shThe installer will:
- β Check Node.js version (18+ required)
- β Detect and remove old bash-based installations automatically
- β Prompt for billing mode (API or Subscription)
- β Create configuration files
- β Update Claude Code settings
- β Create
/tripcommand - β Test the installation
Time: ~2 minutes | Then restart Claude Code
Upgrading from bash version? The installer automatically detects and removes old bash scripts, hooks, and cache files. No manual cleanup needed!
Click to expand manual setup instructions
-
Clone repository:
cd ~/Code # or your preferred location git clone https://github.com/luxsolari/claude-trip-computer
-
Configure billing mode:
Create
~/.claude/hooks/.stats-config:# Claude Code Session Stats Configuration BILLING_MODE="API" # or "Sub" for subscription BILLING_ICON="π³" # or "π " for subscription SAFETY_MARGIN="1.00" # 1.10 for subscription (10% buffer)
-
Configure Claude Code status line:
Edit
~/.claude/settings.json:{ "statusLine": { "type": "command", "command": "npx -y tsx /full/path/to/claude-trip-computer/src/index.ts" } }Replace
/full/path/to/with your actual path. -
Restart Claude Code
Time: ~5 minutes
- Troubleshooting β TROUBLESHOOTING.md
- Technical Docs β CLAUDE.md
- Want to contribute? β CONTRIBUTING.md
Real-time session efficiency metrics in your Claude Code status bar:
Multi-Line Status (v0.13.2):
π¬ 5 msgs (Opus 4.5) | π§ 12 tools (2.4/msg) | π― 15.3K tok | πΏ main* | ββββββββββ 35% | β‘ 78% cached | π 3.1K/msg | β±οΈ 31m | π /trip
β Edit Γ55 | β Bash Γ41 | β Read Γ23 | β Write Γ8
β Explore: Explore codebase structure (52s)
βΈ Fix authentication bug (2/5)
Line 1 - Session Metrics:
- π¬ 5 msgs (Opus 4.5) - Message count with current model
- π§ 12 tools (2.4/msg) - Tool usage with intensity ratio
- π― 15.3K tok - Total tokens (deduplicated)
- πΏ main* - Git branch with dirty indicator (NEW)
- ββββββββββ 35% - Context window usage bar
- β‘ 78% cached - Cache efficiency
- π 3.1K/msg - Response verbosity
- β±οΈ 31m - Session duration (NEW)
- π /trip - Trip computer link
- π ~$X.XX value (Sub users only) - API-equivalent value
Line 2 - Tool Activity (NEW):
- Top 5 tools by frequency with accurate session-wide counts
- Running tools:
β Bash: command...
Lines 3+ - Agent Status (NEW, when agents exist):
- Shows running/completed agents with duration
Final Line - Todo Progress (NEW, when todos exist):
- In progress:
βΈ Task name (2/5) - Complete:
β All todos complete (5/5)
Ask Claude to show trip computer stats, or run directly:
npx tsx /path/to/claude-trip-computer/src/index.ts --trip-computerSession optimization dashboard with complete billing-mode differentiation:
For API Users - Optimization-First Experience:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π TRIP COMPUTER - Session Analytics Dashboard
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π QUICK SUMMARY
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Health: βββββ Excellent (85/100)
Messages: 3 | Tools: 46 | Tokens: 3.8M
π SESSION HEALTH (0-100)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Overall: βββββ 85/100
β‘ Cache Efficiency: β
40/40 points
90% cache hit rate
βοΈ Context Management: β‘οΈ 15/30 points
Context tracking unavailable
π― Efficiency: β
30/30 points
15.3 tools/msg, 4.4K tok/msg
π€ MODEL MIX
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Sonnet 4.5
ββββββββββ 92.7% of cost
Tokens: 3.5M
Haiku 4.5
ββββββββββ 7.3% of cost
Tokens: 336.7K
π TOKEN DISTRIBUTION
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Input: 0.1% ββββββββββ
Output: 0.3% ββββββββββ
Cache writes: 9.6% ββββββββββ
Cache reads: 90.0% ββββββββββ
β‘ EFFICIENCY METRICS
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Tool Intensity: Minimal - early session or simple tasks
46 tools (15.3 tools/msg) across 3 msgs
Response Verbosity: Concise - brief responses
4.4K tokens/msg average
Output/Input Ratio: 3.13x
Cache Hit Rate: 90.4%
Excellent β stay in session
π SESSION METRICS
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Messages: 3 | Tools: 46
Cache Efficiency: 90.4%
Total Tokens: 3,815,792
βΉοΈ Use /cost for official billing amounts
π― TOP OPTIMIZATION ACTIONS
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
Session looks well-optimized! Keep up the good work.
π SESSION INSIGHTS
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Context Growth: Slow growth β healthy pace
4.4K tokens/msg average
Tool Pattern: Minimal - early session or simple tasks
46 tools (15.3 tools/msg)
Cache Performance: Excellent β stay in session
90.4% hit rate
For Subscription Users - Value + Optimization:
- Same dashboard with π΅ Cost Drivers (dollar amounts)
- π Trajectory section with projected costs
- Dollar savings in optimization recommendations
- API-equivalent estimates with 10% safety margin
Architecture: TypeScript executed via npx tsx (no compilation needed)
Claude Code Features Used:
-
Status Line Command (
~/.claude/settings.json)- Not a hook - direct command execution by Claude Code
- Invoked automatically on every interaction
- Receives JSON stdin:
{session_id, model, context_window, ...} - Returns formatted string to status bar
-
Custom Slash Command (
~/.claude/commands/trip.md)- User-invocable skill via
/trip - Assistant executes command with
--trip-computerflag - Assistant displays output in code block (instructed by skill docs)
- No hooks involved - pure command execution
- User-invocable skill via
-
No Hooks Used (v0.11.0+)
- Old bash version (<0.11.0) used SessionEnd hooks for automatic session-end stats
- v0.11.0 removed all hooks - uses only status line command + slash command
- Installer automatically removes old SessionEnd hooks from settings.json
Status Line Flow:
User interaction β Claude Code invokes status line command
β Script reads stdin (session_id, model, context)
β Parses transcript: ~/.claude/projects/<project>/<session>.jsonl
β Deduplicates tokens by requestId + model
β Aggregates per-model, calculates costs
β Returns: "π¬ X msgs (Model) | π§ X tools | ..."
Trip Computer Flow:
User types /trip β Assistant invokes skill
β Skill executes: npx tsx src/index.ts --trip-computer
β Same parsing + deduplication + analytics computation
β Outputs dashboard to stdout
β Assistant copies output to response (per skill instructions)
Session Caching:
- 5-second TTL cache in
~/.claude/session-stats/<session_id>.json - Cache invalidated when transcript mtime changes
- ~10ms cache hits vs ~200ms misses (90% hit rate typical)
Transcript Deduplication Algorithm:
// Group by requestId + model, take MAX tokens per request
const dedupKey = `${requestId}|${modelId}`;
requestUsage.input = Math.max(requestUsage.input, usage.input_tokens);
// Then aggregate into per-model totalsCross-Project Agent Discovery:
- Extracts agent IDs from main transcript:
/agent-[a-z0-9]+/g - Searches all
~/.claude/projects/*/agent-*.jsonlfiles - Includes agent usage in cost calculation (agents are billable)
Zero Dependencies: Uses only Node.js stdlib (no npm install needed)
β
Multi-line status display - Session metrics + tool activity + agents + todos
β
Git branch integration - Shows branch name with dirty indicator (πΏ main*)
β
Session duration - Time since session started (β±οΈ 31m)
β
Tool activity tracking - Top 5 tools by frequency with accurate counts
β
Agent status display - Running and completed agents with duration
β
Todo progress - Current task and completion status
β
Accurate tool counts - Aggregates ALL tools (improvement over claude-hud's last 20)
β Session health scoring - 0-100 automated assessment with 5-star rating β Model mix visibility - See which models used with cost breakdown β Cost drivers breakdown - Visual analysis of input/output/cache patterns β Efficiency metrics - Tool intensity, response verbosity, cache hit rate β Prioritized recommendations - Top 3 actions ranked by impact β Billing mode differentiation - Adapts for API (π³) or Subscription (π ) users
β
Best-effort estimates - Transcript-based calculations typically within 5-15% of /cost
β
Model-aware pricing - All versions: Opus 3/4/4.5, Sonnet 3.7/4/4.5, Haiku 3/3.5/4.5
β
Accurate cache pricing - Model-specific multipliers (including Haiku 3 exception)
β
Token deduplication - Groups by requestId to avoid inflation
β
Cross-project agent tracking - Finds agent transcripts across all projects
β
Real-time updates - Status line refreshes automatically
Speedometer vs. Odometer:
- Trip Computer = Speedometer (real-time insights for decision making)
- /cost command = Odometer (authoritative billing from Anthropic)
- Both are valuable: Use trip computer for session optimization,
/costfor billing verification
Immediate Decision Making:
- "This is getting expensive, let me switch to Haiku"
- "Cache efficiency is great, stay in this session"
- "This task used 3.8M tokens - worth tracking"
Cost Awareness:
- Track session efficiency in real-time
- Understand which workflows are expensive
- Learn to use appropriate models
- Improve cost efficiency over time
Session vs Billing:
- Trip Computer = Real-time session insights
/cost= Final billing verification- Both are valuable for complete awareness
| Model | Input | Output | Cache Write (5m) | Cache Read |
|---|---|---|---|---|
| Opus 4.5 | $5/MTok | $25/MTok | $6.25/MTok | $0.50/MTok |
| Opus 3/4/4.1 | $15/MTok | $75/MTok | $18.75/MTok | $1.50/MTok |
| Sonnet 3.7/4/4.5 | $3/MTok | $15/MTok | $3.75/MTok | $0.30/MTok |
| Haiku 4.5 | $1/MTok | $5/MTok | $1.25/MTok | $0.10/MTok |
| Haiku 3.5 | $0.80/MTok | $4/MTok | $1/MTok | $0.08/MTok |
| Haiku 3 | $0.25/MTok | $1.25/MTok | $0.30/MTok* | $0.03/MTok* |
*Haiku 3 uses different cache multipliers: 1.20x for writes, 0.12x for reads
Subscriptions: Pro ($20/mo), Max 5x ($100/mo), Max 20x ($200/mo)
Limitation: Context tracking is only available when running as a status line command. Direct execution via bash doesn't receive stdin from Claude Code.
Why: Claude Code only provides stdin data (context_window, model) to processes invoked as status line commands.
Workaround: Use /context command for accurate context information.
Current Behavior: When you use /clear, stats reset to zero (new session, new transcript).
Why: Each session has its own transcript file for isolation and simplicity.
Desired Future: Cumulative stats across /clear within same Claude Code instance.
Workaround: Note costs before /clear if tracking total spending across resets.
These are session-level estimates from transcript data, typically accurate within 5-15% of the /cost command. Differences occur due to:
- Web search costs (may not appear in transcript usage)
- Background operations
- Timing variations (transcript lag)
- API measurement methods
For official billing amounts, always use the /cost command. For subscription users, these show API-equivalent costs - your actual usage is included in your plan.
Language: TypeScript with ES2022 modules
Runtime: Node.js 18+ (via tsx for direct TS execution)
Dependencies: Zero npm packages (stdlib only)
Entry Point: src/index.ts
Modules: Transcript parser, analytics computer, renderers, cache manager, usage API client
Data Flow: stdin β transcript parse β analytics compute β cache β render
Potential improvements for future versions:
- Rate limit display - Show OAuth rate limits in status line (library implemented)
- Cumulative stats across
/clear- Track within same instance, reset on close - Cost history tracking - Session-over-session trends
- Budget alerts - Configurable spending warnings
- Export stats - CSV/JSON for analysis
- Time tracking integration - Link sessions to work periods
- Team analytics - Aggregate across multiple users
- Custom pricing profiles - User-defined rates
- Global npm package -
npm install -gfor source-independent installation - Cross-platform Node.js installer -
node install.jsfor pure Windows without Git Bash
Installation issues? Check TROUBLESHOOTING.md
Questions? Review CLAUDE.md for technical details
Want to contribute? See CONTRIBUTING.md
Need help? Verify Node.js 18+ is installed: node --version
Ready to use? Add to ~/.claude/settings.json and restart Claude Code!