Conducts in-depth code research using a tiered tool strategy. Use when investigating codebases, researching libraries/APIs, debugging errors, or understanding unfamiliar code patterns.
Conducts in-depth code research using a tiered tool strategy. Use when investigating codebases, researching libraries/APIs, debugging errors, or understanding unfamiliar code patterns.
Perform comprehensive code research by intelligently selecting from built-in tools, lightweight scripts, and MCP servers. The skill prioritizes context-efficient approaches—using the simplest tool that gets the job done before escalating to heavier solutions.
<quick_start>
Before any Bash command that uses ${AGENT_ROOT}, run:
source ./scripts/agent-env.sh
This resolves AGENT_ROOT to ./.agents in the current working directory.
When researching code, follow the tool escalation ladder:
Local first - For pure code lookup, invoke code-search skill first; otherwise use Grep/Glob/Read
Terminal research - Use fast CLI tools (w3m/lynx, curl, jq, rg, fd, gh) and DDG bangs
Built-in web - Use WebSearch/WebFetch for documentation and articles
Skills & Scripts - Use gh-cli skill for GitHub, scripts for Stack Overflow
MCP servers - Use Exa/Deepwiki/Chrome for complex research needs
Start simple. Escalate only when simpler tools fail.
</quick_start>
<tool_hierarchy>
Local codebase exploration:
Grep - Search for patterns, function names, error messages in code
Glob - Find files by pattern (e.g., **/*.ts, **/config.*)
Read - Read specific files once you know what to look at
**Prefer Rust utils when available (speed/ergonomics):**
- `rg` (ripgrep), `fd`, `bat`, `sd`, `xsv`, `hyperfine`
**Code search routing (`code-search`)** - Use for dedicated local code finding tasks:
- semantic search, structural/AST search, repo layout discovery, literal text matches
- invoke first when the user intent is "find code in this repo"
**Contextplus MCP** - Local code intelligence for large repos
- Use for: structure trees, file skeletons, semantic symbol search, blast-radius checks
- Always pass **repo-root-relative** paths (not cwd-relative paths)
- Path normalization workflow:
```bash
REPO_ROOT="$(git rev-parse --show-toplevel)"
CWD="$(pwd)"
TARGET="$CWD/src/lib.rs" # or any absolute target discovered from current task
RELATIVE_PATH="$(python3 -c 'import os,sys; print(os.path.relpath(sys.argv[1], sys.argv[2]))' "$TARGET" "$REPO_ROOT")"
# Use RELATIVE_PATH with contextplus tools
```
For any codebase question, explore locally first:
```
# If the primary intent is local code finding, route to code-search skill first
Skill: code-search
For complex research needs:
```
# Local code intelligence (Contextplus)
# 1) compute repo-root-relative path before calling contextplus
# 2) call contextplus with RELATIVE_PATH (for example: extensions/swe_distiller/src/lib.rs)
Combine findings from all sources:
- Cross-reference information across sources
- Identify consensus patterns vs. edge cases
- Note version-specific information (library versions matter!)
- Cite sources when presenting findings
Don't pass cwd-relative paths to contextplus when cwd is not repo root. Always normalize to repo-root-relative paths first.
Don't skip local codebase exploration. The answer might already be in the code you're working with.
Don't rely on one source. Cross-reference findings from multiple tools for accuracy.
Don't ignore version information. Library APIs change—verify findings match the version in use.
Don't spam endpoints with aggressive scraping. Use retries, backoff, and caching headers to avoid rate limits.
Task with subagent_type=Explore - For open-ended codebase exploration
Web research:
WebSearch - General web search for docs, tutorials, discussions
WebFetch - 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, uniq
Terminal web/doc workflows:
w3m / lynx for fast doc browsing
DuckDuckGo bangs (!gh, !so, !npm, !pypi) to jump directly to sources
curl + jq + rg for structured data and targeted extraction
pup/htmlq/python -m bs4 for HTML parsing when needed
readability-lxml (or python -m readability) to clean article content
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:
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?"
Website Navigation
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.
<output_formats>
Adapt output to the query:
Quick answer - For simple questions, respond inline with sources
Structured summary - For broader research: