Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
ruvnet avatar

Kg Extract

  • 635 installs
  • 67k repo stars
  • Updated August 4, 2026
  • ruvnet/ruflo

kg-extract is an agent skill that extracts entities and relations from source files into AgentDB knowledge graphs for developers mapping codebase structure and dependencies.

About

kg-extract is a ruvnet/ruflo skill that extracts entities—classes, functions, modules, types, and concepts—and relations including imports, extends, implements, depends-on, and calls from source files or documentation, then stores them as a knowledge graph in AgentDB. Developers invoke it with a path argument-hint when building or updating codebase knowledge graphs for structure understanding, dependency tracing, or agent memory priming. Allowed tools include Read, Glob, Grep, Bash, mcp__claude-flow__agentdb_hierarchical-store, agentdb_causal-edge, agentdb_pattern-store, and embeddings_generate for semantic enrichment. The workflow supports understanding large repositories without rereading every file each agent turn. Catalog metadata lists 440 installs. kg-extract pairs with adr-create and agentdb-query in Claude-flow workflows where structured graphs power hierarchical recall and causal reasoning over code relationships.

  • kg-extract

Kg Extract by the numbers

  • 635 all-time installs (skills.sh)
  • +10 installs in the week ending Jul 26, 2026 (Skillselion tracking)
  • Ranked #586 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/ruvnet/ruflo --skill kg-extract

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs635
repo stars67k
Last updatedAugust 4, 2026
Repositoryruvnet/ruflo

How do you build a knowledge graph from code?

Use kg-extract for development tasks

Who is it for?

Developers building AgentDB knowledge graphs from repositories who need entity and relation extraction for agent semantic recall.

Skip if: Developers needing one-off grep searches without persistent AgentDB graphs or teams without Claude-flow AgentDB MCP configured.

When should I use this skill?

User asks to extract a knowledge graph from code, map imports and calls, or populate AgentDB from a repository path.

What you get

AgentDB knowledge graph with extracted entities, import/call relations, causal edges, and optional embedding-enriched pattern store entries.

  • Knowledge graph in AgentDB
  • Entity-relation map
  • Causal-edge links

By the numbers

  • Extracts 5 entity types: classes, functions, modules, types, concepts
  • Maps 5 relation types: imports, extends, implements, depends-on, calls

Files

SKILL.mdMarkdownGitHub ↗

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__claude-flow__agentdb_hierarchical-store for each entity with metadata (name, type, file, line, description) 5. Create edges -- call mcp__claude-flow__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

Related skills

How it compares

Pick kg-extract for persistent AgentDB code knowledge graphs instead of one-shot grep when agents need causal edges and embedding-backed recall.

FAQ

What entities does kg-extract capture?

kg-extract captures classes, functions, modules, types, and concepts from source files or documentation. It maps relations including imports, extends, implements, depends-on, and calls into AgentDB graph storage.

Which AgentDB tools does kg-extract use?

kg-extract uses agentdb_hierarchical-store, agentdb_causal-edge, agentdb_pattern-store, and embeddings_generate MCP tools plus Read, Glob, Grep, and Bash to parse paths and persist knowledge graphs.

When should developers invoke kg-extract?

kg-extract fits building or updating knowledge graphs from codebases when agents need structure understanding, dependency tracing, or semantic recall without rereading entire repositories each session.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.