3.9 KiB
3.9 KiB
name, description, author, version, tags
| name | description | author | version | tags | |||||
|---|---|---|---|---|---|---|---|---|---|
| twitter-cli | CLI skill for Twitter/X to read timelines, bookmarks, user posts, and profiles from the terminal without API keys | jackwener | 1.0.0 |
|
twitter-cli Skill
Use this skill when the user wants to read or interact with Twitter/X content from terminal without API keys.
Prerequisites
# Install (requires Python 3.10+)
uv tool install twitter-cli
# Or: pipx install twitter-cli
Authentication
- Auto-extracts browser cookies from Chrome/Edge/Firefox/Brave.
- Or set environment variables:
TWITTER_AUTH_TOKEN+TWITTER_CT0.
Command Reference
Feed
twitter feed # Home timeline (For You)
twitter feed -t following # Following timeline
twitter feed --max 50 # Limit count
twitter feed --filter # Enable ranking filter
twitter feed --json > tweets.json # Export as JSON
twitter feed --input tweets.json # Read from local JSON file
Bookmarks
twitter favorites # List bookmarked tweets
twitter favorites --max 30 --json
twitter favorites --filter # Apply ranking filter
Search
twitter search "keyword"
twitter search "AI agent" -t Latest --max 50
twitter search "机器学习" --json
Tweet Detail
twitter tweet 1234567890 # View tweet + replies
twitter tweet https://x.com/user/status/12345 # Accepts URL too
List Timeline
twitter list 1539453138322673664 # Fetch tweets from a Twitter List
User
twitter user elonmusk # User profile
twitter user-posts elonmusk --max 20 # User's tweets
twitter likes elonmusk --max 30 # User's likes
twitter followers elonmusk --max 50 # User's followers
twitter following elonmusk --max 50 # User's following
Write Operations
twitter post "Hello from twitter-cli!" # Post tweet
twitter post "reply text" --reply-to 1234567890 # Reply
twitter delete 1234567890 # Delete tweet
twitter like 1234567890 # Like
twitter unlike 1234567890 # Unlike
twitter retweet 1234567890 # Retweet
twitter unretweet 1234567890 # Unretweet
twitter favorite 1234567890 # Bookmark
twitter unfavorite 1234567890 # Unbookmark
JSON / Scripting
twitter feed --json > tweets.json
twitter feed --input tweets.json
twitter user-posts elonmusk --json | jq '.[0].text'
twitter search "keyword" --json | jq 'length'
Ranking Filter
Filtering is opt-in (disabled by default). Enable with --filter.
twitter feed --filter
twitter favorites --filter
The scoring formula:
score = likes_w * likes
+ retweets_w * retweets
+ replies_w * replies
+ bookmarks_w * bookmarks
+ views_log_w * log10(max(views, 1))
Configure weights and mode in config.yaml.
Common Patterns for AI Agents
# Get latest tweets from a user
twitter user-posts elonmusk --max 5 --json
# Search and export for analysis
twitter search "topic" --json > results.json
# Check user profile
twitter user elonmusk --json
# Daily reading workflow
twitter feed -t following --filter
twitter favorites --filter
Error Handling
No Twitter cookies found— login tox.comin a supported browser, or set env vars.Cookie expired or invalid (HTTP 401/403)— re-login tox.comand retry.Twitter API error 404— queryId rotation, retry the command (client has live fallback).
Safety Notes
- Do not ask users to share raw cookie values in chat logs.
- Prefer local browser cookie extraction over manual secret copy/paste.
- If auth fails with 401/403, ask the user to re-login to
x.com.