本文へスキップ
Skillpedia
分析とスプレッドシート81k · #1639

kg-extract

できること

このスキルは、ソースファイルを読み、クラス、関数、モジュールを、それらの関係を示す地図に変換します。コードベースの構造と、変更がどこまで広がりうるかを理解したい開発者向けです。

使う場面

  • ✓コードベースの各部分が互いにどう依存しているかを理解したいとき。
  • ✓変更がどこまで影響するかを判断する必要があるとき。
  • ✓大きな変更の後に、コードの地図を更新したいとき。

スキルのリンク

https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-knowledge-graph/skills/kg-extract/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-knowledge-graph/skills/kg-extract/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“プロジェクトの主要な部分と、それらの相互の依存関係を地図にしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

スキルはソースファイルを読み、クラス、関数、モジュール、型を特定してから、インポートや継承などを通じてそれらの関係を記録します。結果は、プロジェクトのメモリーストアにグラフとして保存されます。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

KG Extract

Extract entities (classes, functions, modules, types, concepts) and their relations (imports, extends, implements, depends-on, calls) from source files, then store them as a knowledge graph in AgentDB.

When to use

When you need to build or update a knowledge graph from source code or documentation. Useful for understanding codebase structure, dependency analysis, and impact assessment.

Steps

  1. Scan files -- use Glob and Read to enumerate and read source files at the given path

  2. Identify entities -- extract classes, functions, modules, types, and config references from each file

  3. Map relations -- for each entity, determine its relations to other entities. Critical: TypeScript import type and inline type specifiers (import { type Foo, bar }) are erased at compile time and MUST NOT be counted as value imports -- they're a separate, weaker relation. Misclassifying them produces phantom runtime cycles (see ruvnet/ruflo#2049).

    • imports: value imports (import { x } from '...', require(...)) -- weight 0.9
    • type-depends-on: TypeScript type-only imports (import type { Foo } from '...' and import { type Foo, value } from '...') -- weight 0.1, never used for cycle detection or runtime impact analysis
    • extends: class inheritance -- weight 0.9
    • implements: interface implementations -- weight 0.7
    • depends-on: constructor dependencies, injected services -- weight 0.8
    • calls: function/method invocations -- weight 0.7
    • references: documentation mentions, comments -- weight 0.3

    Regex hint for classifying TS imports (so a naive from '...' grep doesn't conflate the two):

    ^\s*import\s+type\s+               → type-depends-on (entire import is type-only)
    ^\s*import\s*\{[^}]*\btype\s+\w+   → split: type specifiers → type-depends-on, value specifiers → imports
    ^\s*import\s+[^{]*\bfrom\s+        → imports (value)
    
  4. Store in AgentDB -- call mcp__plugin_ruflo-core_ruflo__agentdb_hierarchical-store for each entity with metadata (name, type, file, line, description)

  5. Create edges -- call mcp__plugin_ruflo-core_ruflo__agentdb_causal-edge for each relation with source, target, relation type, and weight

  6. Report -- summarize: total entities by type, total relations by type, files scanned

CLI alternative

npx @claude-flow/cli@latest memory store --namespace knowledge-graph --key "entity-NAME" --value "METADATA_JSON"
npx @claude-flow/cli@latest memory search --query "entities in auth module" --namespace knowledge-graph
よくある質問

型だけのインポートは、実行時のつながりとして数えられますか?

いいえ。型だけのインポートは弱い関係として残され、循環の検出には使われません。

どの関係が記録されますか?

インポート、extends、implements、依存の関係で、それぞれに重みが付きます。

グラフはどこに保存されますか?

スキルが使うメモリーストアである AgentDB に保存されます。

詳細

作者による元の説明

Extract entities and relations from source files to build a knowledge graph

repo: ruvnet/ruflo

人気

GitHubのスター
81k
ランキング
#1639
ライセンス
MIT
更新日
2026/11/2

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル