jpskill.com
🛠️ 開発・MCP コミュニティ

codebase-search

Search and navigate large codebases efficiently. Use when finding specific code patterns, tracing function calls, understanding code structure, or locating bugs. Handles semantic search, grep patterns, AST analysis.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o codebase-search.zip https://jpskill.com/download/20894.zip && unzip -o codebase-search.zip && rm codebase-search.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/20894.zip -OutFile "$d\codebase-search.zip"; Expand-Archive "$d\codebase-search.zip" -DestinationPath $d -Force; ri "$d\codebase-search.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して codebase-search.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → codebase-search フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

[Skill 名] codebase-search

コードベース検索

このスキルを使用するタイミング

  • 特定の関数やクラスを見つける
  • 関数呼び出しと依存関係を追跡する
  • コードの構造とアーキテクチャを理解する
  • 使用例を見つける
  • コードパターンを特定する
  • バグや問題の場所を特定する
  • コード考古学(レガシーコードの理解)
  • 変更前の影響分析

手順

ステップ 1: 探しているものを理解する

機能の実装:

  • 機能 X はどこに実装されていますか?
  • 機能 Y はどのように動作しますか?
  • 機能 Z に関連するファイルは何ですか?

バグの場所:

  • このエラーはどこから来ていますか?
  • どのコードがこのケースを処理していますか?
  • このデータはどこで変更されていますか?

API の使用法:

  • この API はどのように使用されていますか?
  • この関数はどこで呼び出されていますか?
  • これを使用する例は何ですか?

設定:

  • 設定はどこで定義されていますか?
  • これはどのように設定されていますか?
  • 設定オプションは何ですか?

ステップ 2: 検索戦略を選択する

セマンティック検索(概念的な質問の場合):

使用するタイミング: 探しているものを概念的に理解している場合
例:
- 「ユーザー認証はどのように処理されますか?」
- 「メール検証はどこに実装されていますか?」
- 「データベースにはどのように接続しますか?」

利点:
- 意味によって関連するコードを見つける
- 不慣れなコードベースでも機能する
- 探索的な検索に適している

Grep(正確なテキスト/パターンの場合):

使用するタイミング: 正確なテキストまたはパターンを知っている場合
例:
- 関数名: "def authenticate"
- クラス名: "class UserManager"
- エラーメッセージ: "Invalid credentials"
- 特定の文字列: "API_KEY"

利点:
- 高速で正確
- 正規表現パターンで機能する
- 既知の用語に適している

Glob(ファイル検索の場合):

使用するタイミング: パターンでファイルを見つける必要がある場合
例:
- "**/*.test.js" (すべてのテストファイル)
- "**/config*.yaml" (設定ファイル)
- "src/**/*Controller.py" (コントローラー)

利点:
- タイプ別にファイルを素早く見つける
- ファイル構造を発見する
- 関連ファイルを見つける

ステップ 3: 検索ワークフロー

1. 広く始めてから絞り込む:

ステップ 1: セマンティック検索「認証はどのように機能しますか?」
結果: auth/ ディレクトリを指す

ステップ 2: auth/ 内で特定の関数を Grep する
パターン: "def verify_token"
結果: auth/jwt.py で見つかった

ステップ 3: ファイルを読む
ファイル: auth/jwt.py
結果: 実装を理解する

2. ディレクトリターゲティングを使用する:

# ターゲットなしで開始(すべてを検索)
クエリ: 「ユーザーログインはどこに実装されていますか?」
ターゲット: []

# 特定のディレクトリで絞り込む
クエリ: 「ログインはどこで検証されていますか?」
ターゲット: ["backend/auth/"]

3. 検索を組み合わせる:

# 機能がどこに実装されているかを見つける
セマンティック: "user registration flow"

# 関連するすべてのファイルを見つける
Grep: "def register_user"

# テストファイルを見つける
Glob: "**/*register*test*.py"

# 実装を理解する
読む: registration.py, test_registration.py

ステップ 4: 一般的な検索パターン

関数定義を見つける:

# Python
grep -n "def function_name" --type py

# JavaScript
grep -n "function functionName" --type js
grep -n "const functionName = " --type js

# TypeScript
grep -n "function functionName" --type ts
grep -n "export const functionName" --type ts

# Go
grep -n "func functionName" --type go

# Java
grep -n "public.*functionName" --type java

クラス定義を見つける:

# Python
grep -n "class ClassName" --type py

# JavaScript/TypeScript
grep -n "class ClassName" --type js,ts

# Java
grep -n "public class ClassName" --type java

# C++
grep -n "class ClassName" --type cpp

クラス/関数の使用法を見つける:

# Python
grep -n "ClassName(" --type py
grep -n "function_name(" --type py

# JavaScript
grep -n "new ClassName" --type js
grep -n "functionName(" --type js

インポート/require を見つける:

# Python
grep -n "from.*import.*ModuleName" --type py
grep -n "import.*ModuleName" --type py

# JavaScript
grep -n "import.*from.*module-name" --type js
grep -n "require.*module-name" --type js

# Go
grep -n "import.*package-name" --type go

設定を見つける:

# 設定ファイル
glob "**/*config*.{json,yaml,yml,toml,ini}"

# 環境変数
grep -n "process\\.env\\." --type js
grep -n "os\\.environ" --type py

# 定数
grep -n "^[A-Z_]+\\s*=" --type py
grep -n "const [A-Z_]+" --type js

TODO/FIXME を見つける:

grep -n "TODO|FIXME|HACK|XXX" -i

エラー処理を見つける:

# Python
grep -n "try:|except|raise" --type py

# JavaScript
grep -n "try|catch|throw" --type js

# Go
grep -n "if err != nil" --type go

ステップ 5: 高度なテクニック

データフローを追跡する:

1. データが作成される場所を見つける
   セマンティック: 「ユーザーオブジェクトはどこで作成されますか?」

2. 変数の使用法を検索する
   Grep: "user\\." をコンテキスト行とともに

3. 変換を追跡する
   読む: ユーザーを変更するファイル

4. 消費される場所を見つける
   Grep: 関連ファイル内の "user\\."

関数のすべての呼び出しサイトを見つける:

1. 関数定義を見つける
   Grep: "def process_payment"
   結果: payments/processor.py:45

2. そのモジュールのすべてのインポートを見つける
   Grep: "from payments.processor import"
   結果: 複数のファイル

3. 関数へのすべての呼び出しを見つける
   Grep: "process_payment\\("
   結果: すべての呼び出しサイト

4. 各呼び出しサイトをコンテキストとともに読む
   読む: コンテキストを持つ各ファイル

機能をエンドツーエンドで理解する:

1. API エンドポイントを見つける
   セマンティック: 「ユーザー登録エンドポイントはどこですか?」
   結果: routes/auth.py

2. コントローラーにトレースする
   読む: routes/auth.py
   見つける: AuthController.register への呼び出し

3. サービスにトレースする
   読む: controllers/auth.py
   見つける: UserService.create_user への呼び出し

4. データベースにトレースする
   読む: services/user.py
   見つける: データベース操作

5. テストを見つける
   Glob: "**/*auth*test*.py"
   読む: 例のテストファイル

関連ファイルを見つける:

1. 既知のファイルから始める
   例: models/user.py

2. このファイルのインポートを見つける
   Grep: "from models.user import"

3. これがインポートするファイルを見つける
   読む: models/user.py
   注意: import ステートメント

4. 依存関係グラフを構築する
   マップ: すべての関連ファイル

影響分析:

関数 X を変更する前に:

1. すべての呼び出しサイトを見つける
   Grep: "function_name\\("

2.
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Codebase Search

When to use this skill

  • Finding specific functions or classes
  • Tracing function calls and dependencies
  • Understanding code structure and architecture
  • Finding usage examples
  • Identifying code patterns
  • Locating bugs or issues
  • Code archaeology (understanding legacy code)
  • Impact analysis before changes

Instructions

Step 1: Understand what you're looking for

Feature implementation:

  • Where is feature X implemented?
  • How does feature Y work?
  • What files are involved in feature Z?

Bug location:

  • Where is this error coming from?
  • What code handles this case?
  • Where is this data being modified?

API usage:

  • How is this API used?
  • Where is this function called?
  • What are examples of using this?

Configuration:

  • Where are settings defined?
  • How is this configured?
  • What are the config options?

Step 2: Choose search strategy

Semantic search (for conceptual questions):

Use when: You understand what you're looking for conceptually
Examples:
- "How do we handle user authentication?"
- "Where is email validation implemented?"
- "How do we connect to the database?"

Benefits:
- Finds relevant code by meaning
- Works with unfamiliar codebases
- Good for exploratory searches

Grep (for exact text/patterns):

Use when: You know exact text or patterns
Examples:
- Function names: "def authenticate"
- Class names: "class UserManager"
- Error messages: "Invalid credentials"
- Specific strings: "API_KEY"

Benefits:
- Fast and precise
- Works with regex patterns
- Good for known terms

Glob (for file discovery):

Use when: You need to find files by pattern
Examples:
- "**/*.test.js" (all test files)
- "**/config*.yaml" (config files)
- "src/**/*Controller.py" (controllers)

Benefits:
- Quickly find files by type
- Discover file structure
- Locate related files

Step 3: Search workflow

1. Start broad, then narrow:

Step 1: Semantic search "How does authentication work?"
Result: Points to auth/ directory

Step 2: Grep in auth/ for specific function
Pattern: "def verify_token"
Result: Found in auth/jwt.py

Step 3: Read the file
File: auth/jwt.py
Result: Understand implementation

2. Use directory targeting:

# Start without target (search everywhere)
Query: "Where is user login implemented?"
Target: []

# Refine with specific directory
Query: "Where is login validated?"
Target: ["backend/auth/"]

3. Combine searches:

# Find where feature is implemented
Semantic: "user registration flow"

# Find all files involved
Grep: "def register_user"

# Find test files
Glob: "**/*register*test*.py"

# Understand the implementation
Read: registration.py, test_registration.py

Step 4: Common search patterns

Find function definition:

# Python
grep -n "def function_name" --type py

# JavaScript
grep -n "function functionName" --type js
grep -n "const functionName = " --type js

# TypeScript
grep -n "function functionName" --type ts
grep -n "export const functionName" --type ts

# Go
grep -n "func functionName" --type go

# Java
grep -n "public.*functionName" --type java

Find class definition:

# Python
grep -n "class ClassName" --type py

# JavaScript/TypeScript
grep -n "class ClassName" --type js,ts

# Java
grep -n "public class ClassName" --type java

# C++
grep -n "class ClassName" --type cpp

Find class/function usage:

# Python
grep -n "ClassName(" --type py
grep -n "function_name(" --type py

# JavaScript
grep -n "new ClassName" --type js
grep -n "functionName(" --type js

Find imports/requires:

# Python
grep -n "from.*import.*ModuleName" --type py
grep -n "import.*ModuleName" --type py

# JavaScript
grep -n "import.*from.*module-name" --type js
grep -n "require.*module-name" --type js

# Go
grep -n "import.*package-name" --type go

Find configuration:

# Config files
glob "**/*config*.{json,yaml,yml,toml,ini}"

# Environment variables
grep -n "process\\.env\\." --type js
grep -n "os\\.environ" --type py

# Constants
grep -n "^[A-Z_]+\\s*=" --type py
grep -n "const [A-Z_]+" --type js

Find TODO/FIXME:

grep -n "TODO|FIXME|HACK|XXX" -i

Find error handling:

# Python
grep -n "try:|except|raise" --type py

# JavaScript
grep -n "try|catch|throw" --type js

# Go
grep -n "if err != nil" --type go

Step 5: Advanced techniques

Trace data flow:

1. Find where data is created
   Semantic: "Where is user object created?"

2. Search for variable usage
   Grep: "user\\." with context lines

3. Follow transformations
   Read: Files that modify user

4. Find where it's consumed
   Grep: "user\\." in relevant files

Find all callsites of a function:

1. Find function definition
   Grep: "def process_payment"
   Result: payments/processor.py:45

2. Find all imports of that module
   Grep: "from payments.processor import"
   Result: Multiple files

3. Find all calls to the function
   Grep: "process_payment\\("
   Result: All callsites

4. Read each callsite for context
   Read: Each file with context

Understand a feature end-to-end:

1. Find API endpoint
   Semantic: "Where is user registration endpoint?"
   Result: routes/auth.py

2. Trace to controller
   Read: routes/auth.py
   Find: Calls to AuthController.register

3. Trace to service
   Read: controllers/auth.py
   Find: Calls to UserService.create_user

4. Trace to database
   Read: services/user.py
   Find: Database operations

5. Find tests
   Glob: "**/*auth*test*.py"
   Read: Test files for examples

Find related files:

1. Start with known file
   Example: models/user.py

2. Find imports of this file
   Grep: "from models.user import"

3. Find files this imports
   Read: models/user.py
   Note: Import statements

4. Build dependency graph
   Map: All related files

Impact analysis:

Before changing function X:

1. Find all callsites
   Grep: "function_name\\("

2. Find all tests
   Grep: "test.*function_name" -i

3. Check related functionality
   Semantic: "What depends on X?"

4. Review each usage
   Read: Each file using function

5. Plan changes
   Document: Impact and required updates

Step 6: Search optimization

Use appropriate context:

# See surrounding context
grep -n "pattern" -C 5  # 5 lines before and after
grep -n "pattern" -B 3  # 3 lines before
grep -n "pattern" -A 3  # 3 lines after

Case sensitivity:

# Case insensitive
grep -n "pattern" -i

# Case sensitive (default)
grep -n "Pattern"

File type filtering:

# Specific type
grep -n "pattern" --type py

# Multiple types
grep -n "pattern" --type py,js,ts

# Exclude types
grep -n "pattern" --glob "!*.test.js"

Regex patterns:

# Any character: .
grep -n "function.*Name"

# Start of line: ^
grep -n "^class"

# End of line: $
grep -n "TODO$"

# Optional: ?
grep -n "function_name_?()"

# One or more: +
grep -n "[A-Z_]+"

# Zero or more: *
grep -n "import.*"

# Alternatives: |
grep -n "TODO|FIXME"

# Groups: ()
grep -n "(get|set)_user"

# Escape special chars: \
grep -n "function\(\)"

Best practices

  1. Start with semantic search: For unfamiliar code or conceptual questions
  2. Use grep for precision: When you know exact terms
  3. Combine multiple searches: Build understanding incrementally
  4. Read surrounding context: Don't just look at matching lines
  5. Check file history: Use git blame for context
  6. Document findings: Note important discoveries
  7. Verify assumptions: Read actual code, don't assume
  8. Use directory targeting: Narrow scope when possible
  9. Follow the data: Trace data flow through the system
  10. Check tests: Tests often show usage examples

Common search scenarios

Scenario 1: Understanding a bug

1. Find error message
   Grep: "exact error message"

2. Find where it's thrown
   Read: File with error

3. Find what triggers it
   Semantic: "What causes X error?"

4. Find related code
   Grep: Related function names

5. Check tests
   Glob: "**/*test*.py"
   Look: For related test cases

Scenario 2: Learning a new codebase

1. Find entry point
   Semantic: "Where does the application start?"
   Common files: main.py, index.js, app.py

2. Find main routes/endpoints
   Grep: "route|endpoint|@app\\."

3. Find data models
   Semantic: "Where are data models defined?"
   Common: models/, entities/

4. Find configuration
   Glob: "**/*config*"

5. Read README and docs
   Read: README.md, docs/

Scenario 3: Refactoring preparation

1. Find all usages
   Grep: "function_to_change"

2. Find tests
   Grep: "test.*function_to_change"

3. Find dependencies
   Semantic: "What does X depend on?"

4. Check imports
   Grep: "from.*import.*X"

5. Document scope
   List: All affected files

Scenario 4: Adding a feature

1. Find similar features
   Semantic: "How is similar feature implemented?"

2. Find where to add code
   Semantic: "Where should new feature go?"

3. Check patterns
   Read: Similar implementations

4. Find tests to emulate
   Glob: Test files for similar features

5. Check documentation
   Grep: "TODO.*new feature" -i

Tools integration

Git integration:

# Who changed this line?
git blame filename

# History of a file
git log -p filename

# Find when function was added
git log -S "function_name" --source --all

# Find commits mentioning X
git log --grep="feature name"

IDE integration:

  • Use "Go to Definition" for quick navigation
  • Use "Find References" for usage
  • Use "Find in Files" for broad search
  • Use symbol search for classes/functions

Documentation:

  • Check inline comments
  • Look for docstrings
  • Read README files
  • Check architecture docs

Troubleshooting

No results found:

  • Check spelling and case sensitivity
  • Try semantic search instead of grep
  • Broaden search scope (remove directory target)
  • Try different search terms
  • Check if files are in .gitignore

Too many results:

  • Add directory targeting
  • Use more specific patterns
  • Filter by file type
  • Use exact phrases (quotes)

Wrong results:

  • Be more specific in query
  • Use grep instead of semantic for exact terms
  • Add context to semantic queries
  • Check file types

References

Examples

Example 1: Basic usage

<!-- Add example content here -->

Example 2: Advanced usage

<!-- Add advanced example content here -->