Code Search Assistantのロゴ

Code Search Assistant

コミュニティ
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.

概要

公開者ArabelaTso
リポジトリSkills-4-SE
スキル名code-search-assistant
スター
258
フォーク
25
同梱ファイル
指示のみ
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    ArabelaTsoがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルCode Search AssistantをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/ArabelaTso/Skills-4-SE/tree/main/skills/code-search-assistant
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ArabelaTso/Skills-4-SE.git /tmp/Skills-4-SE
mkdir -p .claude/skills
cp -r /tmp/Skills-4-SE/skills/code-search-assistant .claude/skills/code-search-assistant
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでCode Search Assistantを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にCode Search Assistantを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Code Search Assistantは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Code Search Assistant

Overview

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.

Workflow

1. Analyze Input Snippet

Extract key characteristics from the provided code snippet:

Structural elements:

  • Function/method calls made
  • Classes/types used
  • Control flow patterns (loops, conditionals, try-catch)
  • Data structures (arrays, objects, maps)

Functional elements:

  • Purpose/intent of the code
  • Input/output behavior
  • Side effects (I/O, state changes, API calls)
  • Domain concepts (authentication, validation, transformation)

Textual elements:

  • Variable and function names
  • String literals and constants
  • Comments and documentation
  • Code tokens and keywords

2. Define Search Scope

Determine where to search:

  • Full repository: Search all code files
  • Specific directories: Focus on relevant modules
  • File type filter: Limit to specific languages

Use Glob to identify candidate files:

**/*.js, **/*.py, **/*.java, etc.

3. Search by Call Chain Similarity

Find code with similar function call patterns and dependencies.

Search strategy:

  1. Extract function/method calls from input snippet
  2. Use Grep to find files containing those function calls
  3. Read matching files to analyze call sequences
  4. Score based on:
    • Number of shared function calls (weight: 40%)
    • Order of function calls (weight: 30%)
    • Shared imported modules/libraries (weight: 30%)

Example:

javascript
// 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()

4. Search by Textual Similarity

Find code with similar structure and token patterns.

Search strategy:

  1. Extract key identifiers from input snippet (function names, variable names)
  2. Use Grep to find files with similar identifiers
  3. Read matching files to compare code structure
  4. Score based on:
    • Shared variable/function names (weight: 35%)
    • Similar control flow structure (weight: 35%)
    • Shared keywords and operators (weight: 30%)

Similarity indicators:

  • Same loop patterns (for, while, forEach, map)
  • Similar conditional logic (if-else chains, switch statements)
  • Matching data structure operations (array methods, object access)
  • Similar string/number operations

5. Search by Functional Similarity

Find code that performs similar operations or solves similar problems.

Search strategy:

  1. Identify the functional purpose of input snippet
  2. Search for code with similar purpose using semantic patterns
  3. Look for:
    • Similar input/output transformations
    • Equivalent algorithms (different implementations, same result)
    • Parallel business logic
    • Alternative approaches to same problem

Functional categories:

  • Data transformation: Mapping, filtering, reducing, sorting
  • Validation: Input checking, format validation, constraint enforcement
  • I/O operations: File reading/writing, API calls, database queries
  • Authentication/Authorization: Login, permission checks, token handling
  • Error handling: Try-catch patterns, error recovery, logging

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

6. Rank and Score Results

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:

  • 0.8-1.0: Very high similarity (likely duplicate or variant)
  • 0.6-0.8: High similarity (related implementation)
  • 0.4-0.6: Medium similarity (similar patterns or purpose)
  • 0.2-0.4: Low similarity (some shared elements)
  • 0.0-0.2: Minimal similarity (weak connection)

Ranking adjustments:

  • Boost files in same directory (+10%)
  • Boost files with similar names (+5%)
  • Penalize test files (-10%) unless input is a test
  • Penalize generated/vendor code (-20%)

7. Format Results

Present results in ranked order with context:

Result format:

markdown
## 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]


2. [file_path] (Score: 0.72)

[... 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:

  1. Call chain: Search for fetch(), response.json(), console.error()
  2. Textual: Search for async functions with try-catch, similar variable names
  3. Functional: Search for API data fetching patterns, error handling

Expected results:

  • Other API fetch functions (high similarity)
  • Data retrieval functions using different libraries (medium similarity)
  • Functions with similar error handling (low-medium similarity)

Tips

  • Start with a complete, representative code snippet (10-30 lines)
  • Include context (imports, surrounding code) for better matching
  • For large codebases, narrow search scope to relevant directories
  • Adjust score weights based on what matters most (calls vs. structure vs. purpose)
  • Review medium-scored results (0.4-0.6) for unexpected but useful matches
  • Use results to discover alternative implementations or refactoring opportunities

よくある質問

AIスキル「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.

TypingMindでCode Search Assistantを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Code Search Assistantはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにCode Search Assistantをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/ArabelaTso/Skills-4-SE/tree/main/skills/code-search-assistantを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Code Search Assistantを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Code Search Assistantは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもCode Search Assistantを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Code Search Assistant」は無料ですか?

はい。ArabelaTsoがGitHubでApache-2.0ライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇