crush stats command generates and displays detailed usage statistics including token usage, costs, activity patterns, and tool usage analytics.
Usage
Description
Generate and display comprehensive usage statistics in a beautiful HTML dashboard. The stats include:- Total statistics: Sessions, tokens, costs, messages
- Daily usage: Token consumption and costs over time
- Model usage: Which models you use most
- Hourly patterns: When you’re most active
- Day of week: Activity by day
- Recent activity: Last 30 days of usage
- Tool usage: Which tools are called most frequently
- Heatmap: Hour-by-day activity visualization
- Response times: Average AI response times
Global Flags
Custom Crush data directory. Specify which Crush database to analyze.
--debug
Output
The command generates an HTML file with interactive charts and visualizations:Examples
Statistics Breakdown
Total Stats
Overall usage metrics:- Total Sessions: Number of Crush sessions
- Total Messages: Messages exchanged with AI
- Total Tokens: Combined prompt and completion tokens
- Prompt Tokens: Tokens sent to the AI
- Completion Tokens: Tokens generated by the AI
- Total Cost: Estimated cost in USD
- Average Tokens per Session: Mean token usage per session
- Average Messages per Session: Mean message count per session
Usage by Day
Daily breakdown showing:- Date
- Prompt tokens
- Completion tokens
- Total tokens
- Cost
- Session count
Usage by Model
Model usage statistics:- Model name (e.g.,
claude-sonnet-4-20250514) - Provider (e.g.,
anthropic) - Message count
Usage by Hour
Activity distribution across 24 hours:- Hour (0-23)
- Session count
Usage by Day of Week
Weekly activity patterns:- Day name (Sunday through Saturday)
- Session count
- Prompt tokens
- Completion tokens
Recent Activity
Last 30 days of activity:- Date
- Session count
- Total tokens
- Cost
Tool Usage
Frequency of tool calls:- Tool name (e.g.,
bash,edit,read) - Call count
Hour-Day Heatmap
Visualize activity across hours and days:- X-axis: Hours (0-23)
- Y-axis: Days of week
- Color intensity: Session count
Average Response Time
Mean response time from the AI in milliseconds.Generated HTML
The statistics page includes:- Interactive charts: Built with JavaScript charting library
- Responsive design: Works on desktop and mobile
- Embedded styling: Self-contained HTML file
- Branding: Crush logo and styling
- Metadata: Generation date, project name, username
File Structure
- CSS styling
- JavaScript code
- SVG graphics
- Statistics data (JSON)
Example Output
When you run the command:Error Messages
No Data Available
Failed to Initialize Config
Failed to Connect to Database
Browser Doesn’t Open
Data Source
Statistics are gathered from the SQLite database at:- Sessions table: Session metadata
- Messages table: All messages with token counts
- Tool calls: Records of tool invocations
- Timestamps: For time-based analysis
Privacy & Analytics
The stats command:- Runs locally: No data is sent to external servers
- Reads from local DB: Only accesses your local Crush database
- Generates local HTML: Output is saved to your filesystem
- No telemetry: Statistics generation doesn’t trigger any metrics
Use Cases
Cost Tracking
Monitor your AI API spending:Usage Optimization
Identify patterns to optimize your workflow:- Which models you use most
- Peak productivity hours
- Most-used tools
- Average session length
Team Reporting
Share usage insights:Billing & Budgeting
Track costs for:- Personal budget management
- Project cost allocation
- Client billing
- Team cost analysis
Telemetry
Runningcrush stats triggers an analytics event:
CRUSH_DISABLE_METRICS=trueenvironment variableDO_NOT_TRACK=trueenvironment variable"disable_metrics": trueincrush.json
See Also
crush logs- View Crush logs- Configuration - Understanding configuration
- Metrics - Understanding metrics and privacy