/kg-extract
Extract entities and relations from source files to build a knowledge graph
$ npx -y skills add ruvnet/claude-flow --skill kg-extract --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/kg-extract
Context preview
The summary Claude sees to decide when to auto-load this skill.
Extract entities and relations from source files to build a knowledge graph
SKILL.md
kg-extract.SKILL.mdname: kg-extract
description: Extract entities and relations from source files to build a knowledge graph
argument-hint: "<path>"
allowed-tools: Read Glob Grep mcp__plugin_ruflo-core_ruflo__agentdb_hierarchical-store mcp__plugin_ruflo-core_ruflo__agentdb_causal-edge mcp__plugin_ruflo-core_ruflo__agentdb_pattern-store mcp__plugin_ruflo-core_ruflo__embeddings_generate Bash
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
Read more
name: kg-extract description: Extract entities and relations from source files to build a knowledge graph argument-hint: "<path>" allowed-tools: Read Glob Grep mcp__plugin_ruflo-core_ruflo__agentdb_hierarchical-store mcp__plugin_ruflo-core_ruflo__agentdb_causal-edge mcp__plugin_ruflo-core_ruflo__agentdb_pattern-store mcp__plugin_ruflo-core_ruflo__embeddings_generate Bash
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
An agent meta-harness for Claude Code and Codex. Agent = Model + Harness. The model writes; the harness gives it tools, memory, loops, sandboxes, and controls so it can actually work.
Repo: ruvnet/claude-flow
Other skills on claude-flow.
- /agentdb-advanced
Master advanced AgentDB features including QUIC synchronization, multi-database management, custom distance metrics, hybrid search, and distributed systems integration. Use when building distributed AI systems, multi-agent coordination, or advanced vector search applications.
Open skill - /agentdb-learning
Create and train AI learning plugins with AgentDB's 9 reinforcement learning algorithms. Includes Decision Transformer, Q-Learning, SARSA, Actor-Critic, and more. Use when building self-learning agents, implementing RL, or optimizing agent behavior through experience.
Open skill - /agentdb-memory-patterns
Implement persistent memory patterns for AI agents using AgentDB. Includes session memory, long-term storage, pattern learning, and context management. Use when building stateful agents, chat systems, or intelligent assistants.
Open skill - /agentdb-optimization
Optimize AgentDB performance with quantization (4-32x memory reduction), HNSW indexing (150x faster search), caching, and batch operations. Use when optimizing memory usage, improving search speed, or scaling to millions of vectors.
Open skill - /agentdb-vector-search
Implement semantic vector search with AgentDB for intelligent document retrieval, similarity matching, and context-aware querying. Use when building RAG systems, semantic search engines, or intelligent knowledge bases.
Open skill - /agentic-jujutsu
Quantum-resistant, self-learning version control for AI agents with ReasoningBank intelligence and multi-agent coordination
Open skill

