A blazing-fast native command-line tool and agent interface for searching and scraping StackOverflow questions and answers via Apify, written in Rust. Features YAML-first output optimized for terminal and LLM readability, raw JSON via --json, secure OS keystore credential storage, and multi-account support.
Ported from the original C# prototype Stackoverflow.Console by Niels Bosma to high-performance native Rust under the SpaceCorps organization.
- β‘ Native Speed & Zero Dependencies: Standalone static binary with 1β3 ms cold start times.
- π OS Keystore Integration: API tokens are stored in macOS Keychain, Windows DPAPI, or Linux Secret Service (
secret-tool). - π€ Agentic Protocol: Clean YAML on stdout by default; structured JSON with
--json; deterministic error envelopes on stderr with stable exit codes. - π₯ Multi-Account Safety: Configure multiple named accounts (
stackoverflow accounts add work) and target them explicitly with--account work(-a work). - π Self-Documenting: Embedded
stackoverflow agent-readme [--json]delivers complete machine-readable rules and documentation directly to LLM agents.
Download prebuilt standalone binaries for macOS, Linux, and Windows from GitHub Releases.
cargo install --git https://github.com/SpaceCorps/Stackoverflow-Cli --lockedYou can authenticate in three ways:
stackoverflow login [account_name]Opens your browser to https://console.apify.com/account/integrations, securely prompts for your token without terminal echo, verifies it against the API, and stores it in your OS keystore.
# Add a named account (prompted securely)
stackoverflow accounts add work
# Or pass via stdin in CI/CD pipelines
printf %s "$APIFY_TOKEN" | stackoverflow accounts add ci --api-key-stdin
# List and verify stored accounts
stackoverflow accounts list --check
# Test account connectivity
stackoverflow accounts test workSet APIFY_TOKEN in your environment or pass --api-key <key> on any command:
export APIFY_TOKEN="your-apify-token"
stackoverflow search "Rust memory leaks"Search StackOverflow for questions matching a query.
# Basic keyword search
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 output for agent pipelines
stackoverflow search "memory leak debugging" --jsonOptions:
<QUERY>: Search query keywords (required)--tagged <TAGS>: Filter by comma-separated tags (e.g.'python,machine-learning')--answers: Include top answers for each question--site <SITE>: Stack Exchange site (default: "stackoverflow")--max <COUNT>: Maximum number of questions to return--sort <SORT>: Sort order (relevance,newest,votes,activity)--account <ACCOUNT>/-a <ACCOUNT>: Account name to resolve from keystore--api-key <KEY>: Direct Apify API token--json: Output as structured JSON
Scrape questions from StackOverflow tags or a specific URL.
# Scrape questions by tags
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-answersOptions:
<TARGET>: Comma-separated tags (e.g.'ai-agent,llm') or StackOverflow URL (required)--answers: Include top answers for each question (default: true)--no-answers: Fast scrape without answer bodies--site <SITE>: Stack Exchange site (default: "stackoverflow")--max <COUNT>: Maximum number of questions to return--sort <SORT>: Sort order (newest,votes,activity)--account <ACCOUNT>/-a <ACCOUNT>: Account name to resolve from keystore--api-key <KEY>: Direct Apify API token--json: Output as structured JSON
Outputs the embedded operating manual for AI agents driving this CLI:
# Print markdown manual
stackoverflow agent-readme
# Print structured JSON specifications
stackoverflow agent-readme --jsonPass --json to any command to receive raw JSON instead of YAML:
stackoverflow search "quantum computing" --json | jq '.[].title'Errors are printed to stderr with machine-readable exit codes matching the code field:
{
"error": "The Apify API token was rejected.",
"code": "auth_required",
"detail": "HTTP 401: Unauthorized",
"remediation": "Set APIFY_TOKEN, use --api-key <key>, or run: stackoverflow login"
}| Exit Code | code: |
Meaning | Agent Action |
|---|---|---|---|
0 |
ok |
Success | Continue |
1 |
error |
General unclassified error | Report error |
2 |
network |
Network timeout or 5xx error | Retry once with backoff |
3 |
auth_required |
Invalid or rejected API token | Surface remediation to user; do NOT retry |
4 |
not_found |
Resource not found | Do not retry |
5 |
rate_limited |
Upstream rate limit reached (HTTP 429) | Back off before retrying |
6 |
invalid_input |
Missing arguments or invalid parameters | Correct arguments |
7 |
no_account |
No account specified and no key available | Prompt user to configure account |
Full documentation, guides, and agent discovery manifests are available at: https://spacecorps.github.io/Stackoverflow-Cli/
- Authentication Guide
- Agent Manual (llms.txt)
- Full Agent Specification (llms-full.txt)
- A2A Agent Card
- AgentSkills Manifest
MIT License. See LICENSE for details. Original prototype created by Niels Bosma. Maintained by SpaceCorps.