A Claude Code Skill that routes X/Twitter queries to xAI Grok 4 via OpenRouter with Live Search turned on and scoped to the X source.
$ npx -y skills add mikedemarais/grok-skill --agent claude-code
FAQ
grok-skill is a Claude Code plugin with 1 hand-picked skill for data work, indexed on Flowy. Install it with the command on its page. It includes grok-skill. Its skills do not fire on their own yet. Request auto-invocation to have Flowy route them as you prompt. Free and open source.
Repo: mikedemarais/grok-skill
A Claude Code Skill that routes X/Twitter queries to xAI Grok 4 via OpenRouter with Live Search turned on and scoped to the X source.
--include / --exclude for targeted searches# 1. Set your OpenRouter API key
export OPENROUTER_API_KEY="sk-or-..."
# 2. Run a query (assumes Bun is installed)
bun scripts/grok.ts --q "what's trending on X about AI?"
That's it! The script returns JSON with summary, citations, and usage stats.
Sign up at openrouter.ai and create an API key.
# Set your OpenRouter key
export OPENROUTER_API_KEY="sk-or-..."
# Verify it's set
echo "$OPENROUTER_API_KEY"
# To persist across sessions, add to your shell profile:
echo 'export OPENROUTER_API_KEY="sk-or-..."' >> ~/.zshrc
source ~/.zshrc
# macOS/Linux
brew install bun || curl -fsSL https://bun.sh/install | bash
# Windows
powershell -c "irm bun.sh/install.ps1|iex"
# Clone to Claude Code skills directory
git clone https://github.com/mikedemarais/grok-skill.git ~/.claude/skills/grok-skill
# Make script executable
chmod +x ~/.claude/skills/grok-skill/scripts/grok.ts
# Restart Claude Code to discover the skill
# Minimal query
bun scripts/grok.ts --q "what are people saying about account abstraction on X?"
# One-off (without shell export)
OPENROUTER_API_KEY="sk-or-..." bun scripts/grok.ts --q "latest crypto news"
# Handles + timeframe + filters
bun scripts/grok.ts \
--q "AI developments" \
--include "@OpenAI" "@AnthropicAI" \
--from 2025-11-01 --to 2025-11-07 \
--mode on --min-faves 25 --max 12
# Exclude specific handles
bun scripts/grok.ts \
--q "crypto market sentiment" \
--exclude "@spam_account" \
--max 20
| Flag | Type | Description | Default |
|---|---|---|---|
--q | string | Query text (required) | - |
--mode | on|off|auto | Live Search mode | auto |
--include | @handle... | X handles to include (max 10) | [] |
--exclude | @handle... | X handles to exclude (max 10) | [] |
--from | YYYY-MM-DD | Start date for search | - |
--to | YYYY-MM-DD | End date for search | - |
--max | 1..50 | Max search results | 12 |
--min-faves | integer | Min favorites per tweet (≥ 0) | - |
--min-views | integer | Min views per tweet (≥ 0) | - |
Environment Variables:
OPENROUTER_API_KEY (required) - Your OpenRouter API keyGROK_MODEL (optional) - Override model (default: x-ai/grok-4)Constraints:
--include and --exclude are mutually exclusiveYYYY-MM-DD format{
"query": "AI developments",
"summary": "- **OpenAI releases GPT-5**: Major improvements in reasoning...\n- **Anthropic Claude updates**: New vision capabilities announced...\n- **xAI Grok integration**: Now available via OpenRouter API...",
"citations": [
"https://x.com/OpenAI/status/1234567890",
"https://x.com/AnthropicAI/status/9876543210",
"https://x.com/xai/status/5555555555"
],
"usage": {
"prompt_tokens": 892,
"completion_tokens": 312,
"total_tokens": 1204
},
"model": "x-ai/grok-4"
}
# Error: "Missing env OPENROUTER_API_KEY"
export OPENROUTER_API_KEY="sk-or-..."
The client automatically retries with exponential backoff. If you still hit limits:
--max to make smaller requests--max (try 15-20)--include/--exclude filters--mode on to force Live SearchThis is normal. The script extracts X/Twitter URLs from the summary text as a fallback. Check the citations array for discovered links.
chmod +x scripts/grok.ts
mode: Controls Live Search behavior
auto (default) - Model decides whether to searchon - Forces Live Searchoff - Disables search, uses model knowledge onlyreturn_citations: Always true to get tweet URLs
max_search_results: Capped at 12 by default for cost/latency
sources: Configured for X/Twitter with optional filters:
included_x_handles / excluded_x_handlespost_favorite_count / post_view_count0 - Success2 - Usage/validation error3 - Network/timeout error4 - JSON parse errorTypical token usage per query:
Best practices:
--max ≤ 12 for routine queriesusage field in output--max only when results are sparseContributions welcome! Please:
MIT - see LICENSE
Security Note: Never commit secrets. If you use a local .env file, ensure it's in .gitignore.
.gitignore CLAUDE.md LICENSE README.md scripts/ grok.ts SKILL.md
© 2026 Flowy · Free and open source
Built for Claude Code · Not affiliated with Anthropic