Search code repositories for code related to a given code snippet, ranking results by call chain similarity, textual similarity, and functional similarity. Use when finding related code, locating similar implementations, discovering code dependencies, or identifying code that performs similar operations. Outputs ranked file lists with matching code snippets and relevance scores.
Install with Tessl CLI
npx tessl i github:ArabelaTso/Skills-4-SE --skill code-search-assistant85
Does it follow best practices?
If you maintain this skill, you can automatically optimize it using the tessl CLI to improve its score:
npx tessl skill review --optimize ./path/to/skillValidation for skill structure
Search codebases to find code related to a given snippet using multi-dimensional similarity analysis: call chain patterns, textual structure, and functional behavior. Results are ranked and presented with matching code snippets.
Extract key characteristics from the provided code snippet:
Structural elements:
Functional elements:
Textual elements:
Determine where to search:
Use Glob to identify candidate files:
**/*.js, **/*.py, **/*.java, etc.Find code with similar function call patterns and dependencies.
Search strategy:
Example:
// Input snippet calls: fetch(), JSON.parse(), setState()
// High match: Code that calls fetch() → JSON.parse() → setState()
// Medium match: Code that calls fetch() and setState() in different order
// Low match: Code that only calls fetch()Find code with similar structure and token patterns.
Search strategy:
Similarity indicators:
Find code that performs similar operations or solves similar problems.
Search strategy:
Functional categories:
Search patterns:
// For validation code, search for:
- "validate", "check", "verify" in function names
- Conditional checks with error throwing
- Regular expression patterns
// For API calls, search for:
- HTTP client usage (fetch, axios, requests)
- Endpoint URLs or API patterns
- Response handling and error casesCombine similarity scores to rank results:
Scoring formula:
Total Score = (Call Chain Score × 0.35) +
(Textual Score × 0.30) +
(Functional Score × 0.35)Score ranges:
Ranking adjustments:
Present results in ranked order with context:
Result format:
## Search Results for: [Brief snippet description]
### 1. [file_path] (Score: 0.85)
**Similarity breakdown**:
- Call chain: 0.90 (shares fetch, JSON.parse, setState calls)
- Textual: 0.75 (similar variable names and structure)
- Functional: 0.90 (performs same data fetching and state update)
**Matching code** (lines 45-62):
```[language]
[relevant code snippet from the file]Why it matches: [Brief explanation of similarity]
[... repeat format ...]
**Output guidelines**:
- Show top 10 results by default
- Include file path with line numbers
- Show relevant code snippet (10-20 lines)
- Explain why each result matches
- Group results by score tier if many results
## Search Optimization Tips
**For better call chain matching**:
- Include import statements in input snippet
- Provide complete function calls with arguments
- Include chained method calls
**For better textual matching**:
- Use descriptive variable names in input
- Include comments describing intent
- Provide complete code blocks, not fragments
**For better functional matching**:
- Describe what the code does in comments
- Include typical input/output examples
- Show error handling patterns
## Example Usage
**Input snippet**:
```javascript
async function fetchUserData(userId) {
try {
const response = await fetch(`/api/users/${userId}`);
const data = await response.json();
return data;
} catch (error) {
console.error('Failed to fetch user:', error);
return null;
}
}Search process:
fetch(), response.json(), console.error()Expected results:
0f00a4f
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.