packages/kilo-docs/pages/automate/tools/semantic-search.md
{% callout type="info" title="Setup Required" %}
The semantic_search tool is part of the Codebase Indexing feature. It requires additional setup including an embedding provider and vector database.
{% /callout %}
The semantic_search tool performs semantic searches across your entire codebase using AI embeddings. Unlike traditional text-based search, it understands the meaning of your queries and finds relevant code even when exact keywords don't match.
The tool accepts these parameters:
query (required): Natural language search query describing what you're looking forpath (optional): Directory path to limit search scope to a specific part of your codebaseThis tool searches through your indexed codebase using semantic similarity rather than exact text matching. It finds code blocks that are conceptually related to your query, even if they don't contain the exact words you searched for. Results include relevant code snippets with file paths, line numbers, and similarity scores.
This tool is only available when the Codebase Indexing feature is properly configured:
When the semantic_search tool is invoked, it follows this process:
Availability Validation:
Query Processing:
Vector Search Execution:
Path Filtering (if specified):
Result Processing and Formatting:
Dual Output Format:
Good: Conceptual and specific
<semantic_search>
<query>user authentication and password validation</query>
</semantic_search>
Good: Feature-focused
<semantic_search>
<query>database connection pool setup</query>
</semantic_search>
Good: Problem-oriented
<semantic_search>
<query>error handling for API requests</query>
</semantic_search>
Less effective: Too generic
<semantic_search>
<query>function</query>
</semantic_search>
Use the optional path parameter to focus searches on specific parts of your codebase:
Search within API modules:
<semantic_search>
<query>endpoint validation middleware</query>
<path>src/api</path>
</semantic_search>
Search in test files:
<semantic_search>
<query>mock data setup patterns</query>
<path>tests</path>
</semantic_search>
Search specific feature directories:
<semantic_search>
<query>component state management</query>
<path>src/components/auth</path>
</semantic_search>
Each search result includes:
Searching for authentication-related code across the entire project:
<semantic_search>
<query>user login and authentication logic</query>
</semantic_search>
Finding database-related code in a specific directory:
<semantic_search>
<query>database connection and query execution</query>
<path>src/data</path>
</semantic_search>
Looking for error handling patterns in API code:
<semantic_search>
<query>HTTP error responses and exception handling</query>
<path>src/api</path>
</semantic_search>
Searching for testing utilities and mock setups:
<semantic_search>
<query>test setup and mock data creation</query>
<path>tests</path>
</semantic_search>
Finding configuration and environment setup code:
<semantic_search>
<query>environment variables and application configuration</query>
</semantic_search>