Skip to content
Skillpedia
Analysis & spreadsheets81k · #1639

kg-extract

What it does

This skill reads source files and turns the classes, functions and modules into a map of how they relate. It is for developers who need to understand a codebase's structure and how changes might spread.

When to use it

  • ✓When you want to understand how the parts of a codebase depend on each other.
  • ✓When you need to judge how far a change could reach.
  • ✓When you want to refresh a code map after large changes.

Skill link

https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-knowledge-graph/skills/kg-extract/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-knowledge-graph/skills/kg-extract/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Map the main parts of my project and how they depend on each other.”

5 new skills a week. 1 minute to read.

How it works

The skill reads the source files, identifies classes, functions, modules and types, then records how they relate, such as through imports and inheritance. It stores the result as a graph in the project's memory store.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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
FAQ

Are type-only imports counted as runtime links?

No. Type-only imports are kept as a weaker relation and are not used for cycle detection.

What relations are recorded?

Imports, extends, implements and depends-on relations, each with a weight.

Where is the graph stored?

It is stored in AgentDB, the memory store the skill uses.

Details

Original description by the author

Extract entities and relations from source files to build a knowledge graph

repo: ruvnet/ruflo

Popularity

GitHub stars
81k
Ranking position
#1639
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills