Hybrid search strategy for finding relevant code: fast targeted search, then deep analysis if needed.
View on GitHubJuniYadi/claude-code
issue-reviews
issue-reviews/skills/code-explorer/SKILL.md
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/JuniYadi/claude-code/blob/main/issue-reviews/skills/code-explorer/SKILL.md -a claude-code --skill code-explorerInstallation paths:
.claude/skills/code-explorer/## Purpose
Given extracted keywords from an issue, locate the relevant code in the repository.
**Strategy:** Start fast and targeted, escalate to comprehensive if needed.
## Usage
Include this file when searching for code:
```
Use lib/code-explorer to find code related to [keywords]
```
## Phase 1: Targeted Search (30 seconds)
Use `Grep` and `Glob` tools for fast pattern matching.
### Step 1: Prepare Search Patterns
From parsed issue, create search patterns:
**Error messages → Grep patterns:**
```
"AuthenticationError" → grep for "AuthenticationError"
"token expired" → grep for "token.*expir|expir.*token"
```
**File paths → Glob patterns:**
```
"src/auth/middleware.ts" → glob for that exact file
"auth" → glob for "**/*auth*.{ts,js,py}"
```
**Function names → Grep patterns:**
```
"handleLogin" → grep for "function handleLogin|const handleLogin|handleLogin\s*[:=(]"
```
### Step 2: Execute Searches in Parallel
Run multiple searches simultaneously:
```bash
# Use Grep tool (NOT bash grep)
Grep pattern="AuthenticationError"
Grep pattern="token.*expir|expir.*token"
Grep pattern="function handleLogin|const handleLogin"
# Use Glob tool (NOT bash find)
Glob pattern="**/*auth*.{ts,js,py,go,rs}"
Glob pattern="**/*login*.{ts,js,py,go,rs}"
Glob pattern="**/middleware*.{ts,js,py,go,rs}"
```
**Important:** Run tools in parallel (single message, multiple tool calls) for speed.
### Step 3: Evaluate Results
Count highly relevant files (files matching multiple patterns):
```python
relevant_files = {}
for result in search_results:
for file in result.files:
relevant_files[file] = relevant_files.get(file, 0) + 1
high_relevance = [f for f, count in relevant_files.items() if count >= 2]
```
**Decision:**
- **≥3 high-relevance files:** Proceed to planning
- **<3 files OR unclear context:** Escalate to Phase 2
### Step 4: Read High-Relevance Files
If targeted search successful:
```bash
# Read the top relevant files
Read file_path="src/auth/middleware.ts"
R