# Stackoverflow Search

> 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.

- Skill: `greatsumini/stackoverflow-search` (Agent Skill)
- Install (CLI): `npx skillmds@latest add greatsumini/stackoverflow-search`
- Raw SKILL.md: https://api.skillmd.com/api/skills/greatsumini/stackoverflow-search/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: greatsumini (https://skillmd.com/u/greatsumini)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/greatsumini/stackoverflow-search

---


# 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:
```bash
stackoverflow search '"PrismaClientKnownRequestError" upsert'
```

Combine the free-text query with `--tagged` to pin the technology:
```bash
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

```bash
# TypeScript error — exact phrase + tag
stackoverflow search '"Property does not exist on type"' --tagged "typescript" --accepted

# Python import error with version context
stackoverflow search 'python 3.11 "ModuleNotFoundError" no module named' --tagged "python"

# React hook rule violation — recent only
stackoverflow search '"Rules of Hooks" cannot call inside callback' \
  --tagged "javascript;react" --fromdate 2021-01-01 --sort votes

# Django ORM error — only questions with accepted answers and decent engagement
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:
```bash
stackoverflow get <question_id>

# Get more answers (default is 3)
stackoverflow get <question_id> --max-answers 5
```

For scripting or piping results into another tool:
```bash
stackoverflow search '"ECONNREFUSED" redis connect' --json
stackoverflow get 11828270 --json
```

---

## Iterative Search Strategy

If the first search returns poor results:

1. **Broaden** — drop one part of the query (remove version, or the specific context)
2. **Rephrase** — try a synonym the community uses (`upsert` → `insert or update`)
3. **Narrow** — add `--accepted` or tighten `--tagged` if results are too broad
4. **Sort differently** — switch to `--sort votes` to surface highly-rated classic answers

---

## Installation (one-time)

Install `sof-cli` globally via your package manager:

```bash
# npm
npm install -g sof-cli

# pnpm
pnpm add -g sof-cli

# yarn
yarn global add sof-cli
```

Verify the installation:
```bash
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](https://stackapps.com/apps/oauth/register) and configure it once:

```bash
stackoverflow init --key <YOUR_APP_KEY>
# → 10,000 requests/day
```

