From ai-eng-research
Guides building knowledge graphs for LLM applications including storage selection, graph algorithms, entity extraction, and Graph RAG patterns.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ai-eng-research:graphifyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
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.
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 |
| Excuse | Counter |
|---|---|
| "Start with Neo4j" | Start in-memory, upgrade when needed. Premature infrastructure adds operational cost. |
| "Extract everything" | Focus on useful relationships. Over-extraction creates noise and slows queries. |
| "Graph replaces vector" | Use hybrid approach. Graph and vector complement each other, they do not compete. |
| "One-time build is enough" | Graphs need maintenance. Stale graphs produce stale answers. |
| "I don't need confidence scores on relationships" | Without confidence, you cannot filter low-quality edges. Scores enable quality control. |
2plugins reuse this skill
First indexed Jul 8, 2026
npx claudepluginhub p/v1truv1us-ai-eng-research-plugins-ai-eng-researchCreates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.