Knowledge graph development for LLM applications. Graph storage selection, graph algorithms, extraction from documents/code/websites, entity extraction, Graph RAG, and visualization. Use when building knowledge graphs, graph databases, or LLM graph applications.
npx claudepluginhub v1truv1us/ai-eng-system --plugin ai-eng-learningThis skill uses the workspace's default tool permissions.
Build knowledge graphs for LLM applications. Knowledge graphs improve AI responses by providing structured context with relationships, enable retrieval-augmented generation with graph traversal, and support agentic workflows with graph-defined tools.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Build knowledge graphs for LLM applications. Knowledge graphs improve AI responses by providing structured context with relationships, enable retrieval-augmented generation with graph traversal, and support agentic workflows with graph-defined tools.
Choose storage based on query patterns and scale requirements.
Use for: prototyping, small graphs (<10K nodes), single-machine apps
// Example: GraphLib or native Map/Set
const graph = new Map<string, Set<string>>();
Use when: already using PostgreSQL, need ACID compliance, moderate scale
Use when: complex relationship queries, Cypher proficiency, managed needed
Use when: caching, real-time, ephemeral graphs
Use when: managed, need Gremlin/SPARQL, AWS ecosystem
Decision Matrix:
| Scenario | Recommended |
|---|---|
| Prototyping | In-memory |
| Already on Postgres | PostgreSQL |
| Complex traversals | Neo4j |
| Caching/real-time | Redis |
| Managed AWS | Neptune |
| Knowledge base | Neo4j or PostgreSQL |
Select algorithm based on the question you're answering.
Use for: exploration, finding any path, connectivity
// BFS for shortest path
function bfs(graph, start, goal) {
const queue = [[start]];
const visited = new Set([start]);
while (queue.length) {
const path = queue.shift();
const node = path[path.length - 1];
if (node === goal) return path;
for (const neighbor of graph.get(node) || []) {
if (!visited.has(neighbor)) {
visited.add(neighbor);
queue.push([...path, neighbor]);
}
}
}
}
Use for: weighted routing, travel time, cost optimization
Use for: identifying important nodes
Use for: clustering, segmentation
When to Use Each:
| Question | Algorithm |
|---|---|
| How do I get from A to B? | BFS/Dijkstra |
| What's the best order? | Topological sort |
| What's most important? | PageRank |
| Who are the bridges? | Betweenness |
| What groups exist? | Louvain |
Extract graphs from different data sources.
Process: chunk → extract entities → extract relationships
// Extract entities from text chunk
prompt = `Extract entities from: {chunk}
Entities as JSON: { "entities": [{"id": "...", "type": "...", "name": "..."}] }`;
Extract: imports, function calls, class relationships
// Dependency graph from imports
imports.map(file => ({
source: file.path,
targets: file.imports,
type: 'imports'
}));
Link graphs from HTML parsing
// Extract links
links = html.querySelectorAll('a[href]')
.map(a => ({ source: pageUrl, target: a.href, type: 'links_to' }));
Schema graphs: tables, columns, foreign keys
// Extract schema relationships
foreignKeys.map(fk => ({
source: fk.fromTable,
target: fk.toTable,
type: 'references',
via: fk.column
}));
Configuration graphs
// Dependencies from package.json
deps.map(d => ({ source: 'package', target: d.name, type: 'depends_on' }));
Build graphs using LLMs for entity and relationship extraction.
Extract all entities from the following text.
For each entity, provide: id, type, name, description.
Text: {text}
Output as JSON array:
Extract relationships between these entities.
For each relationship: source, target, type, confidence (0-1).
Entities: {entities}
Relationships:
// Embed entities for semantic search
entities.forEach(entity => {
entity.embedding = embed(entity.name + ' ' + entity.description);
});
// Query: find similar entities
similar = vectorSearch(queryEmbedding, entities, topK: 10);
Use graphs with LLMs for improved retrieval.
Context from knowledge graph:
{graph_context}
Question: {question}
Based on the graph context above, answer:
Graph retrieval steps:
Define tools from graph structure:
// Graph-defined tools
const tools = graph.nodes.map(node => ({
name: `query_${node.type}`,
description: `Query ${node.type} entities`,
parameters: { ... }
}));
// Route through graph
function orchestrate(query, graph) {
const relevant = graph.query(query);
const agent = selectAgent(relevant.type);
return agent.execute(query, relevant.context);
}
Hybrid RAG: Vector + Graph
| Approach | Best For |
|---|---|
| Vector only | Similarity search |
| Graph only | Relationship queries |
| Hybrid | Both similarity + relationships |
Execute both, combine results.
Choose visualization based on context.
For documentation, README files:
graph TD
A[User] --> B[Login]
B --> C[Dashboard]
C --> D[Query Graph]
D --> E[Results]
For interactive web applications:
// D3 force-directed graph
const simulation = d3.forceSimulation(nodes)
.force('link', d3.forceLink(links).id(d => d.id))
.force('charge', d3.forceManyBody())
.force('center', d3.forceCenter(width / 2, height / 2));
For static diagrams:
digraph {
User -> Login -> Dashboard
Dashboard -> Query
Query -> Graph
}
Selection Guide:
| Context | Recommended |
|---|---|
| Documentation | Mermaid |
| Web app | D3.js |
| Static analysis | Graphviz |
| CLI output | ASCII |
Start simple, upgrade as needed
As needed for debugging/documentation
| Mistake | Reality |
|---|---|
| "Start with Neo4j" | Start in-memory, upgrade when needed |
| "Extract everything" | Focus on useful relationships |
| "Graph replaces vector" | Use hybrid approach |
| "One-time build" | Graphs need maintenance |