PostgreSQL + pgvector + PGroonga で GraphRAG を構築。自然言語でプロジェクトを説明すると、最適なEntity/Edge型、スキーマ、クエリパターンを設計・生成。Use when the user mentions "GraphRAG", "knowledge graph", or wants to build RAG with relationships.
PostgreSQL単体(pgvector + PGroonga拡張)でGraphRAGを構築するためのスキル。 自然言語でプロジェクトを説明すると、最適なGraphRAGスキーマを設計・生成する。
/graphrag 小説のキャラクター関係を管理したい。時系列で関係が変化する
↓ Claude が分析
Entity型: Character, Location, Organization, Event, Item
Edge型: friend_of, enemy_of, ally_of, family_of, participates_in
追加機能: 時系列サポート(events テーブル)
↓ ユーザー確認後、生成
sql/schema.sql, sql/indexes.sql, sql/queries/*.sql, docs/
{project}/
├── sql/
│ ├── schema.sql # カスタマイズされたスキーマ
│ ├── indexes.sql # インデックス定義
│ └── queries/
│ ├── local_search.sql # Entity中心検索
│ ├── global_search.sql # 全体俯瞰検索
│ ├── hybrid_search.sql # Hybrid Search
│ └── custom_*.sql # 要件固有のクエリ
└── docs/
├── graphrag-guide.md # 運用ガイド
└── prompts/
├── entity_extraction.md
└── edge_extraction.md
ユーザーの自然言語の説明を分析:
以下のリファレンスを参照して設計:
ユーザー要件に最適なEntity型とEdge型を設計:
参考パターン(use-cases.md より):
| パターン | Entity型例 | Edge型例 |
|---|---|---|
| 物語・コンテンツ | Character, Location, Item | friend_of, enemy_of, possesses |
| 技術文書 | Technology, API, Component | depends_on, implements, extends |
| ナレッジベース | Concept, Process, Document | defines, precedes, references |
| 障害・トラブル | Symptom, Cause, Solution | causes, solved_by, affects |
| 法務・規約 | Clause, Requirement, Exception | refers_to, overrides, exception_of |
これらを参考に、ユーザー要件に合わせてカスタム設計する。
AskUserQuestionで設計を確認:
templates/schema-core.sqlsql/schema.sqlユーザーの検索要件に基づいてクエリを生成:
local_search.sql - Entity中心のn-hop展開global_search.sql - Community reports検索hybrid_search.sql - PGroonga + pgvector (RRF)custom_*.sql - 要件固有(依存ツリー、因果パス、類似検索等)設計したEntity/Edge型に基づいてLLM抽出プロンプトを生成:
docs/prompts/entity_extraction.md - Entity抽出用docs/prompts/edge_extraction.md - Edge抽出用docs/graphrag-guide.md:
生成完了を報告:
共通:
ユースケース固有:
オプション: