res-x
X/Twitter Fetch & Search
Fetch tweet content by URL and search X posts using xAI Responses API with Grok's x_search tool. Solves the problem of X/Twitter blocking WebFetch with "JavaScript disabled" errors.
Architecture
| Capability | API Tool | Cost |
|---|---|---|
| Fetch tweet by URL | xAI x_search |
~$0.005/call |
| Search X | xAI x_search |
~$0.005/call |
Fetching batches URLs in groups of 3 per API call to reduce cost.
Prerequisites
Required Tools
| Tool | Purpose | Install |
|---|---|---|
| uv | Python package manager (handles dependencies) | curl -LsSf https://astral.sh/uv/install.sh | sh |
API Key
| Service | Purpose | Required | Get Key |
|---|---|---|---|
| xAI | X/Twitter access via Grok | Yes | https://console.x.ai |
This skill requires an xAI API key. There is no fallback mode.
Keychain Setup (One-Time)
# 1. Create a dedicated keychain (skip if already exists)
security create-keychain -p 'YourPassword' ~/Library/Keychains/claude-keys.keychain-db
# 2. Add keychain to search list
security list-keychains -s ~/Library/Keychains/claude-keys.keychain-db ~/Library/Keychains/login.keychain-db /Library/Keychains/System.keychain
# 3. Store your xAI API key
echo -n "Enter xAI API key: " && read -s key && security add-generic-password -s "xai-api" -a "$USER" -w "$key" ~/Library/Keychains/claude-keys.keychain-db && unset key && echo
Before using: security unlock-keychain ~/Library/Keychains/claude-keys.keychain-db
Script Usage
# Fetch single tweet
uv run scripts/x_fetch.py fetch "https://x.com/user/status/123456"
# Fetch multiple tweets (batched, 3 per API call)
uv run scripts/x_fetch.py fetch "url1" "url2" "url3" "url4" "url5"
# Force one-per-URL for max fidelity
uv run scripts/x_fetch.py fetch "url1" "url2" --single
# Search X
uv run scripts/x_fetch.py search "query terms"
uv run scripts/x_fetch.py search "query terms" --quick
# JSON output (both commands)
uv run scripts/x_fetch.py fetch "url" --json
uv run scripts/x_fetch.py search "query" --json
Workflow
Step 0: Detect xAI Key (Mandatory)
Run before every invocation:
security find-generic-password -s "xai-api" -w ~/Library/Keychains/claude-keys.keychain-db 2>/dev/null && echo "XAI_AVAILABLE=true" || echo "XAI_AVAILABLE=false"
If XAI_AVAILABLE=false, report that this skill requires an xAI key and show the keychain setup instructions above.
Step 1: Detect Intent
- URLs present in user input or referenced note -> fetch
- Query text only -> search
Step 2: Execute
For fetch:
- Extract all X/Twitter URLs from user input or referenced file
- Run the script with all URLs as arguments
- The script batches them (3 per API call) automatically
For search:
- Run the script with the search query
- Use
--quickfor fast overview, omit for deeper results
Step 3: Present Results
- For fetch: present tweet-by-tweet with full content, engagement, thread/quote context
- For search: present as a list with engagement metrics
URL Patterns Accepted
https://x.com/{user}/status/{id}
https://twitter.com/{user}/status/{id}
https://x.com/{user}/status/{id}?s=20
https://x.com/{user}/status/{id}?t=...&s=...
https://x.com/i/article/{id}
Tweets normalized to https://x.com/{user}/status/{id}, articles to https://x.com/i/article/{id} before processing.
Batch Processing
For processing saved X links from a file (e.g., Obsidian daily note):
- Read the file content
- Extract all X/Twitter URLs (tweets:
https?://(?:x\.com|twitter\.com)/\w+/status/\d+, articles:https?://(?:x\.com|twitter\.com)/i/article/[\w\-]+) - Pass all URLs to the script:
uv run scripts/x_fetch.py fetch "url1" "url2" ... - Present results organized by URL
Cost
| Action | API Calls | Cost |
|---|---|---|
| Fetch 1-3 tweets | 1 | ~$0.005 |
| Fetch 4-6 tweets | 2 | ~$0.010 |
| Fetch 10 tweets | 4 | ~$0.020 |
| Fetch 10 tweets (--single) | 10 | ~$0.050 |
| X search | 1 | ~$0.005 |
| X search (--quick) | 1 | ~$0.005 |
Constraints
DO:
- Run Step 0 before every invocation
- Validate URLs before calling the script
- Use
--jsonwhen parsing results programmatically - Present full tweet content without truncation
DON'T:
- Try WebFetch on X URLs (fails with JS disabled)
- Skip the xAI key check
- Use this for general web search (use
res-weborres-deep)
Troubleshooting
xAI key not found:
security find-generic-password -s "xai-api" ~/Library/Keychains/claude-keys.keychain-db
If not found, run keychain setup above.
Keychain locked:
security unlock-keychain ~/Library/Keychains/claude-keys.keychain-db
Script errors: Ensure uv is installed: which uv
More from molechowski/claude-skills
res-price-compare
Polish market product price comparison: 20+ shops, shipping costs, manufacturer vs seller warranty, B2B/statutory warranty analysis, stock status, distribution chain. Export TXT/XLSX/HTML. Use when: looking for a product to buy, price comparison, where to buy cheapest. Triggers: cena, porównaj, gdzie kupić, najtaniej, sklep, price compare, best price, kup, ile kosztuje.
36doc-vault-project
Manage multi-note research projects in Obsidian vault with phased subdirectory structure (concept, research, design, implementation). Scaffold new projects, add component notes, track status, link existing research, promote topics to projects. Use when: creating a project, adding to a project, checking project status, linking research to a project, promoting a research topic to a full project. Triggers: project init, project add, project status, project link, project promote, create project, new project.
35res-deep
Iterative multi-round deep research with structured analysis frameworks. Use for: deep research on a topic, compare X vs Y, landscape analysis, evaluate options for a decision, deep dive into a technology, comprehensive research with cross-referencing. Triggers: deep research, compare, landscape, evaluate, deep dive, comprehensive research, which is better, should we use.
35doc-daily-digest
Process Obsidian daily notes: classify raw URLs and loose ideas, fetch content (X tweets, GitHub repos, web pages), run deep research on ideas, create structured vault notes, replace raw items with wikilinks. Orchestrates doc-obsidian, res-x, and res-deep skills. Use when: processing daily note links, digesting saved URLs into notes, turning ideas into research, daily note cleanup. Triggers: daily digest, process daily, daily links, triage daily, digest daily note.
35doc-project
Update all project documentation in one pass: CLAUDE.md, AGENTS.md, README.md, SKILLS.md, CHANGELOG.md. Orchestrates doc-claude-md, doc-readme, doc-skills-md, and doc-changelog skills sequentially. Use when: project docs are stale, after major changes, initial project setup, sync all docs. Triggers: update all docs, update project docs, sync documentation, refresh docs, doc-project.
34doc-obsidian
Obsidian vault management combining qmd (search) and notesmd-cli (CRUD). No Obsidian app needed. Use for: (1) searching notes with keyword, semantic, or hybrid search, (2) creating/editing/moving/deleting notes, (3) daily journaling, (4) frontmatter management, (5) backlink discovery, (6) AI agent memory workflows, (7) vault automation and scripting. Triggers: obsidian vault, obsidian notes, vault search, note management, daily notes, agent memory, knowledge base, markdown vault.
34