rdt-cli

A CLI for Reddit โ browse feeds, read posts, search, and interact via reverse-engineered API ๐
English | ไธญๆ
More Tools
- xiaohongshu-cli โ Xiaohongshu CLI for search, reading, and posting
- twitter-cli โ Twitter/X CLI for timelines, bookmarks, and posting
- bilibili-cli โ Bilibili CLI for videos, users, search, and feeds
- discord-cli โ Discord CLI for local-first sync, search, and export
- tg-cli โ Telegram CLI for local-first sync, search, and export
Features
- ๐ Auth โ auto-extract browser cookies, status check, whoami
- ๐ Feed โ browse home feed, popular, /r/all, and subscription-only feed (
--subs-only)
- ๐ Subreddits โ browse any subreddit with sort/time filters, view subreddit info
- ๐ฐ Posts โ read posts and comment trees with syntax highlighting
- ๐ฌ Expanded comments โ
--expand-more loads additional more comments entries
- ๐ข Short-index navigation โ
rdt show 3 to read, rdt open 3 to browser
- ๐ Search โ full-text search with subreddit, sort, and time filters
- ๐ค Export โ export search results to CSV or JSON;
-o file.json on any listing
- ๐ค Users โ view user profiles, post history, comment history, saved and upvoted items
- โฌ๏ธ Interactions โ upvote/downvote, save/unsave, subscribe/unsubscribe, comment (with 1.5-4s rate-limit delay)
- ๐ก๏ธ Anti-detection โ consistent Chrome 133 fingerprint,
sec-ch-ua alignment, Gaussian jitter, exponential backoff
- ๐ Structured output โ
--yaml, --json, --output FILE, --compact, --full-text
- ๐ฆ Stable envelope โ see SCHEMA.md for
ok/schema_version/data/error
- ๐ค Agent-friendly โ Rich output on stderr,
--compact for token-efficient output
AI Agent Tip: Prefer --yaml for structured output unless strict JSON is required. Non-TTY stdout defaults to YAML automatically. Use --compact to reduce token usage.
Installation
# 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-cli
From source:
git clone git@github.com:jackwener/rdt-cli.git
cd rdt-cli
uv sync
Usage
# โโโ 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
Authentication
rdt-cli supports browser cookie extraction to authenticate with Reddit:
- Saved cookies โ loads from
~/.config/rdt-cli/credential.json
- Browser cookies โ auto-detects installed browsers and extracts cookies (supports Chrome, Firefox, Edge, Brave)
rdt login automatically tries all installed browsers and uses the first one with valid cookies.
Cookie TTL
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.
Short-Index Navigation
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 listing
rdt open <N> opens the Nth post in the browser
rdt upvote <N>, rdt save <N>, rdt comment <N> reuse the same short index
- Empty listings clear the index cache, so old results are not reused by accident
Environment Variables
| Variable | Default | Description |
|---|
OUTPUT | auto | Output format: json, yaml, rich, or auto (โ YAML when non-TTY) |
Rate Limiting & Anti-Detection
rdt-cli includes anti-detection measures designed to minimize risk:
Request Timing
- Gaussian jitter: Delays between requests use a truncated Gaussian distribution (~1s mean, ฯ=0.3)
- Random long pauses: ~5% of requests include an additional 2-5 second delay simulating reading behavior
- Auto-retry: Exponential backoff on HTTP 429/5xx and network errors (up to 3 retries)
Browser Fingerprint Consistency
- UA/Platform alignment: User-Agent,
sec-ch-ua, sec-ch-ua-platform, sec-ch-ua-mobile are all consistent (Chrome 133)
- Cookie merge: Set-Cookie headers from Reddit responses are merged back into the session
Structured Output
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.
Use as AI Agent Skill
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 |
Manual Install
mkdir -p .agents/skills
git clone git@github.com:jackwener/rdt-cli.git .agents/skills/rdt-cli
OpenClaw / ClawHub (Deprecated)
โ ๏ธ ClawHub ๅฎ่ฃ
ๆนๅผๅทฒ่ฟๆถ๏ผไธๅๆฏๆใ่ฏทไฝฟ็จไธๆน็ Skills CLI ๆๆๅจๅฎ่ฃ
ใ
Project Structure
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
Development
# 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 .
Troubleshooting
Q: No Reddit cookies found
- Open any browser and visit https://www.reddit.com/
- Log in with your account
- Run
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.
ๆจ่้กน็ฎ
- xiaohongshu-cli โ ๅฐ็บขไนฆๆ็ดขใ้
่ฏปๅๅๅธ CLI
- twitter-cli โ Twitter/X ๆถ้ด็บฟใไนฆ็ญพๅๅๆจ CLI
- bilibili-cli โ Bilibili ่ง้ขใ็จๆทใๆ็ดขไธๅจๆ CLI
- discord-cli โ Discord ๆฌๅฐไผๅ
ๅๆญฅใๆฃ็ดขไธๅฏผๅบ CLI
- tg-cli โ Telegram ๆฌๅฐไผๅ
ๅๆญฅใๆฃ็ดขไธๅฏผๅบ CLI
ๅ่ฝ็นๆง
- ๐ ่ฎค่ฏ โ ่ชๅจๆๅๆต่งๅจ Cookie๏ผ็ถๆๆฃๆฅ๏ผ็จๆทไฟกๆฏ
- ๐ ๆต่ง โ ้ฆ้กต FeedใPopularใ/r/allใ็บฏ่ฎข้
Feed๏ผ
--subs-only๏ผ
- ๐ ๅญ็ๅ โ ๆต่งไปปๆ subreddit๏ผๆๅบ/ๆถ้ด่ฟๆปค๏ผ๏ผๆฅ็ๅญ็ๅไฟกๆฏ
- ๐ฐ ๅธๅญ โ ้
่ฏปๅธๅญๅ่ฏ่ฎบๆ
- ๐ฌ ่ฏ่ฎบๅฑๅผ โ
--expand-more ๅฏๅฑๅผ้ขๅค่ฏ่ฎบ
- ๐ข ็ญ็ดขๅผๅฏผ่ช โ
rdt show 3 ้
่ฏปใrdt open 3 ๆต่งๅจๆๅผ
- ๐ ๆ็ดข โ ๅ
จๆๆ็ดข๏ผๆฏๆๅญ็ๅใๆๅบใๆถ้ด่ฟๆปค
- ๐ค ๅฏผๅบ โ ๆ็ดข็ปๆๅฏผๅบไธบ CSV ๆ JSON
- ๐ค ็จๆท โ ๆฅ็็จๆท่ตๆใๅๅธๅๅฒใ่ฏ่ฎบๅๅฒใๆถ่ๅ็น่ต่ฎฐๅฝ
- โฌ๏ธ ไบๅจ โ ็น่ต/่ธฉใๆถ่ใ่ฎข้
ใ่ฏ่ฎบ
- ๐ก๏ธ ๅ้ฃๆง โ Chrome 133 ๆ็บนไธ่ดๆงใ้ซๆฏๆๅจๅปถ่ฟใๆๆฐ้้ฟ้่ฏ
- ๐ ็ปๆๅ่พๅบ โ
--yaml / --json๏ผ้ TTY ้ป่ฎค่พๅบ YAML
- ๐ฆ ็จณๅฎ envelope โ ๅ่ง SCHEMA.md
ๅฎ่ฃ
# ๆจ่๏ผ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
ไฝฟ็จ็คบไพ