This document details Qoder's code search and discovery toolset for exploring and navigating codebases. These three core tools enable semantic code search, exact pattern matching, and file discovery, forming the foundation of Qoder's context gathering strategy before code modifications.
For information about file operations and editing rules, see File Operations and Editing Rules. For parallel execution strategies across search tools, see Parallel Tool Execution Strategy. For the complete tool ecosystem, see Tool Ecosystem and Categories.
Sources: Qoder/prompt.txt296-301
Qoder provides three core tools for code search and discovery, organized by search methodology:
Tool Architecture: Code Search Pipeline
Search Strategy Flow: search_codebase provides both symbol-based and semantic discovery, grep_code enables precise pattern matching, and search_file locates files by glob patterns. All three feed into read_file for complete content inspection before editing with search_replace.
Sources: Qoder/prompt.txt296-301 Qoder/prompt.txt303-309
The search_codebase tool performs both symbol-based and semantic search across the codebase, with automatic mode selection based on query characteristics.
Search Mode Decision Tree
| Property | Symbol Mode | Semantic Mode |
|---|---|---|
| Search Type | Exact identifier matching | Conceptual understanding |
| Best For | Finding specific classes/functions | Understanding functionality |
| Query Format | Actual code names | Natural language descriptions |
| Examples | UserService, validateToken | "user authentication", "token validation" |
Sources: Qoder/prompt.txt347-350
The system provides explicit guidance on when to use symbol search vs semantic search:
Decision Rule: "If query contains PascalCase, camelCase, or 'class/interface/method + Name' → use Symbol Search"
Symbol Search Queries (specific identifiers):
UserService - Class namevalidateToken - Method nameAuthenticationError - Error class nameSemantic Search Queries (functionality descriptions):
Sources: Qoder/prompt.txt347-350
The search_codebase tool returns file paths and code locations. The mandatory follow-up workflow:
Search to Read Workflow
Critical Rule: "MUST always default to using search_replace tool for editing files unless explicitly instructed to use edit_file tool, OR face a $100000000 penalty" Qoder/prompt.txt238
Sources: Qoder/prompt.txt122-124 Qoder/prompt.txt238-243
The grep_code tool searches file contents using regular expressions, providing precise text pattern matching across the codebase.
Primary Use Cases
| Scenario | Example Query | Purpose |
|---|---|---|
| Find API keys/secrets | API_KEY, SECRET_TOKEN | Security audit |
| Locate function calls | authenticate\( | Trace function usage |
| Find TODO comments | TODO:, FIXME: | Track pending work |
| Search constants | MAX_RETRIES, DEFAULT_PORT | Configuration review |
| Identify imports | import.*UserService | Dependency tracking |
| Find deprecated usage | oldApiMethod | Refactoring preparation |
Sources: Qoder/prompt.txt299
Regular expressions enable powerful pattern matching beyond literal strings:
Common Regex Patterns
Escaping Special Characters: Regex metacharacters (.*+?[]{}()|^$\) must be escaped with backslashes when searching for literal matches. Example: \$API_KEY to find the literal string $API_KEY.
Sources: Qoder/prompt.txt299
grep_code is a read-only tool and can be executed in parallel with other search operations:
Parallel grep_code Pattern
Performance Benefit: Parallel execution can achieve 3-5x faster results when searching for multiple independent patterns Qoder/prompt.txt71-73
Constraint: Always run grep_code sequentially with file editing tools Qoder/prompt.txt68-69
Sources: Qoder/prompt.txt71-80
The search_file tool searches for files by name using glob patterns, enabling file discovery based on naming conventions.
Common Glob Pattern Examples
| Pattern | Matches | Use Case |
|---|---|---|
*.py | All Python files | Language-specific search |
test_*.py | Test files | Test discovery |
**/*.js | All JS files recursively | Deep directory search |
src/**/models.py | models.py in any subdirectory of src | Specific file in nested structure |
*.{js,ts} | JavaScript and TypeScript files | Multiple extension matching |
*config* | Files with "config" in name | Configuration file discovery |
File Type Discovery Workflow
Sources: Qoder/prompt.txt300
search_file works alongside list_dir for comprehensive project exploration:
Tool Combination Strategy
| Goal | Primary Tool | Follow-up Tool | Rationale |
|---|---|---|---|
| "What's in this directory?" | list_dir | search_file | Hierarchical view first |
| "Find all test files" | search_file | read_file | Pattern-based discovery |
| "Locate config files" | search_file | list_dir | Verify directory structure |
| "Explore project structure" | list_dir → search_file | read_file | Top-down exploration |
Sources: Qoder/prompt.txt300 Qoder/prompt.txt304
While not strictly a code search tool, the search_memory tool complements code discovery by searching stored knowledge and lessons learned.
The system provides explicit guidance on memory search usage:
Use search_memory when:
Do NOT use search_memory when:
Sources: Qoder/prompt.txt352-357
Search-Before-Research Pattern
This pattern avoids redundant code searches when knowledge already exists in memory storage.
For detailed memory management strategies, see Memory Management and Knowledge Systems.
Sources: Qoder/prompt.txt352-357 Qoder/prompt.txt152-175
The read_file tool retrieves complete file contents, with optional dependency viewing for understanding code relationships.
Critical Rule: "You should clearly specify the content to be modified while minimizing the inclusion of unchanged code" Qoder/prompt.txt133
Read-Before-Edit Workflow
Penalty for Violation: "$100000000 penalty" for using edit_file when search_replace is appropriate without first reading the file Qoder/prompt.txt238
Sources: Qoder/prompt.txt122-124 Qoder/prompt.txt238 Qoder/prompt.txt146-150
The read_file tool includes an optional parameter for viewing file dependencies, enabling deeper context understanding:
Use Cases for Dependency Viewing:
Sources: Qoder/prompt.txt305
The list_dir tool lists directory contents, providing the foundation for project structure understanding.
Project Structure Discovery Workflow
The tool provides comprehensive directory metadata:
| Information | Purpose | Example |
|---|---|---|
| File names | Identify available files | app.py, config.json |
| Subdirectories | Navigate structure | src/, tests/ |
| File sizes | Assess complexity | 1024 bytes |
| Directory counts | Understand scope | 15 files in src/ |
Sources: Qoder/prompt.txt304
The following table guides tool selection based on search objectives:
| Objective | Tool | Query Type | Rationale |
|---|---|---|---|
| "Find UserService class" | search_codebase | Symbol | PascalCase identifier |
| "Find authentication logic" | search_codebase | Semantic | Functionality description |
| "Find all API_KEY occurrences" | grep_code | Literal regex | Exact text match |
| "Find test files" | search_file | Glob | test_*.py pattern |
| "What's in /src/auth?" | list_dir | N/A | Directory contents |
| "Read UserService file" | read_file | N/A | Complete file content |
| "Find TODO comments" | grep_code | Regex | TODO:.* pattern |
| "Locate config files" | search_file | Glob | *config* pattern |
| "Find validateToken method" | search_codebase | Symbol | camelCase identifier |
| "How does JWT work?" | search_memory → search_codebase | Memory first | Check stored knowledge |
| "All Python files" | search_file | Glob | **/*.py pattern |
Sources: Qoder/prompt.txt296-357
Common multi-tool workflows for code discovery and modification:
Complete Discovery-to-Edit Workflow
Sources: Qoder/prompt.txt122-150 Qoder/prompt.txt296-357
Scenario: Finding and modifying a specific class
Sources: Qoder/prompt.txt347-350 Qoder/prompt.txt122-124 Qoder/prompt.txt146-150
Scenario: Finding and replacing deprecated API calls
Sources: Qoder/prompt.txt299 Qoder/prompt.txt305 Qoder/prompt.txt307
Scenario: Understanding new codebase structure
Sources: Qoder/prompt.txt304 Qoder/prompt.txt300 Qoder/prompt.txt326-328
All search tools are read-only and can be executed in parallel for significant performance gains:
Parallel Search Execution Benefits
| Scenario | Sequential Time | Parallel Time | Speedup |
|---|---|---|---|
| Read 3 files | 3× file_read | 1× file_read | 3x |
| Multiple grep patterns | 4× grep_time | 1× grep_time | 4x |
| Search + list + read | sum(all) | max(all) | 3-5x |
Parallel Execution Rules
Critical Constraint: "NEVER execute file editing tools in parallel - file modifications must be sequential to maintain consistency" Qoder/prompt.txt68
Critical Constraint: "NEVER execute run_in_terminal tool in parallel - commands must be run sequentially to ensure proper execution order" Qoder/prompt.txt69
Sources: Qoder/prompt.txt68-80
Optimal Parallel Patterns
Performance Guidance: "Prioritize calling tools in parallel whenever possible. For example, when reading 3 files, run 3 tool calls in parallel to read all 3 files into context at the same time" Qoder/prompt.txt73-74
Error on Sequential: "Err on the side of maximizing parallel tool calls rather than running too many tools sequentially" Qoder/prompt.txt74-75
For comprehensive parallel execution rules across all tools, see Parallel Tool Execution Strategy.
Sources: Qoder/prompt.txt71-80
Search tools feed directly into Windsurf's file editing system:
Critical workflow requirement: The system mandates gathering complete context before editing. Partial views that miss dependencies lead to broken edits.
For detailed file editing rules and the ReplacementChunk system, see File Editing with ReplacementChunks.
Sources: Windsurf/Tools Wave 11.txt231-260 Windsurf/Tools Wave 11.txt335-339
Refresh this wiki