public-clis/rdt-cli(新しいタブで開きます)
主要言語: Python
Reddit in your terminal 📖 — Browse feeds, read posts, search, upvote, save, subscribe
- star 数
- 546
- watcher 数
- 1
- fork 数
- 64
- issue 数
- 17
- 最終更新
- 2026/03/21
主要言語: Python
Reddit in your terminal 📖 — Browse feeds, read posts, search, upvote, save, subscribe
A CLI for Reddit — browse feeds, read posts, search, and interact via reverse-engineered API 📖
--subs-only)--expand-more loads additional more comments entriesrdt show 3 to read, rdt open 3 to browser-o file.json on any listingsec-ch-ua alignment, Gaussian jitter, exponential backoff--yaml, --json, --output FILE, --compact, --full-textok/schema_version/data/error--compact for token-efficient outputAI Agent Tip: Prefer
--yamlfor structured output unless strict JSON is required. Non-TTY stdout defaults to YAML automatically. Use--compactto reduce token usage.
# Recommended: uv tool (fast, isolated) uv tool install rdt-cli # Or: pipx pipx install rdt-cli
Upgrade to the latest version:
uv tool upgrade rdt-cli
# Or: pipx upgrade rdt-cliFrom source:
git clone git@github.com:jackwener/rdt-cli.git
cd rdt-cli
uv sync# ─── Auth ───────────────────────────────────────── rdt login # Extract cookies from browser rdt status # Check login status rdt status --json # Structured JSON envelope rdt whoami # Detailed profile (karma, account age) rdt logout # Clear saved cookies # ─── Browse ─────────────────────────────────────── rdt feed # Home feed (requires login) rdt feed --subs-only # Subscriptions-only feed (no algorithm) rdt feed --subs-only -n 5 --max-subs 10 # Limit per-sub posts and max subs rdt popular # Popular posts rdt popular --full-text # Show full titles rdt all # /r/all rdt sub python # Browse subreddit rdt sub programming -s top -t week # Sort + time filter rdt sub-info python # Subreddit info (subscribers, etc.) rdt user spez # User profile rdt user-posts spez # User's submitted posts rdt user-comments spez # User's comments rdt saved # Your saved posts/items rdt upvoted # Your upvoted posts # Short index works after list commands (feed/popular/sub/search) rdt sub python rdt show 1 # Read post #1 from listing rdt open 1 # Open post #1 in browser rdt upvote 1 # Upvote post #1 # ─── Reading ────────────────────────────────────── rdt read 1abc123 # Read post by ID rdt read 1abc123 --expand-more # Expand top-level "more comments" rdt show 3 # Read result #3 from last listing rdt show 3 --expand-more # Expand additional comments from cache-backed post rdt show 1 -s top # Sort comments by top rdt open 3 # Open in browser # ─── Search ─────────────────────────────────────── rdt search "python async" # Global search rdt search "rust vs go" -r programming # Within subreddit rdt search "ML" -s top -t year # Sort by top, last year rdt search "AI" -o results.json # Save to file rdt search "rust" --compact --json # Compact agent output # ─── Export ─────────────────────────────────────── rdt export "python tips" -n 100 -o tips.csv rdt export "rust" --format json -o results.json # ─── Interactions (require login) ───────────────── rdt upvote 3 # Upvote result #3 rdt upvote 3 --down # Downvote rdt upvote 3 --undo # Remove vote rdt save 3 # Save result #3 rdt save 3 --undo # Unsave rdt subscribe python # Subscribe to r/python rdt subscribe python --undo # Unsubscribe rdt comment 3 "Great post!" # Comment on result #3
rdt-cli supports browser cookie extraction to authenticate with Reddit:
~/.config/rdt-cli/credential.jsonrdt login automatically tries all installed browsers and uses the first one with valid cookies.
Saved cookies are valid for 7 days by default. After that, the client automatically attempts to refresh from the browser. If browser extraction fails, the existing cookies are used with a warning.
After any listing command such as feed, popular, all, sub, or search, the CLI stores the latest ordered post list in ~/.config/rdt-cli/index_cache.json.
rdt show <N> reads the Nth post from the latest listingrdt open <N> opens the Nth post in the browserrdt upvote <N>, rdt save <N>, rdt comment <N> reuse the same short index| Variable | Default | Description |
|---|---|---|
OUTPUT |
auto |
Output format: json, yaml, rich, or auto (→ YAML when non-TTY) |
rdt-cli includes anti-detection measures designed to minimize risk:
sec-ch-ua, sec-ch-ua-platform, sec-ch-ua-mobile are all consistent (Chrome 133)All --json / --yaml output uses the shared envelope from SCHEMA.md:
ok: true schema_version: "1" data: { ... }
When stdout is not a TTY (e.g., piped or invoked by an AI agent), output defaults to YAML.
Use OUTPUT=yaml|json|rich|auto to override.
rdt-cli ships with a SKILL.md that teaches AI agents how to use it.
npx skills add jackwener/rdt-cli
| Flag | Description |
|---|---|
-g |
Install globally (user-level, shared across projects) |
-a claude-code |
Target a specific agent |
-y |
Non-interactive mode |
mkdir -p .agents/skills git clone git@github.com:jackwener/rdt-cli.git .agents/skills/rdt-cli
⚠️ ClawHub 安装方式已过时,不再支持。请使用上方的 Skills CLI 或手动安装。
rdt_cli/
├── __init__.py # Version
├── __main__.py # python -m rdt_cli entry point
├── cli.py # Click entry point & command registration
├── client.py # Reddit API client (rate-limit, retry, anti-detection)
├── auth.py # Cookie authentication + TTL refresh
├── constants.py # URLs, headers, sort options
├── exceptions.py # Error hierarchy (6 exception types)
├── index_cache.py # Short-index cache for show/open commands
└── commands/
├── _common.py # Shared helpers (envelope, output routing, formatters)
├── auth.py # login, logout, status, whoami
├── browse.py # feed, popular, all, sub, sub-info, user, user-posts, user-comments, saved, upvoted, open
├── post.py # read, show
├── search.py # search, export
└── social.py # upvote, save, subscribe, comment
# Install dependencies uv sync # Run tests uv run pytest tests/ -v # Unit tests only (no network) uv run pytest tests/ -v -m "not smoke" # Smoke tests (need cookies) uv run pytest tests/ -v -m smoke # Lint uv run ruff check .
Q: No Reddit cookies found
rdt login (auto-detects browser)Q: database is locked
Close the browser Cookie database lock — close browser, then retry rdt login.
Q: Session expired
Your cookies have expired. Run rdt logout && rdt login to refresh.
Q: Rate limited
Wait and retry; the built-in exponential backoff handles this automatically.
Q: Requests are slow
The built-in Gaussian jitter delay (~1s between requests) is intentional to mimic natural browsing and avoid triggering Reddit's rate limiting.
--subs-only)--expand-more 可展开额外评论rdt show 3 阅读、rdt open 3 浏览器打开--yaml / --json,非 TTY 默认输出 YAML# 推荐:uv tool(快速、隔离环境) uv tool install rdt-cli # 或者:pipx pipx install rdt-cli
升级到最新版本:
uv tool upgrade rdt-cli
# 或:pipx upgrade rdt-cli从源码安装:
git clone git@github.com:jackwener/rdt-cli.git
cd rdt-cli
uv sync# 认证 rdt login # 从浏览器提取 Cookie rdt status # 检查登录状态 rdt whoami # 查看用户资料 rdt logout # 清除缓存的 Cookie # 浏览 rdt feed # 首页 Feed(需要登录) rdt feed --subs-only # 纯订阅 Feed(无算法推荐) rdt feed --subs-only -n 5 --max-subs 10 # 限制每个 sub 帖子数和最大 sub 数 rdt popular # 热门帖子 rdt all # /r/all rdt sub python # 浏览子版块 rdt sub programming -s top -t week # 排序 + 时间过滤 rdt sub-info python # 子版块信息 rdt user spez # 用户资料 rdt user-posts spez # 用户发帖 rdt user-comments spez # 用户评论 rdt saved # 你的收藏 rdt upvoted # 你的点赞 # 阅读 rdt read 1abc123 # 按 ID 阅读帖子 rdt read 1abc123 --expand-more # 展开更多评论 rdt show 3 # 阅读最近一次列表里的第 3 条 rdt show 3 --expand-more # 展开缓存帖子里的更多评论 rdt open 3 # 在浏览器打开 # 搜索 rdt search "python async" # 全局搜索 rdt search "rust vs go" -r programming # 在子版块内搜索 rdt export "python tips" -n 100 -o tips.csv # 导出 # 互动(需要登录) rdt upvote 3 # 点赞 rdt save 3 # 收藏 rdt subscribe python # 订阅 rdt comment 3 "Great post!" # 评论
rdt-cli 支持浏览器 Cookie 提取来认证 Reddit:
~/.config/rdt-cli/credential.json 加载Cookie 保存后有效期 7 天,超时后自动尝试从浏览器刷新。
No Reddit cookies found — 请先在任意浏览器打开 https://www.reddit.com/ 并登录,然后执行 rdt logindatabase is locked — 关闭浏览器后重试Session expired — Cookie 过期,执行 rdt logout && rdt login 刷新Rate limited — 等待重试,内置指数退避会自动处理rdt-cli 自带 SKILL.md,让 AI Agent 能自动学习并使用本工具。
npx skills add jackwener/rdt-cli
| 参数 | 说明 |
|---|---|
-g |
全局安装(用户级别,跨项目共享) |
-a claude-code |
指定目标 Agent |
-y |
非交互模式 |
mkdir -p .agents/skills git clone git@github.com:jackwener/rdt-cli.git .agents/skills/rdt-cli
⚠️ ClawHub 安装方式已过时,不再支持。请使用上方的 Skills CLI 或手动安装。
Apache-2.0