Your First Knowledge Graph

Lesson 1 · Learn Graphify · ~10 minutes

By the end of this lesson, you'll have a working knowledge graph of your DocumentDB Performance Test infrastructure and understand what the three output files are for.

Win

After this lesson, your next Kiro CLI session on the DocumentDB project can start with /graphify and skip the discovery phase entirely.

What Graphify Does

When you point an AI assistant at a large codebase, it has two bad options: read every file (blowing the context window) or guess which files matter (missing connections). Graphify gives it a third option: read a structured map of your code's relationships — classes, functions, imports, call chains — then only read the actual files it needs.

The mechanism is tree-sitter AST parsing. It pulls structure from your code locally (nothing leaves your machine) and writes three files:

Step 1: Install the Kiro Skill

Navigate to your DocumentDB project root and run:

cd ~/path/to/documentdb-perf-tests
graphify kiro install

This writes a .kiro/skills/graphify/ directory and a steering file into the project so Kiro CLI knows about the /graphify command.

Note

kiro install is project-scoped by default. The skill lives in the repo, not globally. Other repos won't have it until you run the same command there (or use graphify install --platform kiro globally — but project-scoped is better for team repos).

Step 2: Build the Graph

From the project root:

graphify .

Or, if you want to run it from elsewhere:

graphify /absolute/path/to/project

This takes 10–60 seconds depending on codebase size. Tree-sitter parses every Python file and extracts:

After extraction, Graphify clusters related nodes into communities (groups of tightly-connected code). This is what makes the report useful — it names the clusters so you can navigate by concept, not by file.

Step 3: Inspect the Output

Open the visualization:

open graphify-out/graph.html

And read the report:

cat graphify-out/GRAPH_REPORT.md

The report will show you:

Step 4: Use It in a Session

Start a new Kiro CLI session in the project and type:

/graphify

The AI assistant will load graph.json as context instead of reading your entire codebase. It can then answer structural questions like:

Staleness

The graph is a snapshot. If you add new files or refactor significantly, run graphify update . to refresh it without a full rebuild. For automatic freshness, consider graphify hook install which adds a post-commit git hook.

Key Concepts

Verify Your Understanding

What does graphify update . do differently from graphify .?

Which output file does the AI assistant primarily consume during a session?

Do This Now

  1. Navigate to your DocumentDB Performance Test infrastructure project
  2. Run graphify kiro install
  3. Run graphify .
  4. Open graphify-out/graph.html in your browser and explore the communities
  5. Read graphify-out/GRAPH_REPORT.md — note which clusters it found
Primary Source

Read the BetterStack guide: Building a Knowledge Graph of Your Codebase for a deeper walkthrough of what tree-sitter extracts and how the clustering works.