|
| 1 | +# 054 - Tool: reddit |
| 2 | + |
| 3 | +**Persona:** [CLI User](../personas/cli-user.md), |
| 4 | +[AI Coding Assistant](../personas/ai-coding-assistant.md) |
| 5 | + |
| 6 | +## Goal |
| 7 | + |
| 8 | +Search Reddit for posts matching a query and extract structured metadata |
| 9 | +(title, subreddit, score, comment count, URL, snippet) for each result. |
| 10 | + |
| 11 | +## Stories |
| 12 | + |
| 13 | +- As a CLI user, I run `ibr tool reddit --param query=rust async` to retrieve |
| 14 | + a list of Reddit posts with title, subreddit, score, comment_count, url, and snippet. |
| 15 | +- As a CLI user, I pass `--param subreddit=rust` to scope results to a single subreddit. |
| 16 | +- As a CLI user, I pass `--param sort=hot` to sort by hot posts. |
| 17 | +- As a CLI user, I pass `--param max_results=10` to control how many results are returned. |
| 18 | +- As a CLI user, omitting `query` produces a non-zero exit with a clear error message. |
| 19 | + |
| 20 | +## Acceptance Criteria |
| 21 | + |
| 22 | +- Navigates to `https://www.reddit.com/search/?q={{query}}&sort={{sort}}` by default. |
| 23 | +- When `subreddit` is set, navigates to |
| 24 | + `https://www.reddit.com/r/{{subreddit}}/search/?q={{query}}&sort={{sort}}` instead. |
| 25 | +- Extracts up to `max_results` (default 5) posts per run. |
| 26 | +- Each extracted item contains: `title`, `subreddit`, `score`, `comment_count`, |
| 27 | + `url`, `snippet`. |
| 28 | +- `sort` defaults to `relevance`; accepted values: relevance, hot, new, top. |
| 29 | +- Missing required param `query` → non-zero exit with "Missing required param: query". |
| 30 | +- Exit code 0 on successful extraction; stdout contains "Task execution completed". |
| 31 | + |
| 32 | +## E2E Coverage |
| 33 | + |
| 34 | +- `test/e2e/cli-tool-vcr.test.js` — VCR: exits 0, no config errors; required param |
| 35 | + validation. |
0 commit comments