graphify
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.
What this skill does
# Graphify
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.
## When to Use
- Building knowledge bases with relationships (not just chunks)
- Implementing Graph RAG for better recall
- Extracting structure from unstructured documents
- Building agent memories with relationships
- Creating recommendation systems
- Analyzing code dependencies
---
## 1. Graph Storage Selection
Choose storage based on query patterns and scale requirements.
### In-Memory Graph
Use for: prototyping, small graphs (<10K nodes), single-machine apps
```typescript
// Example: GraphLib or native Map/Set
const graph = new Map<string, Set<string>>();
```
### PostgreSQL with Extensions
Use when: already using PostgreSQL, need ACID compliance, moderate scale
- **pggraph**: Native graph support via extensions
- Works with existing Postgres infrastructure
### Neo4j
Use when: complex relationship queries, Cypher proficiency, managed needed
- Best for: traversals, path finding, graph algorithms
- Avoid if: simple queries dominate
### Redis
Use when: caching, real-time, ephemeral graphs
- Best for: session graphs, rate limiting, recent activity
### AWS Neptune
Use when: managed, need Gremlin/SPARQL, AWS ecosystem
- Serverless option available
- Integration with AWS services
**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 |
---
## 2. Graph Algorithms
Select algorithm based on the question you're answering.
### Traversal (BFS/DFS)
Use for: exploration, finding any path, connectivity
- **BFS**: Shortest unweighted path, level-by-level
- **DFS**: Deep exploration, cycle detection
```typescript
// 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]);
}
}
}
}
```
### Shortest Path (Dijkstra, A*)
Use for: weighted routing, travel time, cost optimization
### Centrality Measures
Use for: identifying important nodes
- **PageRank**: Importance via links/votes
- **Betweenness**: Bridge identification
- **Degree**: Direct influence
### Community Detection
Use for: clustering, segmentation
- **Louvain**: Large-scale community detection
- **Label Propagation**: Fast clustering
**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 |
---
## 3. Graph Extraction Sources
Extract graphs from different data sources.
### From Documents (PDF, Markdown)
Process: chunk → extract entities → extract relationships
```typescript
// Extract entities from text chunk
prompt = `Extract entities from: {chunk}
Entities as JSON: { "entities": [{"id": "...", "type": "...", "name": "..."}] }`;
```
### From Code (AST Parsing)
Extract: imports, function calls, class relationships
```typescript
// Dependency graph from imports
imports.map(file => ({
source: file.path,
targets: file.imports,
type: 'imports'
}));
```
### From Websites
Link graphs from HTML parsing
```typescript
// Extract links
links = html.querySelectorAll('a[href]')
.map(a => ({ source: pageUrl, target: a.href, type: 'links_to' }));
```
### From SQL
Schema graphs: tables, columns, foreign keys
```typescript
// Extract schema relationships
foreignKeys.map(fk => ({
source: fk.fromTable,
target: fk.toTable,
type: 'references',
via: fk.column
}));
```
### From JSON/YAML
Configuration graphs
```typescript
// Dependencies from package.json
deps.map(d => ({ source: 'package', target: d.name, type: 'depends_on' }));
```
---
## 4. LLM Graph Construction
Build graphs using LLMs for entity and relationship extraction.
### Entity Extraction Prompt
```prompt
Extract all entities from the following text.
For each entity, provide: id, type, name, description.
Text: {text}
Output as JSON array:
```
### Relationship Extraction Prompt
```prompt
Extract relationships between these entities.
For each relationship: source, target, type, confidence (0-1).
Entities: {entities}
Relationships:
```
### Relationship Confidence
- Use LLM to provide confidence scores
- Filter by threshold (e.g., confidence > 0.7)
- Allow incremental updating
### Semantic Search with Embeddings
```typescript
// 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);
```
### Incremental Graph Building
1. Process new document
2. Extract entities (match existing → link, new → add)
3. Extract relationships (add/update)
4. Update embeddings
---
## 5. LLM Graph Integration
Use graphs with LLMs for improved retrieval.
### Graph RAG Pattern
```prompt
Context from knowledge graph:
{graph_context}
Question: {question}
Based on the graph context above, answer:
```
**Graph retrieval steps:**
1. Convert question to graph query
2. Traverse relevant subgraphs
3. Include relationship context in prompt
### Graph Tools for Agents
Define tools from graph structure:
```typescript
// Graph-defined tools
const tools = graph.nodes.map(node => ({
name: `query_${node.type}`,
description: `Query ${node.type} entities`,
parameters: { ... }
}));
```
### Subagent Orchestration via Graph
```typescript
// 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.
---
## 6. Graph Visualization
Choose visualization based on context.
### Mermaid
For documentation, README files:
```mermaid
graph TD
A[User] --> B[Login]
B --> C[Dashboard]
C --> D[Query Graph]
D --> E[Results]
```
### D3.js
For interactive web applications:
```typescript
// 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));
```
### Graphviz (DOT)
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 |
---
## Process Summary
### Step 1: Choose Storage
Start simple, upgrade as needed
### Step 2: Extract Graph
- From documents → chunk + LLM extraction
- From code → AST parsing
- From existing data → schema extraction
### Step 3: Build Incrementally
- Process documents
- Deduplicate entities
- Add relationships
- Update embeddings
### Step 4: Integrate with LLM
- Graph RAG for retrieval
- Graph tools for agents
### Step 5: Visualize
As needed for debugging/documentation
---
## Common Mistakes
| Mistake | Reality |
|---------|--------|
| "Start with Neo4j" | Start in-memory, upgrade when needed |
| "Extract everything" | FoRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.