AgentSkillsCN

similar-code

使用向量搜索(armyknife searchx)在整个代码库中查找语义相似的代码。适用于寻找相似实现、重复代码或现有模式时。需使用 symbols.db。

SKILL.md
--- frontmatter
name: similar-code
description: Find semantically similar code across the codebase using vector search (armyknife searchx). Use when looking for similar implementations, duplicate code, or existing patterns. Requires symbols.db.
keywords: similar-code, 類似コード, 似た実装, 重複コード
  • Always use actual code as query input, not natural language descriptions
  • Prerequisite: symbols.db must exist at project root (built via armyknife searchx index)

Workflow

  1. User provides code as argument (e.g., /similar-code <pasted code>)
  2. Run the search command:
bash
armyknife searchx query '<code>' --limit 10 --database symbols.db
  1. Present results as a table (symbol, kind, file, line, similarity)
  2. Read top matches to show code context

Interpreting Results

SimilarityMeaning
0.8+Very similar (likely same pattern or implementation)
0.6-0.8Related (similar structure or purpose)
<0.6Weak match

Limitations

Input TypeResult Quality
Actual codeGood (designed for code-to-code similarity)
Natural languagePoor (embedding model is code-focused)

Code is embedded using embeddinggemma:300m (768-dim) via Ollama.