arabelatso/code-search-assistant
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.
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill code-search-assistant
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 cases
Combine 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):
[relevant code snippet from the file]
**Why it matches**: [Brief explanation of similarity]
---
### 2. [file_path] (Score: 0.72)
[... repeat format ...]
Output guidelines:
For better call chain matching:
For better textual matching:
For better functional matching:
Input snippet:
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:
Take arabelatso/code-search-assistant from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.