Overview
The--analyze flag activates Grok’s code_interpreter tool, enabling quantitative analysis of X search results. Grok writes and executes code to compute:
- Engagement statistics (likes, reposts, replies)
- Posting frequency and velocity
- Trend patterns over time
- Sentiment distribution
- Geographic signals
- Account influence metrics
How It Works
Add the--analyze flag (or -a) to any X Search query:
- Use
x_searchto gather relevant posts - Activate
code_interpreterto process the data - Generate statistics, tables, and trend analysis
- Present findings with specific numbers and patterns
The
--analyze flag cannot be combined with --extract. Choose quantitative analysis or structured JSON output, but not both.What It Can Analyze
- Engagement metrics: Like counts, repost ratios, reply volumes
- Posting patterns: Daily/hourly frequency, peak activity times
- Trend velocity: Rate of growth or decline in discussion volume
- Sentiment distribution: Breakdown of positive/negative/neutral posts
- Company/topic mentions: Frequency tables by entity
- Geographic distribution: Where posts are originating from
- Account influence: Amplification patterns and reach
Real Example: Tech Layoffs Analysis
Tech Layoff Activity — February 2026 Analysis Grok searched X for layoff announcements and ran quantitative analysis via code interpreter across 847 relevant posts from Feb 1–Mar 4, 2026. By company (posts mentioning layoffs):Posting velocity: Layoff-related posts peaked on Feb 14 (Valentine’s Day — 203 posts in 24h) and again on Feb 28 (end-of-month HR cycles — 178 posts). Sentiment in layoff posts: 61% negative/critical, 24% neutral/informational, 15% supportive of company rationale. The supportive cluster skews toward accounts in finance and investor relations. Geographic signal: 71% of geo-tagged posts originated from US accounts, 14% from India (Salesforce and Workday have large India engineering hubs), 8% from UK. Most amplified single post: An Intel engineer’s firsthand account of receiving a severance email with 48 hours notice — 94K likes, 41K reposts, 6.2K replies. Conclusion: February 2026 is tracking ~18% above the rolling 6-month average for layoff post volume. The Intel and Salesforce announcements are dominating signal. No signs of a sectoral recovery narrative emerging yet.
Company Posts Estimated headcount reduction Salesforce 143 ~1,200 Intel 98 ~2,800 Snap 67 ~400 Twilio 54 ~350 Workday 41 ~600
Data Tables and Insights
Grok’scode_interpreter produces:
Frequency Tables
Time Series Analysis
- Peak posting times
- Day-over-day trends
- Weekly/monthly patterns
Engagement Metrics
- Average likes per post
- Repost-to-like ratios
- Viral content identification
- Amplification patterns
Statistical Summaries
- Means, medians, and distributions
- Comparative analysis (current vs. baseline)
- Outlier detection
Example Use Cases
Engagement trend analysis
Topic velocity tracking
Comparative sentiment
Event impact measurement
Combining with Other Flags
The--analyze flag works with:
--handles/--exclude: Focus analysis on specific accounts--from/--to: Analyze specific time periods--images/--videos: Include media-rich posts in analysis--citations: Get source URLs for verification
Example: Video content analysis
Constraint:
--analyze and --extract cannot be combined. Use --analyze for quantitative insights or --extract for structured JSON, but not both in the same query.When to Use Data Analysis
Choose--analyze when you need:
- Numbers and statistics rather than narrative summaries
- Trend identification across time periods
- Comparative analysis between entities or topics
- Engagement metrics to measure amplification
- Pattern detection in posting behavior or sentiment
--extract.
