name: dev-research-codebase-exploration description: Efficient codebase search using Glob and Grep category: research
Codebase Exploration
Efficiently explore the codebase using Glob and Grep tools.
Glob Tool
Find files by pattern:
# Find all TypeScript files
Glob("**/*.ts")
# Find all TSX files
Glob("**/*.tsx")
# Find specific folders
Glob("src/components/**/*.tsx")
Glob("src/hooks/**/*.ts")
# Find files with keyword
Glob("**/*player*")
Glob("**/*physics*")
Grep Tool
Search file contents:
# Search for specific text
Grep("useFrame", "src/")
Grep("useState", "src/")
# Case-insensitive search
Grep("COLYSEUS", "src/", { ignoreCase: true })
# Search with context
Grep("function.*movement", "src/", { context: 2 })
Search Patterns
Find Component Definitions
Grep("function.*Component|const.*=.*=>", "src/components/")
Find State Stores
Glob("src/stores/**/*.ts")
Grep("create.*Store|zustand", "src/stores/")
Find Type Definitions
Glob("src/types/**/*.ts")
Grep("interface.*|type.*=", "src/types/")
Find Exports
Grep("export.*function|export.*const", "src/")
Tips
- Start broad, then narrow - Use Glob first, then Grep
- Use specific patterns - More specific = faster results
- Check multiple locations - Code may be in unexpected places
- Read related files - Found patterns often have related code nearby
Anti-Patterns
❌ DON'T:
- Use overly broad globs -
Glob("**/*")is useless - Search from root every time - Narrow to relevant directories
- Ignore file extensions - Searching
.mdfiles for code patterns wastes time - Skip context - Reading just the matched line misses important context
- Search for common words -
Grep("const")returns everything
✅ DO:
- Combine Glob + Grep -
Glob("src/**/*.ts")thenGrep("pattern", "src/") - Use specific globs -
Glob("src/components/**/*.tsx")instead ofGlob("**/*.tsx") - Search with context -
Grep("pattern", "src/", { context: 3 }) - Filter by file type - Search
.tsfiles for code,.mdfor docs - Start from known locations - Check similar features first