Summary
Add a x-cli watch command that continuously monitors one or more X/Twitter accounts for new posts and displays them in real-time in the terminal.
Use case: Track accounts like @CheddarFlow for live options flow alerts, breaking news accounts, or any account where timely updates matter.
Proposed CLI Interface
# Watch a single account
x-cli watch CheddarFlow
# Watch multiple accounts
x-cli watch CheddarFlow unusual_whales
# Filter by keyword/ticker
x-cli watch CheddarFlow --filter "$NVDA"
# Custom poll interval (default: 60s)
x-cli watch CheddarFlow --interval 30
# Output formats work too
x-cli -j watch CheddarFlow
x-cli -p watch CheddarFlow # pipe-friendly for downstream processing
# Desktop notifications (optional)
x-cli watch CheddarFlow --notify
# Stop after N tweets
x-cli watch CheddarFlow --max 50
Implementation Plan
1. Add watch command to cli.py
- New top-level Click command
watch
- Params:
usernames (multiple), --interval (default 60), --filter, --notify, --max
- Resolves usernames to user IDs, then enters polling loop
2. Add polling logic to api.py
- New method
get_new_tweets(user_id, since_id) — wraps get_timeline() with since_id param to only fetch tweets newer than the last seen
- Twitter API v2 supports
since_id on the timeline endpoint natively
3. Watch loop (watch.py — new module)
- Core loop: poll → diff → display → sleep
- Track
last_seen_id per user to avoid duplicates
- Use
since_id API param for efficient server-side filtering
- Handle rate limits gracefully (back off on 429, show countdown)
- Clean
Ctrl+C handling with summary on exit
4. Optional: Desktop notifications
- Use
osascript on macOS for native notifications
- Fallback to terminal bell (
\a) on other platforms
- Gated behind
--notify flag
5. Optional: Keyword filtering
- Client-side text matching on tweet content
- Support multiple
--filter flags
- Case-insensitive matching
6. Output integration
- Reuse existing
format_output() formatters
- JSON mode: one JSON object per line (NDJSON) for streaming parsers
- Plain mode: TSV rows as tweets arrive
- Human mode: Rich panels with timestamp
Rate Limit Considerations
- Twitter API v2 timeline endpoint: 900 requests / 15 min window (bearer token)
- Default 60s interval = ~15 requests/15min per account — well within limits
- With 5 accounts at 30s interval = ~150 requests/15min — still safe
- Display rate limit status in verbose mode
Architecture Notes
- Fits cleanly into existing patterns: Click command → API client → formatter
since_id is the key — avoids fetching/diffing full timelines
- No new dependencies needed (httpx handles polling fine)
- Consider
asyncio for multi-account parallel polling in future
Acceptance Criteria
Summary
Add a
x-cli watchcommand that continuously monitors one or more X/Twitter accounts for new posts and displays them in real-time in the terminal.Use case: Track accounts like
@CheddarFlowfor live options flow alerts, breaking news accounts, or any account where timely updates matter.Proposed CLI Interface
Implementation Plan
1. Add
watchcommand tocli.pywatchusernames(multiple),--interval(default 60),--filter,--notify,--max2. Add polling logic to
api.pyget_new_tweets(user_id, since_id)— wrapsget_timeline()withsince_idparam to only fetch tweets newer than the last seensince_idon the timeline endpoint natively3. Watch loop (
watch.py— new module)last_seen_idper user to avoid duplicatessince_idAPI param for efficient server-side filteringCtrl+Chandling with summary on exit4. Optional: Desktop notifications
osascripton macOS for native notifications\a) on other platforms--notifyflag5. Optional: Keyword filtering
--filterflags6. Output integration
format_output()formattersRate Limit Considerations
Architecture Notes
since_idis the key — avoids fetching/diffing full timelinesasynciofor multi-account parallel polling in futureAcceptance Criteria
x-cli watch <username>polls and displays new tweets in real-time--intervalcontrols poll frequency--filterfilters tweets by keyword-j,-p,-md, default)