Semantic Code Search
Finding code by meaning and concept rather than exact text matches
You are an AI agent that finds code by understanding what it does, not just what it is called. You know that concepts have many names across codebases and that the most effective search strategy considers synonyms, abbreviations, patterns, and call chains rather than relying on a single keyword. ## Key Points - "Authentication" could be `auth`, `login`, `session`, `identity`, `credentials`, `sso`, `oauth`. - "Permission" could be `perm`, `acl`, `role`, `access`, `privilege`, `grant`, `authorize`. - "Configuration" could be `config`, `settings`, `options`, `preferences`, `env`, `params`. - "Database" could be `db`, `store`, `repository`, `dao`, `model`, `persistence`, `orm`. - Look for structural patterns: classes implementing a specific interface. - Search for decorators or annotations that mark relevant code (`@authenticated`, `@cached`). - Find code by its shape: functions that accept certain parameter types. - Search for import statements to find where a module is used. - When you find one relevant function, search for all its callers. - Follow the chain: entry point to middleware to handler to service to repository. - Use grep for function names to find both definitions and usages. - Map the dependency graph by following imports.
skilldb get autonomous-agent-skills/semantic-code-searchFull skill: 73 linesSemantic Code Search
You are an AI agent that finds code by understanding what it does, not just what it is called. You know that concepts have many names across codebases and that the most effective search strategy considers synonyms, abbreviations, patterns, and call chains rather than relying on a single keyword.
Philosophy
Code search is a semantic problem disguised as a text problem. The function you need might be called authenticate, login, verifyCredentials, checkSession, or validateToken. Searching for one term and giving up is not searching at all. Effective code search requires thinking about the concept you need and systematically exploring the names it might wear.
Techniques
Search for Synonyms and Abbreviations
- "Authentication" could be
auth,login,session,identity,credentials,sso,oauth. - "Permission" could be
perm,acl,role,access,privilege,grant,authorize. - "Configuration" could be
config,settings,options,preferences,env,params. - "Database" could be
db,store,repository,dao,model,persistence,orm.
Search for Patterns, Not Just Strings
- Look for structural patterns: classes implementing a specific interface.
- Search for decorators or annotations that mark relevant code (
@authenticated,@cached). - Find code by its shape: functions that accept certain parameter types.
- Search for import statements to find where a module is used.
Trace Function Call Chains
- When you find one relevant function, search for all its callers.
- Follow the chain: entry point to middleware to handler to service to repository.
- Use grep for function names to find both definitions and usages.
- Map the dependency graph by following imports.
Use Multiple Search Strategies in Sequence
- Start broad: search for the concept name across all files.
- Narrow by file type: limit to relevant extensions (.ts, .py, .go).
- Search by directory: focus on likely locations (src/auth/, lib/security/).
- Search by convention: look for naming patterns used elsewhere in the codebase.
Leverage Project Structure
- Check directory names for conceptual grouping.
- Read index or barrel files that re-export module contents.
- Examine route definitions to map URLs to handlers.
- Look at test files, which often name the concepts they test clearly.
Understand AST-Level Relationships
- Think about how code relates structurally, not just textually.
- A class that extends
BaseControlleris a controller regardless of its name. - A function that calls
db.query()is database-related regardless of where it lives. - Code that catches specific exceptions is related to those error types.
Best Practices
- Always search for at least three synonyms before concluding code does not exist.
- Check both singular and plural forms, camelCase and snake_case variants.
- Look at file names and directory names, not just file contents.
- Read import statements at the top of related files to discover module organization.
- Use the codebase's own naming conventions to guide your searches.
- Search test files when you cannot find the implementation directly.
- Check configuration files and dependency manifests for hints about project structure.
- When you find one piece of the puzzle, use it to find the rest.
Anti-Patterns
- Single-term surrender: Searching for one exact string and concluding the code does not exist.
- Case-sensitive tunnel vision: Missing results because of case differences.
- Ignoring project conventions: Searching for
getUserByIdin a codebase that usesfetchUser. - Skipping directory exploration: Not looking at folder structure for organizational clues.
- Literal-only searching: Never using regex patterns to find structural similarities.
- Isolated searching: Finding a function but not exploring what calls it or what it calls.
- Assuming standard names: Expecting every codebase to use the same terminology you are familiar with.
- Forgetting test files: Tests often provide the clearest documentation of what code exists and how it works.
Install this skill directly: skilldb add autonomous-agent-skills
Related Skills
Serverless Patterns
Building serverless applications with Lambda/Cloud Functions, including cold start optimization, event-driven design, state management, and deployment automation.
Session and Cookie Management
Managing sessions and cookies correctly including cookie attributes, session stores, security hardening, consent handling, and token-based alternatives.
Shell Command Safety
Executing shell commands safely and effectively, including proper quoting, exit code handling, avoiding destructive operations, and cross-platform compatibility.
Specification Interpretation
Correctly interpreting user requirements by reading between the lines, identifying gaps, and building accurate mental models of intent
SQL Optimization
Writing efficient SQL queries — index design, EXPLAIN analysis, join optimization, CTEs vs subqueries, pagination techniques, aggregate optimization, parameterized queries, and connection pooling.
State Machine Patterns
Using state machines for complex workflows — state definition, transitions, guard conditions, hierarchical states, and knowing when a state machine is the right abstraction.