| created | "2025-12-16T00:00:00.000Z" |
| modified | "2025-12-16T00:00:00.000Z" |
| reviewed | "2025-12-16T00:00:00.000Z" |
| name | VectorCode Semantic Search |
| description | Semantic code search with VectorCode using embeddings for finding code by meaning, not just keywords. Use when searching for code patterns, similar implementations, concept-based search, or when keyword search fails. Automatically available via MCP. |
| allowed-tools | mcp__vectorcode, Read, Grep, Glob |
VectorCode Semantic Search
Expert knowledge for using VectorCode's semantic code search capabilities through MCP integration. VectorCode indexes code using embeddings, enabling searches based on meaning and context rather than exact keyword matches.
Core Expertise
Semantic Search
- Find code by intent and meaning, not just keywords
- Discover similar implementations across codebases
- Locate related functionality without knowing exact names
- Cross-language concept search
Index Management
- List indexed projects and files
- Add new files to the index
- Remove outdated or irrelevant files
- Verify index coverage
Query Optimization
- Formulate effective semantic queries
- Combine with traditional search tools
- Balance recall vs precision
- Iterate queries based on results
When to Use VectorCode
✅ Use VectorCode when:
- Searching by concept or intent ("authentication logic", "error handling patterns")
- Finding similar code without knowing exact function names
- Exploring unfamiliar codebases
- Discovering related functionality across modules
- Keyword search returns too many or irrelevant results
- Looking for implementation patterns
❌ Use Grep/Glob instead when:
- Searching for exact strings or identifiers
- Finding specific function/class names
- Locating file paths or extensions
- Simple pattern matching suffices
- Need complete exhaustive results
🔀 Combine both when:
- Initial semantic search to find areas of interest
- Follow up with grep for specific details
- Broad concept search, narrow with keywords
Essential MCP Tools
List Indexed Projects
When to use:
- Starting work on a new machine
- Verifying project is indexed
- Choosing project_root for queries
- Troubleshooting missing results
Query Code Semantically
{
"n_query": 10,
"query_messages": [
"authentication",
"user login",
"session management"
],
"project_root": "/path/to/project"
}
Parameters:
n_query (number): Results to return (start with 10-20)
query_messages (array): Distinct keywords or phrases
project_root (string): Exact path from ls output
Returns:
- File paths with relevance scores
- Code snippets with context
- Line ranges for matches
Add Files to Index
{
"paths": [
"/absolute/path/to/file1.py",
"/absolute/path/to/file2.js"
],
"project_root": "/path/to/project"
}
When to use:
- After creating new files
- When expanding index coverage
- After major code changes
- Before semantic search sessions
Important: Use absolute paths for files
List Indexed Files
{
"project_root": "/path/to/project"
}
When to use:
- Verifying what's indexed
- Checking coverage of modules
- Debugging missing results
- Planning index updates
Remove Files from Index
{
"files": [
"/absolute/path/to/file1.py",
"/absolute/path/to/file2.js"
],
"project_root": "/path/to/project"
}
When to use:
- After deleting source files
- Removing generated/build files
- Cleaning up old code
- Reducing index size
Query Formulation Best Practices
Effective Query Keywords
✅ Good queries:
["database connection", "connection pooling"]
["user authentication", "password validation"]
["error handling", "try catch", "exception"]
["HTTP request", "API endpoint", "REST"]
❌ Poor queries:
["function getUserById"]
["data"]
["async def", "try:"]
Query Keywords Should Be:
-
Conceptual, not literal
- ❌ "def authenticate"
- ✅ "user authentication logic"
-
Distinct and orthogonal
- ❌ ["login", "sign in", "authenticate"] (redundant)
- ✅ ["authentication", "session", "authorization"] (different aspects)
-
Multiple perspectives
- ✅ ["database", "persistence", "storage"] (covers concept broadly)
-
Domain language
- ✅ ["HTTP request", "API client", "REST endpoint"]
Iterative Query Refinement
query: ["authentication", "login"]
result: Too many results
query: ["OAuth authentication", "token validation"]
result: Better, but missing some
query: ["OAuth", "JWT token", "bearer authentication"]
result: Good coverage
Common Patterns
Explore Unfamiliar Codebase
mcp__vectorcode__ls()
mcp__vectorcode__query({
n_query: 20,
query_messages: ["main entry point", "application startup", "initialization"],
project_root: "/path/to/project"
})
mcp__vectorcode__query({
n_query: 15,
query_messages: ["database schema", "models", "ORM"],
project_root: "/path/to/project"
})
Find Similar Implementations
mcp__vectorcode__query({
n_query: 10,
query_messages: ["error handling", "exception management", "retry logic"],
project_root: "/path/to/project"
})
mcp__vectorcode__query({
n_query: 15,
query_messages: ["REST API", "HTTP handler", "endpoint routing"],
project_root: "/path/to/project"
})
Cross-Module Search
mcp__vectorcode__query({
n_query: 20,
query_messages: ["authentication", "authorization", "access control"],
project_root: "/path/to/project"
})
Discover Dependencies
mcp__vectorcode__query({
n_query: 15,
query_messages: ["external API", "third party", "service integration"],
project_root: "/path/to/project"
})
mcp__vectorcode__query({
n_query: 15,
query_messages: ["database query", "SQL", "data access"],
project_root: "/path/to/project"
})
Locate Configuration
mcp__vectorcode__query({
n_query: 10,
query_messages: ["configuration", "settings", "environment variables"],
project_root: "/path/to/project"
})
Debug Feature Implementation
mcp__vectorcode__query({
n_query: 15,
query_messages: ["user registration", "signup", "account creation"],
project_root: "/path/to/project"
})
Combining with Traditional Search
Two-Stage Search Strategy
mcp__vectorcode__query({
n_query: 20,
query_messages: ["payment processing", "transaction"],
project_root: "/path/to/project"
})
grep -r "process_payment" src/payments/ src/api/
Validation Pattern
vectorcode: "configuration loading"
grep -l "load_config\|read_settings" config.py settings.py env.py
Index Management Workflow
Initial Setup
mcp__vectorcode__ls()
mcp__vectorcode__files_ls({project_root: "/path/to/project"})
mcp__vectorcode__vectorise({
paths: ["/path/to/new_file.py"],
project_root: "/path/to/project"
})
Maintain Index
mcp__vectorcode__vectorise({
paths: ["/path/to/new_module.py", "/path/to/new_util.js"],
project_root: "/path/to/project"
})
mcp__vectorcode__files_rm({
files: ["/path/to/old_file.py"],
project_root: "/path/to/project"
})
Troubleshooting Missing Results
mcp__vectorcode__files_ls({project_root: "/path/to/project"})
mcp__vectorcode__vectorise({
paths: ["/path/to/missing_file.py"],
project_root: "/path/to/project"
})
Advanced Techniques
Multi-Concept Queries
mcp__vectorcode__query({
n_query: 25,
query_messages: [
"authentication",
"authorization",
"permission check",
"access control",
"role based"
],
project_root: "/path/to/project"
})
Progressive Refinement
n_query: 30
query: ["feature X"]
n_query: 15
query: ["feature X", "specific aspect", "related concept"]
n_query: 10
query: ["very specific aspect", "implementation detail"]
Cross-Language Patterns
mcp__vectorcode__query({
n_query: 20,
query_messages: ["async operations", "concurrency", "parallel execution"],
project_root: "/path/to/project"
})
Performance Tips
Query Size:
- Start with
n_query: 10-15 for focused results
- Increase to
20-30 for broad exploration
- Higher numbers = more results but lower relevance
Query Formulation:
- Spend time on good keywords
- Use 2-5 distinct concepts
- Use distinct, specific search terms
- Think about synonyms and related concepts
Project Root:
- Always use exact path from
mcp__vectorcode__ls
- Case-sensitive on Unix systems
- Include/exclude trailing slashes consistently
Indexing:
- Index incrementally (new files only)
- Don't re-index entire project frequently
- Use git hooks for automatic indexing
Common Pitfalls
❌ Using Exact Code as Query
query: ["def process_payment(amount, user_id):"]
query: ["payment processing", "transaction handling"]
❌ Single Generic Word
query: ["function"]
query: ["utility functions", "helper methods", "common operations"]
❌ Wrong Project Root
❌ Expecting Exact Matches
Integration with Other Skills
Combine with:
- rg-code-search - Follow up with exact keyword search
- fd-file-finding - Locate files by name after VectorCode narrows scope
- grep - Extract specific patterns from VectorCode results
Workflow:
- VectorCode: Find relevant areas semantically
- fd/glob: Locate specific files in those areas
- grep/rg: Extract exact code patterns
- Read: Examine specific files
Comparison Matrix
| Need | Tool | Why |
|---|
| Find by concept | VectorCode | Semantic understanding |
| Find exact string | grep/rg | Fast, exhaustive |
| Find files by name | fd/glob | File system patterns |
| Explore unknown code | VectorCode | No prior knowledge needed |
| Verify completeness | grep | Exhaustive search |
| Find similar code | VectorCode | Pattern recognition |
Quick Reference
MCP Tools
mcp__vectorcode__ls - List indexed projects
mcp__vectorcode__query - Semantic code search
mcp__vectorcode__vectorise - Add files to index
mcp__vectorcode__files_ls - List indexed files
mcp__vectorcode__files_rm - Remove files from index
Query Parameters
n_query - Number of results (10-30 typical)
query_messages - Array of distinct keywords
project_root - Exact project path from ls
Best Practices
- Use concept-based keywords
- Provide 2-5 distinct terms
- Start broad, refine iteratively
- Combine with traditional search
- Verify project_root exactly
Common Query Patterns
["main functionality", "core logic", "entry point"]
["user authentication", "login flow", "session management"]
["error handling", "retry logic", "fallback"]
["database access", "API integration", "service layer"]
Resources
- VectorCode MCP Integration: Automatically available when MCP server is configured
- Git Hooks: Use
vectorcode init --hooks to auto-index on commits
- Index Files:
.vectorcode.include and .vectorcode.exclude control indexing