X Smart Read
by @nevaaron
Personal X (Twitter) analytics — timeline engagement, mentions, follower tracking, read any tweet/thread, bookmarks, and combined briefings via X API v2. Cos...
Run setup first (imports credentials from ~/.openclaw/.env or prompts interactively):
uv run scripts/x_setup.py
1. Never call the same command twice in one conversation unless the user explicitly asks for fresh data. The scripts cache locally — if you already ran recent this session, just reference those results.
2. Prefer top over recent for repeat questions. top reads from the local store for free ($0). recent hits the API ($0.005).
3. Don't use --context on mentions by default. It costs an extra $0.005 per reply thread it fetches. Only add it if the user specifically asks "what were they replying to?"
4. Use --max 5 for quick checks. Default is 10-20. If the user just wants a summary, pull fewer.
5. Use --hours 24 for briefings. Don't pull the full timeline when they just want "what happened today."
6. Never run all scripts unprompted. If the user asks "what's happening on my X?", use x_briefing.py instead of running 3 separate commands.
7. For accountability checks, use activity only. It's a single API call. Don't also pull mentions and profile — that triples the cost.
8. top and refresh are your friends. top is free (local data). refresh TWEET_ID updates just one tweet ($0.005) — use it when they ask "how's my last post doing?" instead of re-pulling the whole timeline.
9. Watch the daily spend total. Every command output shows "Today's spend: $X.XXX". If it's approaching the budget limit, tell the user before making more calls.
10. Never loop or retry on your own. If a command fails (402, rate limit, etc.), report the error. Don't retry automatically.
11. x_read.py caches tweets — if the user asks about the same tweet again, it's already in the local store. No need to re-fetch.
12. Use x_briefing.py for morning briefings instead of running timeline + mentions + user separately. It's cheaper ($0.02 vs $0.02 for 3 separate commands) and cleaner output.
Cost Reference
| Action | Cost | When to use |
|--------|------|-------------|
| x_briefing.py | $0.02 | Morning briefing — one command does it all |
| recent | $0.005 | Once per briefing, or when user asks for new posts |
| top | $0 | Anytime — serves from local store |
| activity | $0.005 | Accountability check, once per session max |
| refresh ID | $0.005 | User asks about a specific post's performance |
| mentions recent | $0.005 | Once per briefing, or user asks about replies |
| mentions --context | $0.005-0.03 | Only when user explicitly wants reply context |
| x_read.py URL | $0.005 | User sends a tweet URL or asks to read a post |
| x_read.py --thread | $0.005-0.01 | User asks for full thread |
| x_bookmarks.py list | $0.005 | User wants to see saved bookmarks |
| x_bookmarks.py add/remove | $0 | Write actions are free |
| user me | $0.01 | Profile check, once per day is plenty |
| user me --track | $0.01 | Morning brief only — saves follower delta |
| user lookup | $0.01 | Only when user asks about another account |
| --spend-report | $0 | Check spending anytime |
| --dry-run | $0 | Preview cost before any command |
Budget Modes
The user can set a budget enforcement mode via x_setup.py --budget-mode:
Budget Tiers
The user set a daily budget during setup. The scripts will warn and block when the limit is hit:
If blocked, tell the user: "Daily X API budget reached. Use --force to override, or wait until tomorrow."
What NOT to do
--no-cache unless debugginguser lookup on multiple accounts in a looprecent + mentions + user in one response — use x_briefing.py insteadclawhub install x-smart-read