| name | stackoverflow-search |
| description | How to effectively search Stack Overflow using the stackoverflow-cli (`sof-cli`) tool. Use this skill whenever the user wants to look up an error, debug a problem, or find solutions on Stack Overflow from the terminal. Trigger this skill when the user mentions searching Stack Overflow, troubleshooting an error with the CLI, running `stackoverflow search`, or asks how to use `sof-cli` effectively — even if they don't explicitly say "skill" or "guide". Also trigger when the user pastes an error message and seems to want a CLI-based lookup strategy.
|
Effectively Searching Stack Overflow with sof-cli
The sof-cli tool lets you search Stack Overflow from the terminal. Getting good results
requires thinking carefully about what you search and how you filter the results.
There are three steps: sanitize the query, run the right command, and evaluate what comes back.
Step 1: Sanitize the Error Message
Raw error messages from your project are full of noise that hurts search quality —
file paths, table names, variable names, and IDs that are unique to your environment.
Strip those out before searching.
Remove:
- Local file paths:
/Users/alice/project/src/db/users.ts
- Custom variable/table names:
this.prisma.myCustomTable.upsert()
- Unique IDs or hashes:
job_id=abc123
- Database/schema names specific to your app
Keep:
- The exact error string the framework or runtime generated
- Standardized error codes:
Error 404, ECONNREFUSED, ER_DUP_ENTRY
- The framework/library name and version context
Example:
# Raw (bad — too specific)
PrismaClientKnownRequestError: Invalid `this.prisma.userProfile.upsert()` invocation in
/Users/alice/myapp/src/services/userService.ts:42:5
# Sanitized (good — searchable)
PrismaClientKnownRequestError Invalid prisma upsert invocation
Step 2: Structure the Search Query
Query structure
Build your query in this order:
[Language/Framework + Version] [Core Error Message] [Specific Context]
For exact phrase matching, wrap critical parts of the error string in double quotes:
stackoverflow search '"PrismaClientKnownRequestError" upsert'
Combine the free-text query with --tagged to pin the technology:
stackoverflow search '"cannot read properties of undefined" reading map' --tagged "javascript;react"
Key options for precision
| Goal | Option | Example |
|---|
| Pin a technology | --tagged "tag1;tag2" | --tagged "python;django" |
| Exclude noisy tags | --nottagged "tags" | --nottagged "javascript" |
| Match title exactly | --title "text" | --title "upsert conflict" |
| Only answered questions | --accepted | --accepted |
| Require at least N answers | --answers 1 | --answers 2 |
| More results | --limit 10 | --limit 10 |
| Sort by votes | --sort votes | --sort votes --order desc |
| Only recent results | --fromdate YYYY-MM-DD | --fromdate 2022-01-01 |
Practical examples
stackoverflow search '"Property does not exist on type"' --tagged "typescript" --accepted
stackoverflow search 'python 3.11 "ModuleNotFoundError" no module named' --tagged "python"
stackoverflow search '"Rules of Hooks" cannot call inside callback' \
--tagged "javascript;react" --fromdate 2021-01-01 --sort votes
stackoverflow search 'django "RelatedObjectDoesNotExist" get() returned more than one' \
--tagged "python;django" --accepted --answers 1
Step 3: Evaluate the Results
The search command returns a list of questions with their score (net upvotes),
answered status, and link. Use these to triage quickly:
- High score + accepted answer: Strong signal — prioritize these first.
- Low score or zero answers: The problem may be too niche or the thread unresolved.
- Old creation date: Check whether the answer still applies to your version. A
solution from 2013 may use a deprecated API.
To read the full question and its top answers:
stackoverflow get <question_id>
stackoverflow get <question_id> --max-answers 5
For scripting or piping results into another tool:
stackoverflow search '"ECONNREFUSED" redis connect' --json
stackoverflow get 11828270 --json
Iterative Search Strategy
If the first search returns poor results:
- Broaden — drop one part of the query (remove version, or the specific context)
- Rephrase — try a synonym the community uses (
upsert → insert or update)
- Narrow — add
--accepted or tighten --tagged if results are too broad
- Sort differently — switch to
--sort votes to surface highly-rated classic answers
Installation (one-time)
Install sof-cli globally via your package manager:
npm install -g sof-cli
pnpm add -g sof-cli
yarn global add sof-cli
Verify the installation:
stackoverflow --version
Requires Node.js >= 16.
Setup (one-time)
By default you get 300 API requests/day. Register a free Stack Exchange App Key at
stackapps.com and configure it once:
stackoverflow init --key <YOUR_APP_KEY>