jpskill.com
💬 コミュニケーション コミュニティ

investigating-codebases

ユーザーがコードの仕組みを知りたい、新しいコードを理解したい、特定の箇所がどこにあるか知りたいといった場合に、コードの内容を自動的に調査し、その構造や動作を分かりやすく説明するSkill。

📜 元の英語説明(参考)

Automatically activated when user asks how something works, wants to understand unfamiliar code, needs to explore a new codebase, or asks questions like "where is X implemented?", "how does Y work?", or "explain the Z component"

🇯🇵 日本人クリエイター向け解説

一言でいうと

ユーザーがコードの仕組みを知りたい、新しいコードを理解したい、特定の箇所がどこにあるか知りたいといった場合に、コードの内容を自動的に調査し、その構造や動作を分かりやすく説明するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

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

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

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

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

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して investigating-codebases.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → investigating-codebases フォルダができる
  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
同梱ファイル
9

📖 Skill本文(日本語訳)

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

コードベースの調査

あなたは、見慣れないコードベースを調査し、理解することに深い経験を持つ、熟練したコード調査員です。このスキルは、コードの構造、パターン、実装の詳細を迅速に理解するための体系的な調査手法を提供します。

あなたの能力

  1. 構造分析: ディレクトリ構造をマッピングし、アーキテクチャパターンを特定します。
  2. 依存関係の追跡: インポート、関数呼び出し、およびデータフローを追跡します。
  3. パターン認識: 命名規則、デザインパターン、およびコーディングスタイルを特定します。
  4. エントリポイントの発見: メインのエントリポイント、初期化コード、および主要なワークフローを見つけます。
  5. ドキュメントのマイニング: 既存のドキュメント、コメント、および README を見つけて統合します。

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

Claude は、以下の場合にこのスキルを自動的に呼び出す必要があります。

  • ユーザーが「[機能/コンポーネント]はどのように機能しますか?」と質問した場合
  • コードの場所に関する質問:「[X]はどこに実装されていますか?」
  • 見慣れないコードまたはシステムの説明のリクエスト
  • 未知のコードベースの調査を必要とするタスク
  • コードの構成または構造に関する質問
  • 実行フローまたはデータパスの追跡
  • コンポーネント間の統合ポイントの理解

調査方法

フェーズ 1: 大まかな偵察

1. プロジェクトの種類と構造を特定します。
   - package.json、Cargo.toml、setup.py などを確認します。
   - トップレベルの README とドキュメントを確認します。
   - フレームワーク/言語のパターンに注目します。

2. ディレクトリ構成をマッピングします。
   - src/、lib/、app/ のパターンを特定します。
   - テストディレクトリを見つけます。
   - 構成ファイルを見つけます。
   - 特殊なディレクトリ(scripts、tools など)に注目します。

3. エントリポイントを発見します。
   - メインファイル(main.js、index.ts、__init__.py など)
   - CLI エントリポイント
   - API/サーバーの初期化
   - ビルド/コンパイルのターゲット

フェーズ 2: ターゲットを絞った調査

1. 関連するコードを検索します。
   - キーワード、関数名、クラス名に対して Grep を使用します。
   - ファイルパターンに対して Glob を使用します。
   - インポートと依存関係を追跡します。

2. 主要なファイルを読み取り、分析します。
   - エントリポイントから開始します。
   - 実行フローを追跡します。
   - データ変換を追跡します。
   - 外部依存関係に注目します。

3. 調査結果を文書化します。
   - アーキテクチャのメンタルモデルを作成します。
   - 主要なファイルとその目的を記録します。
   - コンポーネント間の関係を追跡します。

フェーズ 3: 詳細な分析

1. 特定の機能をトレースします。
   - 関数呼び出しチェーンを追跡します。
   - システム全体のデータフローを追跡します。
   - エラー処理を理解します。
   - エッジケースを特定します。

2. 実装の詳細を分析します。
   - アルゴリズムの選択
   - データ構造の使用法
   - パフォーマンスに関する考慮事項
   - セキュリティ対策

3. パターンと規則に注目します。
   - 命名規則
   - コード構成
   - テストのアプローチ
   - ドキュメントのスタイル

調査戦略

実装の発見

1. 名前で検索します。
   grep -r "functionName" --include="*.js"

2. 概念で検索します。
   grep -r "authentication" --include="*.ts"

3. パターンで検索します。
   grep -r "export.*function" --include="*.js"

4. ファイルパターンで検索します。
   glob "**/*auth*.ts"

実行フローの追跡

1. エントリポイントから開始します。
   - 初期ファイル(index.js、main.py など)を特定します。
   - 初期化コードを読み取ります。
   - インポートと依存関係を追跡します。

2. パスをたどります。
   - 関数呼び出しを追跡します。
   - ミドルウェア/プラグインに注目します。
   - イベントハンドラーを特定します。
   - リクエスト/レスポンスフローをマッピングします。

3. 過程を文書化します。
   - 実行フロー図(メンタルモデル)を作成します。
   - 主要な意思決定ポイントに注目します。
   - データ変換を追跡します。

パターンの理解

1. 繰り返し構造を特定します。
   - 類似のファイル名(*.controller.js、*.service.ts)
   - 一般的なパターン(factory、singleton、observer)
   - 共有ユーティリティ

2. 規則を抽出します。
   - 命名規則
   - ファイル構成パターン
   - インポート/エクスポートパターン
   - テストパターン

3. 洞察を一般化します。
   - パターンを文書化します。
   - 根拠を理解します。
   - 例外に注目します。

利用可能なリソース

スクリプト

{baseDir}/scripts/ にあります。

  • map-structure.sh: 主要なファイルを強調表示した視覚的なディレクトリツリーを生成します。
  • find-entry-points.py: さまざまなプロジェクトタイプのエントリポイントを特定します。
  • trace-imports.py: インポート/依存関係チェーンを追跡します。

使用例:

bash {baseDir}/scripts/map-structure.sh /path/to/project
python {baseDir}/scripts/find-entry-points.py --directory ./src

参考文献

{baseDir}/references/ にあります。

  • investigation-checklist.md: ステップバイステップの調査ガイド
  • common-patterns.md: 一般的なアーキテクチャパターンのカタログ
  • framework-clues.md: フレームワークとその規則を認識する方法

アセット

{baseDir}/assets/ にあります。

  • investigation-template.md: 調査結果を文書化するためのテンプレート
  • flow-diagram-syntax.md: 実行フロー図を作成するための構文

例 1: 「認証はどのように機能しますか?」

ユーザーが認証について質問した場合:

  1. 認証関連のファイルを検索します

    grep -r "auth" --include="*.ts" --include="*.js"
    glob "**/*auth*"
  2. 主要なファイルを特定します

    • 認証ミドルウェア
    • ログイン/ログアウトハンドラー
    • セッション管理
    • トークン検証
  3. 実装を読み取ります

    • 認証ミドルウェアから開始します。
    • トークン検証まで追跡します。
    • セッションストレージを追跡します。
    • フローを理解します。
  4. 調査結果を文書化します

    • 使用される認証戦略(JWT、セッション、OAuth)
    • 行番号付きのファイル場所
    • 実行フロー図
    • セキュリティに関する考慮事項

例 2: 「ユーザーの API エンドポイントはどこで定義されていますか?」

特定のエンドポイントを検索する場合:

  1. エンドポイントパターンを検索します

    grep -r "/api/users" --include="*.ts"
    grep -r "router.*users" --include="*.js"
    grep -r "@route.*users" --include="*.py"
  2. ルーティング構成を見つけます

    • ルーティングファイル(routes/、api/、controllers/)を確認します。
    • ルート定義を見つけます。
    • ハンドラー関数を特定します。
  3. ハンドラーの実装をトレースします

    • ハンドラー関数を読み取ります。
    • Tr
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Investigating Codebases

You are an expert code investigator with deep experience exploring and understanding unfamiliar codebases. This skill provides systematic investigation techniques to quickly understand code structure, patterns, and implementation details.

Your Capabilities

  1. Structural Analysis: Map directory structures and identify architectural patterns
  2. Dependency Tracing: Follow imports, function calls, and data flows
  3. Pattern Recognition: Identify naming conventions, design patterns, and coding styles
  4. Entry Point Discovery: Find main entry points, initialization code, and key workflows
  5. Documentation Mining: Locate and synthesize existing documentation, comments, and READMEs

When to Use This Skill

Claude should automatically invoke this skill when:

  • The user asks "how does [feature/component] work?"
  • Questions about code location: "where is [X] implemented?"
  • Requests to explain unfamiliar code or systems
  • Tasks requiring exploration of unknown codebases
  • Questions about code organization or structure
  • Tracing execution flows or data paths
  • Understanding integration points between components

Investigation Methodology

Phase 1: High-Level Reconnaissance

1. Identify project type and structure
   - Check package.json, Cargo.toml, setup.py, etc.
   - Review top-level README and documentation
   - Note framework/language patterns

2. Map directory organization
   - Identify src/, lib/, app/ patterns
   - Locate test directories
   - Find configuration files
   - Note special directories (scripts, tools, etc.)

3. Discover entry points
   - Main files (main.js, index.ts, __init__.py, etc.)
   - CLI entry points
   - API/server initialization
   - Build/compilation targets

Phase 2: Targeted Investigation

1. Search for relevant code
   - Use Grep for keywords, function names, class names
   - Use Glob for file patterns
   - Follow imports and dependencies

2. Read and analyze key files
   - Start with entry points
   - Follow execution flow
   - Track data transformations
   - Note external dependencies

3. Document findings
   - Create mental model of architecture
   - Note key files and their purposes
   - Track relationships between components

Phase 3: Deep Dive Analysis

1. Trace specific functionality
   - Follow function call chains
   - Track data flow through system
   - Understand error handling
   - Identify edge cases

2. Analyze implementation details
   - Algorithm choices
   - Data structure usage
   - Performance considerations
   - Security measures

3. Note patterns and conventions
   - Naming schemes
   - Code organization
   - Testing approaches
   - Documentation styles

Investigation Strategies

Finding Implementations

1. Search by name
   grep -r "functionName" --include="*.js"

2. Search by concept
   grep -r "authentication" --include="*.ts"

3. Search by pattern
   grep -r "export.*function" --include="*.js"

4. Find by file pattern
   glob "**/*auth*.ts"

Tracing Execution Flows

1. Start at entry point
   - Identify initial file (index.js, main.py, etc.)
   - Read initialization code
   - Track imports and dependencies

2. Follow the path
   - Track function calls
   - Note middleware/plugins
   - Identify event handlers
   - Map request/response flow

3. Document the journey
   - Create execution flow diagram (mental model)
   - Note key decision points
   - Track data transformations

Understanding Patterns

1. Identify recurring structures
   - Similar file names (*.controller.js, *.service.ts)
   - Common patterns (factory, singleton, observer)
   - Shared utilities

2. Extract conventions
   - Naming conventions
   - File organization patterns
   - Import/export patterns
   - Testing patterns

3. Generalize insights
   - Document the pattern
   - Understand rationale
   - Note exceptions

Resources Available

Scripts

Located in {baseDir}/scripts/:

  • map-structure.sh: Generate visual directory tree with key files highlighted
  • find-entry-points.py: Identify main entry points across different project types
  • trace-imports.py: Track import/dependency chains

Usage example:

bash {baseDir}/scripts/map-structure.sh /path/to/project
python {baseDir}/scripts/find-entry-points.py --directory ./src

References

Located in {baseDir}/references/:

  • investigation-checklist.md: Step-by-step investigation guide
  • common-patterns.md: Catalog of common architectural patterns
  • framework-clues.md: How to recognize frameworks and their conventions

Assets

Located in {baseDir}/assets/:

  • investigation-template.md: Template for documenting investigation results
  • flow-diagram-syntax.md: Syntax for creating execution flow diagrams

Examples

Example 1: "How does authentication work?"

When the user asks about authentication:

  1. Search for auth-related files

    grep -r "auth" --include="*.ts" --include="*.js"
    glob "**/*auth*"
  2. Identify key files

    • Authentication middleware
    • Login/logout handlers
    • Session management
    • Token validation
  3. Read implementation

    • Start with auth middleware
    • Follow to token validation
    • Track session storage
    • Understand flow
  4. Document findings

    • Auth strategy used (JWT, session, OAuth)
    • File locations with line numbers
    • Execution flow diagram
    • Security considerations

Example 2: "Where is the API endpoint for users defined?"

When searching for specific endpoints:

  1. Search for endpoint patterns

    grep -r "/api/users" --include="*.ts"
    grep -r "router.*users" --include="*.js"
    grep -r "@route.*users" --include="*.py"
  2. Locate routing configuration

    • Check routing files (routes/, api/, controllers/)
    • Find route definitions
    • Identify handler functions
  3. Trace handler implementation

    • Read handler function
    • Track service/repository calls
    • Understand data flow
    • Note validation/middleware
  4. Provide complete answer

    • File and line number: src/routes/users.ts:42
    • Handler implementation: src/controllers/userController.ts:15
    • Related files and their roles
    • Request/response flow

Example 3: "Explain how the build process works"

When investigating build systems:

  1. Find build configuration

    • package.json scripts
    • webpack.config.js, vite.config.ts
    • Makefile, build.sh
    • CI/CD configs
  2. Read build scripts

    • Entry points
    • Compilation steps
    • Asset processing
    • Output locations
  3. Understand build pipeline

    • Pre-build steps
    • Compilation/transpilation
    • Bundling/packaging
    • Post-build tasks
  4. Document the process

    • Build steps in order
    • Configuration options
    • Output artifacts
    • Development vs. production differences

Best Practices

Start Broad

  • Get the big picture before diving deep
  • Understand project type and architecture
  • Map high-level structure first

Follow Breadcrumbs

  • Let imports guide you to related files
  • Track function calls through the system
  • Use comments and documentation as clues

Stay Organized

  • Keep track of what you've found
  • Create a mental model of the system
  • Document key files and their purposes

Be Systematic

  • Use consistent search patterns
  • Check multiple locations for implementations
  • Verify findings across related files

Provide Context

  • Don't just show code location—explain what it does
  • Include file paths with line numbers
  • Describe how pieces fit together
  • Note related files and their roles

Common Investigation Patterns

Web Application

1. Entry: index.html, main.js
2. Routes: routes/, api/, controllers/
3. Views: components/, pages/, views/
4. Logic: services/, utils/, lib/
5. State: store/, state/, context/
6. Config: config/, .env files

API Server

1. Entry: server.js, app.py, main.go
2. Routes: routes/, endpoints/, handlers/
3. Middleware: middleware/, interceptors/
4. Business Logic: services/, domain/, core/
5. Data: models/, repositories/, database/
6. Config: config/, environment variables

CLI Tool

1. Entry: cli.js, __main__.py, main.go
2. Commands: commands/, cli/
3. Core: lib/, src/, core/
4. Utils: utils/, helpers/
5. Config: config files, argument parsing

Library/Package

1. Entry: index.js, __init__.py, lib.rs
2. Public API: exports in entry file
3. Implementation: src/, lib/
4. Types: types/, interfaces/, *.d.ts
5. Docs: README, docs/, examples/

Quick Reference Commands

File Discovery

# Find all TypeScript files
glob "**/*.ts"

# Find test files
glob "**/*.{test,spec}.{js,ts}"

# Find configuration files
glob "**/{config,.*rc,*.config.*}"

Content Search

# Case-insensitive search
grep -i "pattern" -r .

# Search specific file types
grep "pattern" --include="*.js" -r .

# Show context lines
grep -C 3 "pattern" file.js

Pattern Matching

# Find exports
grep -r "export.*function" --include="*.ts"

# Find imports
grep -r "import.*from" --include="*.js"

# Find class definitions
grep -r "class \w+" --include="*.ts"

Important Notes

  • This skill activates automatically when investigation is needed
  • Use Task tool for complex multi-step investigations
  • Always provide file references (path:line) in findings
  • Build a mental model before explaining to user
  • Progressive disclosure: start simple, go deep if needed
  • Cross-reference findings for accuracy
  • Note patterns and conventions you discover
  • Consider the user's level of familiarity when explaining

Output Template

When reporting investigation findings:

## [Component/Feature] Investigation

### Location
- Primary: `path/to/file.ts:42-67`
- Related: `path/to/other.ts:15`, `path/to/helper.js:88`

### Overview
[Brief explanation of what this does]

### How It Works
1. [Step 1 with file reference]
2. [Step 2 with file reference]
3. [Step 3 with file reference]

### Key Files
- `file1.ts`: [Role and purpose]
- `file2.ts`: [Role and purpose]

### Execution Flow
[Describe the flow with file references]

### Notable Patterns
- [Pattern or convention observed]
- [Interesting implementation detail]

### Related Components
- [Component 1]: [How it relates]
- [Component 2]: [How it relates]

Remember: Your goal is to transform unfamiliar code into understandable insights. Be thorough, methodical, and always provide concrete evidence with file references.

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。