StackOverflow Search & Scraping for LLM Agents
A native Rust command-line tool and agent interface for searching questions, tags, and answers via Apify. YAML-first output optimized for LLM agents, with deterministic error envelopes and OS keystore security.
Native Rust Performance
Compiled with Rust 2024 and full Link-Time Optimization (LTO). Executes in 1–3 ms without .NET runtime or VM overhead.
Agentic-First Protocol
Human-friendly YAML by default, raw JSON with --json. Deterministic error envelopes with stable exit codes (1..=7) on stderr.
Native OS Keystores
Tokens are secured in macOS Keychain (/usr/bin/security), Windows DPAPI, or Linux Secret Service. Never stored in plaintext without opt-in.
Question & Tag Scraping
Search StackOverflow questions by keyword or tag. Scrape tag archives or extract specific question discussions and top answers.
Multi-Account Safety
Isolated account profiles with explicit --account <name> targeting prevent credential mix-ups across projects or CI runners.
Self-Documenting
Embedded stackoverflow agent-readme [--json] exposes complete operating rules and exit codes with zero network roundtrips.
Interactive Examples
Try common workflows for searching, tag scraping, authentication, and multi-account management.
# Search StackOverflow by query stackoverflow search "AI coding agent orchestration" # Filter by tags and include top answers stackoverflow search "code review automation" --tagged "python,ai" --answers # Limit results and sort by newest stackoverflow search "multi-agent workflow" --sort newest --max 20 # Structured JSON for agent pipelines stackoverflow search "memory leak debugging" --json
# Scrape tag archives stackoverflow scrape "ai-agent,llm" # Scrape a specific tag page with limit stackoverflow scrape "https://stackoverflow.com/questions/tagged/ai-agent" --max 20 # Scrape a specific question URL stackoverflow scrape "https://stackoverflow.com/questions/12345678/some-question" # Fast scrape without answer bodies stackoverflow scrape "rust" --no-answers
# Interactive login (opens Apify console, saves to OS keystore) stackoverflow login # Add named account via stdin (for CI / agent loops) printf %s "$APIFY_TOKEN" | stackoverflow accounts add work --api-key-stdin # List configured accounts and test validity stackoverflow accounts list --check # Test connectivity for a stored account stackoverflow accounts test work # Remove an account securely stackoverflow accounts remove work --yes
# Dump human-readable operating manual
stackoverflow agent-readme
# Dump structured JSON rules and exit codes
stackoverflow agent-readme --json
# Error envelope format on stderr:
# {
# "error": "The Apify API token was rejected.",
# "code": "auth_required",
# "remediation": "Set APIFY_TOKEN, use --api-key , or run: stackoverflow login"
# }
Command Reference
Summary of commands and subcommands available in the stackoverflow CLI.
| Command | Description | Primary Flags |
|---|---|---|
stackoverflow search <QUERY> |
Search StackOverflow for questions matching a query | --tagged, --answers, --site, --max, --sort |
stackoverflow scrape <TARGET> |
Scrape tags, tagged URLs, or question URLs | --answers, --no-answers, --site, --max, --sort |
stackoverflow login [NAME] |
Authenticate with Apify API token via browser or flag | --api-key, --api-key-stdin, --no-browser, --force |
stackoverflow accounts <SUBCOMMAND> |
Manage named accounts and stored keystore credentials | add, list, test, remove |
stackoverflow agent-readme |
Print full agent instruction manual or JSON rules | --json |