Skill by
ara.so — Devtools Skills collection.
由
ara.so开发的Skill工具——Devtools Skills系列工具之一。
is a Python-based terminal CLI for Twitter/X that works without API keys. It uses browser cookie authentication to read timelines (For You, Following), bookmarks, search results, user profiles, and post/delete tweets. All commands support structured output (
,
) for AI agent pipelines.
Key capabilities:
- Read: feed, bookmarks, search, tweet detail, article, list timeline, user lookup
- Write: post, reply, quote, delete, like, retweet, bookmark
- Auth: browser cookie extraction (Arc/Chrome/Edge/Firefox/Brave) or env vars
- Anti-detection: TLS fingerprinting, full cookie forwarding, request jitter
- Output: rich tables (default), JSON, YAML, Markdown (articles)
是一款基于Python的Twitter/X终端CLI工具,无需API密钥即可使用。它通过浏览器Cookie认证来浏览时间线(为你推荐、关注列表)、书签、搜索结果、用户资料,还能发布/删除推文。所有命令都支持结构化输出(
、
),适用于AI Agent流水线。
核心功能:
- 浏览:动态、书签、搜索、推文详情、文章、列表时间线、用户查询
- 操作:发布、回复、引用、删除、点赞、转发、收藏
- 认证:浏览器Cookie提取(Arc/Chrome/Edge/Firefox/Brave)或环境变量
- 反检测:TLS指纹识别、完整Cookie转发、请求抖动
- 输出:丰富表格(默认)、JSON、YAML、Markdown(文章)
Recommended: uv tool (fast, isolated)
推荐:uv工具(快速、隔离)
uv tool install twitter-cli
uv tool install twitter-cli
Alternative: pipx
替代方案:pipx
uv tool upgrade twitter-cli
**From source:**
```bash
git clone git@github.com:jackwener/twitter-cli.git
cd twitter-cli
uv sync
uv tool upgrade twitter-cli
**从源码安装:**
```bash
git clone git@github.com:jackwener/twitter-cli.git
cd twitter-cli
uv sync
Priority order:
- Environment variables: +
- Browser cookies (auto-extracted from Arc/Chrome/Edge/Firefox/Brave)
Browser cookie extraction (recommended):
优先级顺序:
- 环境变量: +
- 浏览器Cookie(自动从Arc/Chrome/Edge/Firefox/Brave提取)
浏览器Cookie提取(推荐):
Auto-detect browser and extract all Twitter cookies
自动检测浏览器并提取所有Twitter Cookie
Specify browser explicitly
明确指定浏览器
TWITTER_BROWSER=chrome twitter feed
TWITTER_BROWSER=chrome twitter feed
Chrome multi-profile
Chrome多配置文件
TWITTER_CHROME_PROFILE="Profile 2" twitter feed
**Manual environment variables:**
```bash
export TWITTER_AUTH_TOKEN="your_auth_token"
export TWITTER_CT0="your_ct0_token"
twitter feed
Proxy support:
bash
export TWITTER_PROXY=http://127.0.0.1:7890
TWITTER_CHROME_PROFILE="Profile 2" twitter feed
**手动设置环境变量:**
```bash
export TWITTER_AUTH_TOKEN="你的auth_token"
export TWITTER_CT0="你的ct0_token"
twitter feed
代理支持:
bash
export TWITTER_PROXY=http://127.0.0.1:7890
export TWITTER_PROXY=socks5://127.0.0.1:1080
export TWITTER_PROXY=socks5://127.0.0.1:1080
For You feed (default)
为你推荐动态(默认)
twitter feed -t following
twitter feed -t following
Full text (no truncation)
完整文本(不截断)
Structured output for agents
供Agent使用的结构化输出
twitter feed --json
twitter feed --yaml
twitter feed --json
twitter feed --yaml
twitter feed --filter --max 50
twitter feed --filter --max 50
twitter feed --cursor "DAABCgABGdE..."
twitter feed --cursor "DAABCgABGdE..."
twitter search "AI agent"
twitter search "AI agent"
Search type: Top, Latest, Photos, Videos
搜索类型:热门、最新、图片、视频
twitter search "machine learning" -t Latest
twitter search "machine learning" -t Latest
Full text + JSON output
完整文本 + JSON输出
twitter search "python" --full-text --json
twitter search "python" --full-text --json
twitter search "climate" --from scientist --lang en --since 2026-01-01
twitter search "news" --exclude retweets --has links
twitter search "climate" --from scientist --lang en --since 2026-01-01
twitter search "news" --exclude retweets --has links
twitter search "trending" -o results.json
twitter search "trending" -o results.json
Apply ranking filter
应用排序过滤
twitter search "tech" --filter
twitter search "tech" --filter
Limit + full text
限制数量 + 完整文本
twitter bookmarks --max 30 --full-text
twitter bookmarks --max 30 --full-text
Tweet Detail (tweet + replies)
推文详情(推文 + 回复)
Full text in reply table
回复表格显示完整文本
twitter tweet 1234567890 --full-text
twitter tweet 1234567890 --full-text
twitter tweet 1234567890 --json
twitter tweet 1234567890 --json
Show Command (open tweet by index)
展示命令(按索引打开推文)
twitter show 2 # Open tweet #2 from last list
twitter show 2 --full-text
twitter show 2 --json
twitter show 2 # 打开上次列表中的第2条推文
twitter show 2 --full-text
twitter show 2 --json
Twitter Article (fetch and export as Markdown)
Twitter文章(获取并导出为Markdown)
twitter article 1234567890
twitter article 1234567890
Export as Markdown
导出为Markdown格式
twitter article 1234567890 --markdown
twitter article 1234567890 --output article.md
twitter article 1234567890 --markdown
twitter article 1234567890 --output article.md
twitter article 1234567890 --json
twitter article 1234567890 --json
Fetch tweets from a Twitter List
获取Twitter列表中的推文
twitter list 1539453138322673664
twitter list 1539453138322673664
twitter list 1539453138322673664 --cursor "DAABCgABGdE..."
twitter list 1539453138322673664 --cursor "DAABCgABGdE..."
twitter list 1539453138322673664 --full-text
twitter list 1539453138322673664 --full-text
twitter user-posts elonmusk --max 20
twitter user-posts elonmusk --full-text -o tweets.json
twitter user-posts elonmusk --max 20
twitter user-posts elonmusk --full-text -o tweets.json
User likes (own account only, private since Jun 2024)
用户点赞(仅自己账号可用,2024年6月起为私有)
twitter likes elonmusk --max 30
twitter likes elonmusk --max 30
twitter followers elonmusk --max 50
twitter followers elonmusk --max 50
twitter following elonmusk --max 50
twitter following elonmusk --max 50
twitter post "Hello from twitter-cli!"
twitter post "Hello from twitter-cli!"
Tweet with image (up to 4)
带图片的推文(最多4张)
twitter post "Hello!" --image photo.jpg
twitter post "Gallery" -i a.png -i b.jpg -i c.webp
twitter post "Hello!" --image photo.jpg
twitter post "Gallery" -i a.png -i b.jpg -i c.webp
twitter post "Hello from twitter-cli!" --json
twitter post "Hello from twitter-cli!" --json
twitter post "Nice!" --reply-to 1234567890
twitter post "Nice!" --reply-to 1234567890
twitter reply 1234567890 "Great!" -i screenshot.png
twitter reply 1234567890 "Great!" -i screenshot.png
twitter quote 1234567890 "Check this out"
twitter quote 1234567890 "Check this out"
twitter quote 1234567890 "Look at this chart" -i chart.png
twitter quote 1234567890 "Look at this chart" -i chart.png
bash
twitter delete 1234567890
bash
twitter delete 1234567890
bash
twitter like 1234567890
twitter like 1234567890 --yaml
twitter unlike 1234567890
bash
twitter like 1234567890
twitter like 1234567890 --yaml
twitter unlike 1234567890
Retweet / Unretweet
转发 / 取消转发
bash
twitter retweet 1234567890
twitter unretweet 1234567890
bash
twitter retweet 1234567890
twitter unretweet 1234567890
Bookmark / Unbookmark
收藏 / 取消收藏
bash
twitter bookmark 1234567890
twitter unbookmark 1234567890
bash
twitter bookmark 1234567890
twitter unbookmark 1234567890
Follow / Unfollow
关注 / 取消关注
bash
twitter follow elonmusk --json
twitter unfollow elonmusk
bash
twitter follow elonmusk --json
twitter unfollow elonmusk
Create
in your working directory:
yaml
fetch:
count: 50
filter:
mode: "topN" # "topN" | "score" | "all"
topN: 20
minScore: 50
lang: []
excludeRetweets: false
weights:
likes: 1.0
retweets: 3.0
replies: 2.0
bookmarks: 5.0
views_log: 0.5
rateLimit:
requestDelay: 2.5 # base delay (randomized ×0.7–1.5)
maxRetries: 3
retryBaseDelay: 5.0
maxCount: 200
Scoring formula:
text
score = likes_w * likes
+ retweets_w * retweets
+ replies_w * replies
+ bookmarks_w * bookmarks
+ views_log_w * log10(max(views, 1))
Filter modes:
- : Keep highest N tweets by score
- : Keep tweets where score >= minScore
- : Return all tweets sorted by score
yaml
fetch:
count: 50
filter:
mode: "topN" # "topN" | "score" | "all"
topN: 20
minScore: 50
lang: []
excludeRetweets: false
weights:
likes: 1.0
retweets: 3.0
replies: 2.0
bookmarks: 5.0
views_log: 0.5
rateLimit:
requestDelay: 2.5 # 基础延迟(随机乘以0.7–1.5)
maxRetries: 3
retryBaseDelay: 5.0
maxCount: 200
评分公式:
text
score = likes_w * likes
+ retweets_w * retweets
+ replies_w * replies
+ bookmarks_w * bookmarks
+ views_log_w * log10(max(views, 1))
过滤模式:
- : 保留评分最高的N条推文
- : 保留评分≥minScore的推文
- : 返回所有按评分排序的推文
AI Agent Usage
AI Agent 用法
All commands support
or
for structured output. Non-TTY stdout defaults to YAML.
Example: Fetch and parse timeline
python
import subprocess
import yaml
result = subprocess.run(
["twitter", "feed", "--max", "10", "--yaml"],
capture_output=True,
text=True,
check=True
)
data = yaml.safe_load(result.stdout)
for tweet in data["tweets"]:
print(f"{tweet['author']['username']}: {tweet['text']}")
Example: Post tweet from Python
python
import subprocess
import json
result = subprocess.run(
["twitter", "post", "Hello from Python!", "--json"],
capture_output=True,
text=True,
check=True
)
response = json.loads(result.stdout)
print(f"Tweet ID: {response['tweetId']}")
Example: Search and filter
所有命令都支持
或
结构化输出。非TTY标准输出默认使用YAML格式。
示例:获取并解析时间线
python
import subprocess
import yaml
result = subprocess.run(
["twitter", "feed", "--max", "10", "--yaml"],
capture_output=True,
text=True,
check=True
)
data = yaml.safe_load(result.stdout)
for tweet in data["tweets"]:
print(f"{tweet['author']['username']}: {tweet['text']}")
示例:通过Python发布推文
python
import subprocess
import json
result = subprocess.run(
["twitter", "post", "Hello from Python!", "--json"],
capture_output=True,
text=True,
check=True
)
response = json.loads(result.stdout)
print(f"推文ID: {response['tweetId']}")
示例:搜索并过滤
Get top 10 AI tweets from today as JSON
获取今日关于AI agent的前10条推文,格式为JSON
twitter search "AI agent" --since 2026-05-17 --filter --max 10 --json
**Structured output contract:** See [SCHEMA.md](https://github.com/jackwener/twitter-cli/blob/main/SCHEMA.md)
twitter search "AI agent" --since 2026-05-17 --filter --max 10 --json
**结构化输出规范:** 查看[SCHEMA.md](https://github.com/jackwener/twitter-cli/blob/main/SCHEMA.md)
Export bookmarks to file
将书签导出到文件
bash
twitter bookmarks --max 100 --json > bookmarks.json
bash
twitter bookmarks --max 100 --json > bookmarks.json
Monitor user tweets
监控用户推文
Fetch latest 5 tweets from user
获取用户最新5条推文
twitter user-posts elonmusk --max 5 --yaml
twitter user-posts elonmusk --max 5 --yaml
Search and rank by engagement
搜索并按互动量排序
Top 10 tweets about "AI" by score
关于"AI"的前10条高评分推文
twitter search "AI" --filter --max 10 --full-text
twitter search "AI" --filter --max 10 --full-text
Post with multiple images
发布多张图片的推文
bash
twitter post "My photo gallery" -i img1.jpg -i img2.png -i img3.webp
bash
twitter post "My photo gallery" -i img1.jpg -i img2.png -i img3.webp
Reply to tweet with image
带图片回复推文
bash
twitter reply 1234567890 "Here's the screenshot" -i screenshot.png
bash
twitter reply 1234567890 "Here's the screenshot" -i screenshot.png
Extract article as Markdown
将文章提取为Markdown格式
bash
twitter article 1234567890 --markdown --output ~/articles/ai-safety.md
bash
twitter article 1234567890 --markdown --output ~/articles/ai-safety.md
Use proxy for all requests
为所有请求使用代理
bash
export TWITTER_PROXY=http://127.0.0.1:7890
twitter feed --max 20
bash
export TWITTER_PROXY=http://127.0.0.1:7890
twitter feed --max 20
No Twitter cookies found
未找到Twitter Cookie
Solution:
- Log in to in a supported browser (Arc/Chrome/Edge/Firefox/Brave)
- Or set and manually
- Run with for diagnostics:
解决方案:
- 在支持的浏览器(Arc/Chrome/Edge/Firefox/Brave)中登录
- 或手动设置和
- 使用参数运行以获取诊断信息:
Cookie expired (HTTP 401/403)
Cookie过期(HTTP 401/403)
Solution: Re-login to
and retry.
Keychain access denied (macOS)
钥匙串访问被拒绝(macOS)
SSH sessions:
bash
security unlock-keychain ~/Library/Keychains/login.keychain-db
Local terminal:
- Open Keychain Access → search for "<Browser> Safe Storage"
- Access Control → add Terminal app → Save Changes
- Or click "Always Allow" when prompted
SSH会话:
bash
security unlock-keychain ~/Library/Keychains/login.keychain-db
本地终端:
- 打开钥匙串访问 → 搜索"<浏览器名称> Safe Storage"
- 访问控制 → 添加终端应用 → 保存更改
- 或在提示时点击**"始终允许"**
Twitter API error 404
Twitter API错误404
Solution: Retry command. The client attempts a live queryId fallback when GraphQL IDs rotate.
解决方案: 重试命令。当GraphQL ID更新时,客户端会尝试实时查询ID回退。
Invalid tweet JSON file
无效的推文JSON文件
Solution: Regenerate using:
bash
twitter feed --json > tweets.json
解决方案: 重新生成:
bash
twitter feed --json > tweets.json
Windows: no pipe output in AI agent subprocess
Windows:AI Agent子进程无管道输出
Issue: ConPTY intercepts pipe output from network commands.
Fix:
- Use Git Bash as terminal shell
- Set
"windowsEnableConpty": false
in terminal settings
- Standard
subprocess.run(capture_output=True)
works correctly
问题: ConPTY拦截网络命令的管道输出。
修复:
- 使用Git Bash作为终端Shell
- 在终端设置中设置
"windowsEnableConpty": false
- 标准
subprocess.run(capture_output=True)
可正常工作
Rate limiting (HTTP 429)
请求频率限制(HTTP 429)
Solution:
- Use to limit requests
- Set to avoid direct IP exposure
- Increase in
- Use residential proxies instead of datacenter IPs
解决方案:
- 使用限制请求数量
- 设置避免直接暴露IP
- 在中增加
- 使用住宅代理而非数据中心IP
- Use a proxy — set to avoid direct IP exposure
- Keep request volumes low — prefer over
- Don't run too frequently — each startup fetches x.com to initialize headers
- Use browser cookie extraction — provides full cookie fingerprint
- Avoid datacenter IPs — residential proxies are safer
- Upgrade regularly —
uv tool upgrade twitter-cli
to avoid outdated API handling
- 使用代理 — 设置避免直接暴露IP
- 控制请求量 — 优先使用而非
- 不要过于频繁运行 — 每次启动都会获取x.com以初始化请求头
- 使用浏览器Cookie提取 — 提供完整的Cookie指纹
- 避免数据中心IP — 住宅代理更安全
- 定期升级 — 使用
uv tool upgrade twitter-cli
避免API处理过时
- Rich table (default): Interactive reading in terminal
- : Show full tweet text in tables
- : Structured output for agents (default for non-TTY)
- : Strict JSON for parsers
- / : Token-efficient compact output
- : Save to file
- 丰富表格(默认):终端交互式浏览
- : 在表格中显示完整推文文本
- : 供Agent使用的结构化输出(非TTY环境默认)
- : 供解析器使用的严格JSON格式
- / : 高效压缩输出
- : 保存到文件
Install dev dependencies
安装开发依赖
text
twitter_cli/
├── cli.py # Command-line interface
├── client.py # HTTP client + anti-detection
├── graphql.py # GraphQL query IDs, URL building
├── parser.py # Tweet/User/Media parsing
├── auth.py # Cookie extraction
├── config.py # Configuration loading
├── filter.py # Ranking/scoring logic
├── formatter.py # Rich table formatting
├── output.py # JSON/YAML serialization
└── models.py # Data models (Tweet, User, Media)
text
twitter_cli/
├── cli.py # 命令行界面
├── client.py # HTTP客户端 + 反检测
├── graphql.py # GraphQL查询ID、URL构建
├── parser.py # 推文/用户/媒体解析
├── auth.py # Cookie提取
├── config.py # 配置加载
├── filter.py # 排序/评分逻辑
├── formatter.py # 丰富表格格式化
├── output.py # JSON/YAML序列化
└── models.py # 数据模型(Tweet, User, Media)
Daily AI news digest
每日AI新闻摘要
Search AI tweets from today, rank by engagement, export as JSON
搜索今日AI相关推文,按互动量排序,导出为JSON
twitter search "AI" --since 2026-05-17 --filter --max 20 --json > ai_digest.json
twitter search "AI" --since 2026-05-17 --filter --max 20 --json > ai_digest.json
python
import subprocess
import yaml
from collections import Counter
result = subprocess.run(
["twitter", "bookmarks", "--max", "200", "--yaml"],
capture_output=True, text=True, check=True
)
data = yaml.safe_load(result.stdout)
python
import subprocess
import yaml
from collections import Counter
result = subprocess.run(
["twitter", "bookmarks", "--max", "200", "--yaml"],
capture_output=True, text=True, check=True
)
data = yaml.safe_load(result.stdout)
hashtags = []
for tweet in data["tweets"]:
hashtags.extend([h["text"] for h in tweet.get("hashtags", [])])
print(Counter(hashtags).most_common(10))
hashtags = []
for tweet in data["tweets"]:
hashtags.extend([h["text"] for h in tweet.get("hashtags", [])])
print(Counter(hashtags).most_common(10))
Post with automated image
自动生成图片并发布推文
Generate chart, then post with image
生成图表,然后带图片发布推文
subprocess.run(["python", "generate_chart.py"], check=True)
subprocess.run([
"twitter", "post",
"Daily metrics update",
"-i", "chart.png",
"--json"
], check=True)
subprocess.run(["python", "generate_chart.py"], check=True)
subprocess.run([
"twitter", "post",
"Daily metrics update",
"-i", "chart.png",
"--json"
], check=True)
Monitor user and alert on keyword
监控用户推文并触发关键词提醒
Cron job: check user tweets for keyword
定时任务:检查用户推文中的关键词
tweets=$(twitter user-posts elonmusk --max 5 --yaml)
if echo "$tweets" | grep -q "Mars"; then
echo "Alert: New Mars tweet from @elonmusk"
fi
tweets=$(twitter user-posts elonmusk --max 5 --yaml)
if echo "$tweets" | grep -q "Mars"; then
echo "提醒:@elonmusk发布了关于火星的新推文"
fi