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

rust-call-graph

RustのLSP機能を利用して、`/call-graph`などのコマンドや呼び出し階層から、Rustの関数呼び出し関係を図でわかりやすく表示するSkill。

📜 元の英語説明(参考)

Visualize Rust function call graphs using LSP. Triggers on: /call-graph, call hierarchy, who calls, what calls, 调用图, 调用关系, 谁调用了, 调用了谁

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

一言でいうと

RustのLSP機能を利用して、`/call-graph`などのコマンドや呼び出し階層から、Rustの関数呼び出し関係を図でわかりやすく表示するSkill。

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

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

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

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

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

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して rust-call-graph.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → rust-call-graph フォルダができる
  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 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Rust Call Graph

LSP のコール階層を使用して、関数呼び出しの関係を可視化します。

使い方

/rust-call-graph <function_name> [--depth N] [--direction in|out|both]

オプション:

  • --depth N: 探索するレベル数 (デフォルト: 3)
  • --direction: in (呼び出し元), out (呼び出し先), both

例:

  • /rust-call-graph process_request - 呼び出し元と呼び出し先の両方を表示
  • /rust-call-graph handle_error --direction in - 呼び出し元のみを表示
  • /rust-call-graph main --direction out --depth 5 - 深い呼び出し先分析

LSP 操作

1. コール階層の準備

関数のコール階層アイテムを取得します。

LSP(
  operation: "prepareCallHierarchy",
  filePath: "src/handler.rs",
  line: 45,
  character: 8
)

2. 呼び出し元 (誰がこれを呼び出しているか?)

LSP(
  operation: "incomingCalls",
  filePath: "src/handler.rs",
  line: 45,
  character: 8
)

3. 呼び出し先 (これは何を呼び出しているか?)

LSP(
  operation: "outgoingCalls",
  filePath: "src/handler.rs",
  line: 45,
  character: 8
)

ワークフロー

User: "Show call graph for process_request"
    │
    ▼
[1] 関数の場所を特定
    LSP(workspaceSymbol) または Grep
    │
    ▼
[2] コール階層を準備
    LSP(prepareCallHierarchy)
    │
    ▼
[3] 呼び出し元を取得
    LSP(incomingCalls)
    │
    ▼
[4] 呼び出し先を取得
    LSP(outgoingCalls)
    │
    ▼
[5] 深さ N まで再帰的に展開
    │
    ▼
[6] ASCII 可視化を生成

出力形式

呼び出し元 (誰がこれを呼び出しているか?)

## `process_request` の呼び出し元

main
└── run_server
    └── handle_connection
        └── process_request  ◄── YOU ARE HERE

呼び出し先 (これは何を呼び出しているか?)

## `process_request` の呼び出し先

process_request  ◄── YOU ARE HERE
├── parse_headers
│   └── validate_header
├── authenticate
│   ├── check_token
│   └── load_user
├── execute_handler
│   └── [dynamic dispatch]
└── send_response
    └── serialize_body

双方向 (両方)

## `process_request` のコールグラフ

                    ┌─────────────────┐
                    │      main       │
                    └────────┬────────┘
                             │
                    ┌────────▼────────┐
                    │   run_server    │
                    └────────┬────────┘
                             │
                    ┌────────▼────────┐
                    │handle_connection│
                    └────────┬────────┘
                             │
        ┌────────────────────┼────────────────────┐
        │                    │                    │
┌───────▼───────┐   ┌───────▼───────┐   ┌───────▼───────┐
│ parse_headers │   │ authenticate  │   │send_response  │
└───────────────┘   └───────┬───────┘   └───────────────┘
                            │
                    ┌───────┴───────┐
                    │               │
             ┌──────▼──────┐ ┌──────▼──────┐
             │ check_token │ │  load_user  │
             └─────────────┘ └─────────────┘

分析の洞察

コールグラフを生成した後、洞察を提供します。

## 分析

**エントリポイント:** main, test_process_request
**リーフ関数:** validate_header, serialize_body
**ホットパス:** main → run_server → handle_connection → process_request
**複雑さ:** 12 関数, 深さ 3 レベル

**潜在的な問題:**
- `authenticate` は高いファンアウト (4 つの呼び出し先) を持っています
- `process_request` は 3 つの場所から呼び出されています (これが意図的なものかどうか検討してください)

一般的なパターン

User Says Direction Use Case
"Who calls X?" incoming 影響分析
"What does X call?" outgoing 実装の理解
"Show call graph" both 全体像
"Trace from main to X" outgoing 実行パス

可視化オプション

Style Best For
Tree (default) 単純な階層
Box diagram 複雑な関係
Flat list 多数の接続
Mermaid ドキュメントへのエクスポート

Mermaid エクスポート

graph TD
    main --> run_server
    run_server --> handle_connection
    handle_connection --> process_request
    process_request --> parse_headers
    process_request --> authenticate
    process_request --> send_response

関連スキル

When See
定義を見つける rust-code-navigator
プロジェクト構造 rust-symbol-analyzer
トレイトの実装 rust-trait-explorer
安全なリファクタリング rust-refactor-helper
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Rust Call Graph

Visualize function call relationships using LSP call hierarchy.

Usage

/rust-call-graph <function_name> [--depth N] [--direction in|out|both]

Options:

  • --depth N: How many levels to traverse (default: 3)
  • --direction: in (callers), out (callees), both

Examples:

  • /rust-call-graph process_request - Show both callers and callees
  • /rust-call-graph handle_error --direction in - Show only callers
  • /rust-call-graph main --direction out --depth 5 - Deep callee analysis

LSP Operations

1. Prepare Call Hierarchy

Get the call hierarchy item for a function.

LSP(
  operation: "prepareCallHierarchy",
  filePath: "src/handler.rs",
  line: 45,
  character: 8
)

2. Incoming Calls (Who calls this?)

LSP(
  operation: "incomingCalls",
  filePath: "src/handler.rs",
  line: 45,
  character: 8
)

3. Outgoing Calls (What does this call?)

LSP(
  operation: "outgoingCalls",
  filePath: "src/handler.rs",
  line: 45,
  character: 8
)

Workflow

User: "Show call graph for process_request"
    │
    ▼
[1] Find function location
    LSP(workspaceSymbol) or Grep
    │
    ▼
[2] Prepare call hierarchy
    LSP(prepareCallHierarchy)
    │
    ▼
[3] Get incoming calls (callers)
    LSP(incomingCalls)
    │
    ▼
[4] Get outgoing calls (callees)
    LSP(outgoingCalls)
    │
    ▼
[5] Recursively expand to depth N
    │
    ▼
[6] Generate ASCII visualization

Output Format

Incoming Calls (Who calls this?)

## Callers of `process_request`

main
└── run_server
    └── handle_connection
        └── process_request  ◄── YOU ARE HERE

Outgoing Calls (What does this call?)

## Callees of `process_request`

process_request  ◄── YOU ARE HERE
├── parse_headers
│   └── validate_header
├── authenticate
│   ├── check_token
│   └── load_user
├── execute_handler
│   └── [dynamic dispatch]
└── send_response
    └── serialize_body

Bidirectional (Both)

## Call Graph for `process_request`

                    ┌─────────────────┐
                    │      main       │
                    └────────┬────────┘
                             │
                    ┌────────▼────────┐
                    │   run_server    │
                    └────────┬────────┘
                             │
                    ┌────────▼────────┐
                    │handle_connection│
                    └────────┬────────┘
                             │
        ┌────────────────────┼────────────────────┐
        │                    │                    │
┌───────▼───────┐   ┌───────▼───────┐   ┌───────▼───────┐
│ parse_headers │   │ authenticate  │   │send_response  │
└───────────────┘   └───────┬───────┘   └───────────────┘
                            │
                    ┌───────┴───────┐
                    │               │
             ┌──────▼──────┐ ┌──────▼──────┐
             │ check_token │ │  load_user  │
             └─────────────┘ └─────────────┘

Analysis Insights

After generating the call graph, provide insights:

## Analysis

**Entry Points:** main, test_process_request
**Leaf Functions:** validate_header, serialize_body
**Hot Path:** main → run_server → handle_connection → process_request
**Complexity:** 12 functions, 3 levels deep

**Potential Issues:**
- `authenticate` has high fan-out (4 callees)
- `process_request` is called from 3 places (consider if this is intentional)

Common Patterns

User Says Direction Use Case
"Who calls X?" incoming Impact analysis
"What does X call?" outgoing Understanding implementation
"Show call graph" both Full picture
"Trace from main to X" outgoing Execution path

Visualization Options

Style Best For
Tree (default) Simple hierarchies
Box diagram Complex relationships
Flat list Many connections
Mermaid Export to docs

Mermaid Export

graph TD
    main --> run_server
    run_server --> handle_connection
    handle_connection --> process_request
    process_request --> parse_headers
    process_request --> authenticate
    process_request --> send_response

Related Skills

When See
Find definition rust-code-navigator
Project structure rust-symbol-analyzer
Trait implementations rust-trait-explorer
Safe refactoring rust-refactor-helper