AWS Builder Center
Reduce AI Coding Agent Token Usage by 40–70% with Graphify Knowledge Graphs in Kiro

Reduce AI Coding Agent Token Usage by 40–70% with Graphify Knowledge Graphs in Kiro

Graphify is an open-source skill that builds queryable knowledge graphs from your codebase, letting AI coding agents pull only the relevant context they need. Popular with Codex and Claude Code users, Graphify is fully compatible with Kiro IDE and Kiro CLI through skills and hooks – giving your agents a structural map instead of forcing them to re-read raw files every session.

The Problem: AI Coding Agents Waste Tokens on Irrelevant Context

If you have used an AI coding agent on a project with more than a handful of files, you have experienced the same frustration. The agent reads entire files to orient itself. It pulls in code that has nothing to do with your prompt. As your codebase grows, you lose track of what the agent needs to see, and the agent lacks a map to figure it out on its own.
The result is predictable:
  • Inflated token consumption per session
  • Slower response times as the context window fills with noise
  • Hallucinated dependencies because the agent cannot see how modules actually connect
  • Manual overhead of pointing agents at the right files and classes
This problem scales linearly with project size. A 50-file project might be manageable, but a production codebase with hundreds of modules, shared libraries, and database schemas quickly overwhelms brute-force file reading.

What Is Graphify?

Graphify  is an open-source AI coding assistant skill that transforms any codebase into a queryable knowledge graph. Rather than letting agents read raw repositories over and over, Graphify builds a structured map of how your code is connected – functions, classes, imports, call edges, database schemas, API endpoints, and even documentation – all represented as nodes and edges in a graph.
Key stats:
  • 28,000+ GitHub stars in the first two weeks after release
  • 1,093 commits and active development
  • Supports code (.py, .ts, .js, .go, .rs, .java, .c, .cpp, .rb, and more), Markdown, PDFs, and images
  • 71.5x fewer tokens per query vs. reading raw files (on mixed corpora of 50+ files)
How it works:
  1. Multi-modal extraction – Tree-sitter parses ASTs and call graphs from code files. Claude extracts concepts and relationships from documentation. Vision models read diagrams and screenshots.
  2. Knowledge graph construction – All extracted nodes and edges merge into a NetworkX graph. The Leiden algorithm detects semantic communities – no vector embeddings required.
  3. God nodes and surprises – Graphify identifies the highest-degree concepts everything connects through and flags unexpected cross-file connections worth investigating.
  4. Interactive outputs – Exports an interactive graph.html, a queryable graph.json, a human-readable GRAPH_REPORT.md, and an optional Obsidian vault.
Once built, the graph persists. Agents query it on subsequent sessions without re-reading your source files. A SHA256 cache means re-runs only process changed files.

Why Graphify Matters for Your Codebase

The core value proposition is simple: give AI agents a pre-mapped graph to navigate instead of forcing them to grep and read raw files.
Without GraphifyWith Graphify
Agent reads entire files to find relevant codeAgent queries the graph for specific relationships
20,000+ tokens burned per session just for orientationSubgraph queries return only relevant context
Hallucinated imports and dependenciesEdges are tagged EXTRACTED, INFERRED, or AMBIGUOUS
Manual prompting to direct agent attentionAgent navigates the graph autonomously
Context re-read on every new sessionPersistent graph survives across sessions
Real-world results:
  • Mixed corpus (code + papers + images, 52 files): 71.5x token reduction
  • Growing codebases see compounding savings – the larger the project, the greater the benefit
  • Practical developer reports indicate 40–70% reduction in typical workflows
This matters whether you are refactoring legacy architecture, building complex new features from scratch, or onboarding a new team member. The agent understands relationships between your APIs, database schemas, and frontend components – no more hallucinated dependencies.

Graphify Is Not Just for Claude Code and Codex

Graphify is most commonly associated with Claude Code and OpenAI Codex, where it originated as a slash-command skill (/graphify). But Graphify is tool-agnostic by design. It supports 15+ platforms – Claude Code, Codex, OpenCode, Cursor, Gemini CLI, GitHub Copilot CLI, and more – including first-class support for Kiro IDE and Kiro CLI.
Graphify's repo includes a dedicated graphify kiro install command that writes both a Skill and a Steering file into Kiro's native configuration structure. Optionally, you can layer on Hooks for automatic graph rebuilds.

Installing Graphify for Kiro (Official Method)

Graphify provides a dedicated platform installer for Kiro directly from its CLI. This is the recommended method documented in the Graphify GitHub repository .
Step 1: Install the Graphify CLI
1
2
3
4
5
# Recommended (isolated env):
uv tool install graphifyy

# Alternatives:
pipx install graphifyy
Note: The PyPI package is graphifyy (double-y). The CLI command is still graphify. Using uv tool install or pipx is recommended over pip install to avoid environment isolation issues.
Step 2: Register Graphify for Kiro
1
graphify kiro install
This single command creates two files in your project:
1
2
3
.kiro/
├── skills/graphify/SKILL.md # Skill: activates when queries match its description
└── steering/graphify.md # Steering: always-loaded context guiding the agent toward the graph
What each file does:
  • .kiro/skills/graphify/SKILL.md – A portable skill package following the open Agent Skills standard . It contains the instructions for building and querying the knowledge graph, activating on-demand when your prompt matches (e.g., "what depends on the auth module?"). You can also invoke it directly via the /graphify slash command.
  • .kiro/steering/graphify.md – A steering file that loads into every Kiro session automatically. It tells Kiro to prefer scoped graph queries (graphify query "<question>") over reading raw files or grepping, ensuring the agent reaches for the graph by default.
Project-scoped install (committable to git):
1
graphify kiro install --project
This writes the files under the current directory so you can git add them and share the configuration with your team. Every developer who clones the repo gets Graphify integration out of the box.
To uninstall:
1
graphify kiro uninstall

Adding Kiro Hooks for Automatic Graph Sync

While graphify kiro install handles the skill and steering setup, you can optionally add Kiro hooks  to keep the graph automatically in sync as you code.
Option A: File-save hook (immediate sync)
Create .kiro/hooks/graphify-sync.json:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"version": "v1",
"hooks": [
{
"name": "graphify-rebuild-on-save",
"trigger": "PostFileSave",
"matcher": "\\.(ts|js|py|go|rs|java|rb)$",
"action": {
"type": "command",
"command": "
AWS_PROFILE=<AWS_PROFILE> \
AWS_REGION=<AWS_REGION> \
graphify . --update\
--backend bedrock \
--model global.anthropic.claude-haiku-4-5-20251001-v1:0
"

},
"timeout": 120,
"enabled": true
}
]
}
This fires graphify . --update (incremental – only processes changed files) every time you save a source file matching the pattern. The existing graph is merged, not rebuilt from scratch.
Option B: Git commit hook (batch sync)
If you prefer less-frequent rebuilds:
1
graphify hook install
This installs a post-commit + post-checkout git hook that rebuilds the graph after each commit. No background process required – fires once per commit and works alongside existing git hooks.

Kiro CLI Integration

For developers using Kiro CLI , the setup is identical – graphify kiro install writes the same .kiro/skills/ and .kiro/steering/ files that the CLI reads. The skill activates automatically when your request matches its description, or via /graphify slash command.
Custom agents in Kiro CLI can explicitly include the skill:
1
2
3
4
5
6
7
{
"name": "my-agent",
"resources": [
"skill://.kiro/skills/graphify/SKILL.md",
"file://.kiro/steering/**/*.md"
]
}

How It All Comes Together

Here is the typical workflow once Graphify is integrated into Kiro:
  1. Install – uv tool install graphifyy && graphify kiro install
  2. Build the graph – In Kiro, type /graphify . or run graphify . from your terminal. The graph builds in 30–90 seconds for large codebases.
  3. Hooks keep it fresh – File-save hooks or git commit hooks trigger incremental updates automatically.
  4. Agent queries the graph – When you ask Kiro to refactor a module, add a feature, or trace a bug, the steering file nudges the agent toward the graph. The skill activates for architecture queries. The agent queries relationships instead of reading raw files.
  5. Focused context, better output – The agent receives a tight subgraph of exactly the relevant code architecture, not a dump of every file in the repository.
The result: faster responses, dramatically lower token consumption, fewer hallucinated dependencies, and an agent that actually understands how your code is connected.

Getting Started

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Install the CLI
uv tool install graphifyy

# Register Graphify for Kiro
graphify kiro install

# Build your first graph (from terminal or inside Kiro with /graphify .)
cd your-project
AWS_PROFILE=<AWS_PROFILE> \
AWS_REGION=<AWS_REGION> \
graphify . --extract\
--backend bedrock \
--model global.anthropic.claude-haiku-4-5-20251001-v1:0

# (Optional) Add auto-sync hook
graphify hook install

# Start using it in Kiro
# Ask: "What modules depend on the auth service?"
# Or: /graphify query "how does the API connect to the database?"
Resources:
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article