ddgr
ddgr
Use ddgr for terminal-first web search when the task benefits from local CLI execution, reproducible flags, or JSON output that can be filtered further in-shell.
Treat ddgr as the discovery layer. Use it to find candidate URLs quickly, then hand selected URLs to a browser automation or page-inspection tool such as playwright-cli when the task requires reading page contents, following navigation, or validating page behavior.
When To Use
- The user explicitly wants
ddgror DuckDuckGo via CLI. - You need search results from a local command rather than the built-in web tool.
- You want machine-friendly output with
--json --np. - You need DuckDuckGo-specific features such as bangs, region, time, or site filtering.
- You want to collect likely target URLs first, then inspect the shortlisted pages with another tool.
Default Workflow
- Confirm
ddgris callable withddgr --versionorddgr --helpif needed. - Prefer non-interactive usage for Codex:
ddgr --json --np -n 5 <query> - Add filters only as needed:
-w <site>,-t <d|w|m|y>,-r <region>,-x,--unsafe. - If the user wants a browser-open action, use
-j,--gb, or--url-handler. - Summarize the result set clearly because terminal command output is not shown directly to the user.
- If deeper inspection is needed, pass only the most relevant URLs to the next tool rather than forwarding the whole result set.
Recommended Patterns
Structured output
Use JSON by default when you need to inspect or summarize results:
ddgr --json --np -n 5 "query terms"
This is the preferred handoff format when another tool will consume the results.
Human-readable one-shot search
Use plain text only when the user wants terminal-style results:
ddgr --np -n 5 "query terms"
Note: plain output can include DuckDuckGo instant-answer text before normal results, which may be noisy. Prefer --json when reliability matters.
Common filters
ddgr --json --np -n 5 -w example.com "query"
ddgr --json --np -n 5 -t m "query"
ddgr --json --np -n 5 -r jp-jp "query"
ddgr --json --np -n 5 -x "query"
Tool Chaining
When a search should lead to deeper page inspection:
- Run
ddgr --json --npwith a narrow query. - Select 1 to 5 likely URLs based on title, domain, and abstract.
- Hand those URLs to the next tool.
Use playwright-cli when you need to:
- open the shortlisted pages
- inspect rendered content instead of snippets
- click through navigation
- verify page text, forms, tables, or dynamic behavior
Avoid sending raw ddgr plain-text output into downstream tooling. Prefer parsed URLs from --json.
Interaction Guidance
--npavoids the omniprompt and is usually the right choice for Codex.-naccepts0..25; keep it small unless the user asks for breadth.-jopens the first result and implies--np.--jsonalso implies--np.- For multi-tool workflows, keep the initial search broad enough to discover candidates but narrow enough that the handoff set stays small.
- Bang queries such as
!wmay need escaping in some shells:\!w. - If
BROWSERpoints to a text browser,ddgrcan integrate with it; useOin interactive mode for GUI-browser intent.
Caveats
ddgroutput reflects DuckDuckGo HTML results, not the built-in web tool.- Results may differ by region, safe-search, proxy, and user agent settings.
- For reproducible automation, include explicit flags rather than relying on environment defaults.
References
- For command recipes and practical notes, read references/recipes.md.