Conducts in-depth code research using a tiered tool strategy. Use when investigating codebases, researching libraries/APIs, debugging errors, or understanding unfamiliar code patterns.
When researching code, follow the tool escalation ladder:
code-search skill first; otherwise use Grep/Glob/Readgh-cli skill for GitHub, scripts for Stack OverflowStart simple. Escalate only when simpler tools fail.
Web research:
WebSearch - General web search for docs, tutorials, discussionsWebFetch - Fetch and analyze specific URLs (works for most static sites)When to use: Always start here. These tools are fast, low-cost, and handle 80% of research tasks.
Fallback to POSIX tools:
grep, find, sed, awk, cut, sort, uniqTerminal web/doc workflows:
w3m / lynx for fast doc browsing!gh, !so, !npm, !pypi) to jump directly to sourcescurl + jq + rg for structured data and targeted extractionpup/htmlq/python -m bs4 for HTML parsing when neededreadability-lxml (or python -m readability) to clean article contentcsvkit / xsv for CSV docs and tablesfzf to interactively select snippets and URLspbcopy (macOS) / xclip -selection clipboard (Linux)Rate-limit hygiene:
curl --retry 3 --retry-delay 2 --compressed + backoff (sleep)ETag/If-Modified-Since to avoid refetching unchanged docsWhen to use: Quick web/CLI research before WebSearch, or when you need high-throughput data extraction.
GitHub CLI (gh) - Use the gh-cli skill for comprehensive GitHub operations:
Skill: gh-clistackoverflow-api.sh - Find solutions to errors
# Search Stack Overflow for solutions
${AGENT_ROOT}/skills/code-research/scripts/stackoverflow-api.sh "error message or question"
When to use: When you need structured GitHub data (issues, PRs, code across repos) that WebSearch can't provide cleanly.
Exa MCP - Semantic web search with AI understanding
Deepwiki MCP - Documentation and wiki content
Chrome Web Tools MCP - Headless browser automation
https://codewiki.google/github.com/anomalyco/opencodeWhen to use: When simpler tools fail—JS-rendered content, semantic search needs, or complex documentation sites.
Glob: **/{keyword}.{ts,py,go}
Grep: "functionName|className|errorMessage"
Task(subagent_type=Explore): "Find how authentication is implemented"
</step>
<step name="2.5" label="Terminal Research">
Use fast terminal tools to browse docs and extract data:
w3m https://docs.example.com/guide
WebSearch: "!gh repo:org/project authentication middleware"
curl -s https://docs.example.com/api | rg -n "endpoint" | sed -n '1,120p'
gh repo view org/repo --json description --jq '.description'
curl -s https://blog.example.com/post | python -m readability | rg -n "API" | sed -n '1,80p'
curl -s https://docs.example.com/table.csv | xsv select 1,3 | xsv table | sed -n '1,40p'
curl -s https://docs.example.com/api | rg -n "endpoint" | fzf
curl -s https://docs.example.com/api | pbcopy # or: xclip -selection clipboard
Prefer Rust utilities when available (rg/fd/bat/sd/xsv); fall back to standard Unix tools otherwise.
</step>
<step name="3" label="Expand to Web">
If local exploration isn't enough:
WebSearch: "library-name how to implement X"
WebFetch: "https://docs.library.com/guide"
</step>
<step name="4" label="Use Skills & Scripts for Structured Data">
When you need GitHub/StackOverflow data:
Skill: gh-cli
gh issue list -R facebook/react --search "useEffect cleanup" gh search code "useEffect cleanup" --repo facebook/react
```bash
# Find error solutions
${AGENT_ROOT}/skills/code-research/scripts/stackoverflow-api.sh "React useEffect memory leak"
mcp__web_search_exa: "best practices for React state management 2024" mcp__get_code_context_exa: "langgraph deepagent cli" mcp__crawling_exa: "https://codewiki.google/github.com/anomalyco/opencode"
mcp__deepwiki__read_wiki_contents: "react/react" mcp__deepwiki__read_wiki_structure: "anomalyco/opencode" mcp__deepwiki__ask_question: "What are the context engineering strategies used by anomalyco/opencode?"
Use chrome-devtools-mcp to open up webpages and crawl through them for deeper information extraction tasks.
</step>
<step name="6" label="Save High-Value Sources to Readwise">
When a source is highly relevant (authoritative docs, key blog posts, insightful discussions), persist it for future retrieval:
```bash
# Save a URL to Reader with research tags
readwise reader-create-document --url "https://..." --tags "code-research,<topic>"
# Create a highlight for a key finding or quote
readwise readwise-create-highlights --highlights '[{"text": "key finding text", "title": "Source Title", "source_url": "https://...", "note": "Why this matters"}]'
Only save sources scoring 2-3 on relevance (directly answers the question or provides strong supporting context). Do not save noise.
Quick answer - For simple questions, respond inline with sources Structured summary - For broader research:
## Findings
- Key finding 1
- Key finding 2
## Recommendations
- Recommended approach with rationale
## Sources
- [Source 1](url)
- [Source 2](url)
Research report - For deep dives, create a markdown file:
Write: research-{topic}-{date}.md