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

explain

複雑なコード、ファイル、または概念について、構造的な検索やMermaid図の生成を通じて専門的なエージェントが深く解説するためのSkill。

📜 元の英語説明(参考)

Deep explanation of complex code, files, or concepts. Routes to expert agents, uses structural search, generates mermaid diagrams. Triggers on: explain, deep dive, how does X work, architecture, data flow.

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

一言でいうと

複雑なコード、ファイル、または概念について、構造的な検索やMermaid図の生成を通じて専門的なエージェントが深く解説するためのSkill。

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

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

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

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

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

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

📖 Skill本文(日本語訳)

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

[スキル名] explain

Explain - 詳細なコード解説

コード、ファイル、ディレクトリ、またはアーキテクチャの概念について、包括的な解説を提供します。最も関連性の高いエキスパートエージェントに自動的にルーティングされ、最新のCLIツールを使用して分析を行います。

引数

$ARGUMENTS

  • <target> - ファイルパス、関数名、クラス名、ディレクトリ、または概念
  • --depth <shallow|normal|deep|trace> - 詳細レベル (デフォルト: normal)
  • --focus <arch|flow|deps|api|perf> - 特定の焦点領域

アーキテクチャ

/explain <target> [--depth] [--focus]
    |
    +-> Step 1: Detect & Classify Target (ターゲットの検出と分類)
    |     +- File exists? -> Read it (ファイルが存在するか? -> 読み込む)
    |     +- Function/class? -> ast-grep to find definition (関数/クラスか? -> ast-grepで定義を見つける)
    |     +- Directory? -> tokei for overview (ディレクトリか? -> tokeiで概要を把握する)
    |     +- Concept? -> rg search codebase (概念か? -> rgでコードベースを検索する)
    |
    +-> Step 2: Gather Context (parallel) (コンテキストの収集 (並行))
    |     +- structural-search skill -> find usages (structural-searchスキル -> 使用箇所を見つける)
    |     +- code-stats skill -> assess scope (code-statsスキル -> スコープを評価する)
    |     +- Find related: tests, types, docs (関連するものを見つける: テスト、型、ドキュメント)
    |     +- Load: AGENTS.md, CLAUDE.md conventions (読み込む: AGENTS.md, CLAUDE.mdの規約)
    |
    +-> Step 3: Route to Expert Agent (エキスパートエージェントへのルーティング)
    |     +- .ts/.tsx -> typescript-expert or react-expert
    |     +- .py -> python-expert
    |     +- .vue -> vue-expert
    |     +- .sql/migrations -> postgres-expert
    |     +- agents/skills/commands -> claude-architect
    |     +- Default -> general-purpose (デフォルト -> 汎用)
    |
    +-> Step 4: Generate Explanation (解説の生成)
    |     +- Structured markdown with sections (セクション分けされた構造化Markdown)
    |     +- Mermaid diagrams (flowchart/sequence/class) (Mermaid図 (フローチャート/シーケンス/クラス))
    |     +- Related code paths as file:line refs (関連するコードパスをfile:line参照として)
    |     +- Design decisions and rationale (設計上の決定と根拠)
    |
    +-> Step 5: Integrate (統合)
          +- Offer to save to ARCHITECTURE.md (if significant) (ARCHITECTURE.mdへの保存を提案 (重要であれば))
          +- Link to /save if working on related task (関連タスクに取り組んでいる場合は/saveへのリンク)

実行ステップ

ステップ1: ターゲットタイプの検出

# Check if target is a file
test -f "$TARGET" && echo "FILE" && exit

# Check if target is a directory
test -d "$TARGET" && echo "DIRECTORY" && exit

# Otherwise, search for it as a symbol

ファイルの場合: bat (シンタックスハイライト付き) または Read ツールで直接読み込みます。

ディレクトリの場合: tokei (利用可能な場合) で概要を取得します。

command -v tokei >/dev/null 2>&1 && tokei "$TARGET" --compact || echo "tokei unavailable"

シンボル (関数/クラス) の場合: ast-grep で定義を見つけます。

# Try ast-grep first (structural)
command -v ast-grep >/dev/null 2>&1 && ast-grep -p "function $TARGET" -p "class $TARGET" -p "def $TARGET"

# Fallback to ripgrep
rg "(?:function|class|def|const|let|var)\s+$TARGET" --type-add 'code:*.{ts,tsx,js,jsx,py,vue}' -t code

ステップ2: コンテキストの収集

可能な限りこれらを並行して実行します。

使用箇所の検索 (structural-search スキル):

# With ast-grep
ast-grep -p "$TARGET($_)" --json 2>/dev/null | head -20

# Fallback
rg "$TARGET" --type-add 'code:*.{ts,tsx,js,jsx,py,vue}' -t code -l

関連ファイルの検索:

# Tests
fd -e test.ts -e spec.ts -e test.py -e spec.py | xargs rg -l "$TARGET" 2>/dev/null

# Types/interfaces
fd -e d.ts -e types.ts | xargs rg -l "$TARGET" 2>/dev/null

プロジェクト規約の読み込み:

  • AGENTS.md が存在すれば読み込みます
  • CLAUDE.md が存在すれば読み込みます
  • フレームワーク固有のパターンを確認します

ステップ3: エキスパートエージェントへのルーティング

ファイル拡張子と内容に基づいて最適なエキスパートを決定します。

パターン プライマリエージェント 条件
.ts typescript-expert JSX/Reactのインポートなし
.tsx react-expert JSXが存在する
.js, .jsx javascript-expert -
.py python-expert -
.vue vue-expert -
.sql, migrations/* postgres-expert -
agents/*.md, skills/*, commands/* claude-architect Claude拡張機能
*.test.*, *.spec.* (フレームワークエキスパート) ファイルタイプでルーティング
その他 general-purpose フォールバック

Task ツールを介した呼び出し:

Task tool with subagent_type: "[detected]-expert"
Prompt includes:
  - File content
  - Related files found
  - Project conventions
  - Requested depth and focus

ステップ4: 解説の生成

エキスパートエージェントは構造化された解説を生成します。

# Explanation: [target]

## Overview
[1-2 sentence summary of purpose and role in the system]

## Architecture

[Mermaid diagram - choose appropriate type]

### Flowchart (for control flow)
` ` `mermaid
flowchart TD
    A[Input] --> B{Validate}
    B -->|Valid| C[Process]
    B -->|Invalid| D[Error]
    C --> E[Output]
` ` `

### Sequence (for interactions)
` ` `mermaid
sequenceDiagram
    participant Client
    participant Server
    participant Database
    Client->>Server: Request
    Server->>Database: Query
    Database-->>Server: Result
    Server-->>Client: Response
` ` `

### Class (for structures)
` ` `mermaid
classDiagram
    class Component {
        +props: Props
        +state: State
        +render(): JSX
    }
` ` `

## How It Works

### Step 1: [Phase Name]
[Explanation with code references]

See: `src/module.ts:42`

### Step 2: [Phase Name]
[Explanation]

## Key Concepts

### [Concept 1]
[Explanation]

### [Concept 2]
[Explanation]

## Dependencies

| Import | Purpose |
|--------|---------|
| `package` | [why it's used] |

## Design Decisions

### Why [decision]?
[Rationale and tradeoffs considered]

## Related Code

| File | Relationship |
|------|--------------|
| `path/to/file.ts:123` | [how it relates] |

## See Also

- `/explain path/to/related` - [description]
- [External docs link] - [description]

詳細モード

モード 出力
--shallow 概要段落、主要なエクスポート、図なし
--normal 1つの図と主要な概念を含む完全な解説 (デフォルト)
--deep 網羅的: すべての内部、エッジケース、履歴、複数の図
--trace システム全体を通じたデータフローの追跡、シーケンス図

Shallow の例

/explain src/auth/token.ts --shallow

出力: 単一の段落 + エクスポートリスト。

Deep の例

/explain src/core/engine.ts --deep

出力: 完全な内部、アルゴリズム分析、パフォーマンスに関する注意点、エッジケース。

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

Explain - Deep Code Explanation

Get a comprehensive explanation of code, files, directories, or architectural concepts. Automatically routes to the most relevant expert agent and uses modern CLI tools for analysis.

Arguments

$ARGUMENTS

  • <target> - File path, function name, class name, directory, or concept
  • --depth <shallow|normal|deep|trace> - Level of detail (default: normal)
  • --focus <arch|flow|deps|api|perf> - Specific focus area

Architecture

/explain <target> [--depth] [--focus]
    |
    +-> Step 1: Detect & Classify Target
    |     +- File exists? -> Read it
    |     +- Function/class? -> ast-grep to find definition
    |     +- Directory? -> tokei for overview
    |     +- Concept? -> rg search codebase
    |
    +-> Step 2: Gather Context (parallel)
    |     +- structural-search skill -> find usages
    |     +- code-stats skill -> assess scope
    |     +- Find related: tests, types, docs
    |     +- Load: AGENTS.md, CLAUDE.md conventions
    |
    +-> Step 3: Route to Expert Agent
    |     +- .ts/.tsx -> typescript-expert or react-expert
    |     +- .py -> python-expert
    |     +- .vue -> vue-expert
    |     +- .sql/migrations -> postgres-expert
    |     +- agents/skills/commands -> claude-architect
    |     +- Default -> general-purpose
    |
    +-> Step 4: Generate Explanation
    |     +- Structured markdown with sections
    |     +- Mermaid diagrams (flowchart/sequence/class)
    |     +- Related code paths as file:line refs
    |     +- Design decisions and rationale
    |
    +-> Step 5: Integrate
          +- Offer to save to ARCHITECTURE.md (if significant)
          +- Link to /save if working on related task

Execution Steps

Step 1: Detect Target Type

# Check if target is a file
test -f "$TARGET" && echo "FILE" && exit

# Check if target is a directory
test -d "$TARGET" && echo "DIRECTORY" && exit

# Otherwise, search for it as a symbol

For files: Read directly with bat (syntax highlighted) or Read tool.

For directories: Get overview with tokei (if available):

command -v tokei >/dev/null 2>&1 && tokei "$TARGET" --compact || echo "tokei unavailable"

For symbols (function/class): Find definition with ast-grep:

# Try ast-grep first (structural)
command -v ast-grep >/dev/null 2>&1 && ast-grep -p "function $TARGET" -p "class $TARGET" -p "def $TARGET"

# Fallback to ripgrep
rg "(?:function|class|def|const|let|var)\s+$TARGET" --type-add 'code:*.{ts,tsx,js,jsx,py,vue}' -t code

Step 2: Gather Context

Run these in parallel where possible:

Find usages (structural-search skill):

# With ast-grep
ast-grep -p "$TARGET($_)" --json 2>/dev/null | head -20

# Fallback
rg "$TARGET" --type-add 'code:*.{ts,tsx,js,jsx,py,vue}' -t code -l

Find related files:

# Tests
fd -e test.ts -e spec.ts -e test.py -e spec.py | xargs rg -l "$TARGET" 2>/dev/null

# Types/interfaces
fd -e d.ts -e types.ts | xargs rg -l "$TARGET" 2>/dev/null

Load project conventions:

  • Read AGENTS.md if exists
  • Read CLAUDE.md if exists
  • Check for framework-specific patterns

Step 3: Route to Expert Agent

Determine the best expert based on file extension and content:

Pattern Primary Agent Condition
.ts typescript-expert No JSX/React imports
.tsx react-expert JSX present
.js, .jsx javascript-expert -
.py python-expert -
.vue vue-expert -
.sql, migrations/* postgres-expert -
agents/*.md, skills/*, commands/* claude-architect Claude extensions
*.test.*, *.spec.* (framework expert) Route by file type
Other general-purpose Fallback

Invoke via Task tool:

Task tool with subagent_type: "[detected]-expert"
Prompt includes:
  - File content
  - Related files found
  - Project conventions
  - Requested depth and focus

Step 4: Generate Explanation

The expert agent produces a structured explanation:

# Explanation: [target]

## Overview
[1-2 sentence summary of purpose and role in the system]

## Architecture

[Mermaid diagram - choose appropriate type]

### Flowchart (for control flow)
` ` `mermaid
flowchart TD
    A[Input] --> B{Validate}
    B -->|Valid| C[Process]
    B -->|Invalid| D[Error]
    C --> E[Output]
` ` `

### Sequence (for interactions)
` ` `mermaid
sequenceDiagram
    participant Client
    participant Server
    participant Database
    Client->>Server: Request
    Server->>Database: Query
    Database-->>Server: Result
    Server-->>Client: Response
` ` `

### Class (for structures)
` ` `mermaid
classDiagram
    class Component {
        +props: Props
        +state: State
        +render(): JSX
    }
` ` `

## How It Works

### Step 1: [Phase Name]
[Explanation with code references]

See: `src/module.ts:42`

### Step 2: [Phase Name]
[Explanation]

## Key Concepts

### [Concept 1]
[Explanation]

### [Concept 2]
[Explanation]

## Dependencies

| Import | Purpose |
|--------|---------|
| `package` | [why it's used] |

## Design Decisions

### Why [decision]?
[Rationale and tradeoffs considered]

## Related Code

| File | Relationship |
|------|--------------|
| `path/to/file.ts:123` | [how it relates] |

## See Also

- `/explain path/to/related` - [description]
- [External docs link] - [description]

Depth Modes

Mode Output
--shallow Overview paragraph, key exports, no diagram
--normal Full explanation with 1 diagram, main concepts (default)
--deep Exhaustive: all internals, edge cases, history, multiple diagrams
--trace Data flow tracing through entire system, sequence diagrams

Shallow Example

/explain src/auth/token.ts --shallow

Output: Single paragraph + exports list.

Deep Example

/explain src/core/engine.ts --deep

Output: Full internals, algorithm analysis, performance notes, edge cases.

Trace Example

/explain handleLogin --trace

Output: Traces data flow from entry to database to response.

Focus Modes

Mode What It Analyzes
--focus arch Module boundaries, layer separation, dependencies
--focus flow Data flow, control flow, state changes
--focus deps Imports, external dependencies, integrations
--focus api Public interface, inputs/outputs, contracts
--focus perf Complexity, bottlenecks, optimization opportunities

CLI Tool Integration

Commands use modern CLI tools with graceful fallbacks:

Tool Purpose Fallback
tokei Code statistics Skip stats
ast-grep Structural search rg with patterns
bat Syntax highlighting Read tool
rg Content search Grep tool
fd File finding Glob tool

Check availability:

command -v tokei >/dev/null 2>&1 || echo "tokei not installed - skipping stats"

Usage Examples

# Explain a file
/explain src/auth/oauth.ts

# Explain a function (finds it automatically)
/explain validateToken

# Explain a directory
/explain src/services/

# Deep dive with architecture focus
/explain src/core/engine.ts --deep --focus arch

# Trace data flow
/explain handleUserLogin --trace

# Quick overview
/explain src/utils/helpers.ts --shallow

# Focus on dependencies
/explain package.json --focus deps

Integration

Skill/Command Relationship
/review Review after understanding
/testgen Generate tests for explained code
/save Save progress if working on related task

Persistence

After significant explanations, you may be offered:

Would you like to save this explanation?
  1. Append to ARCHITECTURE.md
  2. Append to AGENTS.md (if conventions-related)
  3. Don't save (output only)

This keeps valuable architectural knowledge in git-tracked documentation.

Notes

  • Explanations are based on code analysis, not documentation
  • Complex systems may need multiple /explain calls
  • Use --deep for unfamiliar codebases
  • Mermaid diagrams render in GitHub, GitLab, VSCode, and most markdown viewers
  • Expert agents provide framework-specific insights