Why KiroGraph
KiroGraph is a semantic code knowledge graph built specifically for Kiro. It gives Kiro a pre-indexed understanding of your codebase: symbol relationships, call graphs, type hierarchies, impact radius, so it can answer complex questions in a single MCP tool call instead of cascading through file reads, greps, and globs.
The problem
When an AI coding agent works on a complex task, it explores your codebase one tool call at a time: read a file, grep for a symbol, glob for related files, read another file. Each of those burns context window and adds latency. On large codebases this becomes the bottleneck: not the reasoning, but the exploration.
The approach
KiroGraph parses your entire codebase with tree-sitter, extracts symbols and their relationships into a local SQLite graph database, and optionally generates vector embeddings for natural-language search. The result is a structured knowledge graph that can answer "who calls this function?", "what breaks if I change this?", or "find code related to authentication" in milliseconds, without reading a single file.
Why Kiro
KiroGraph is designed around Kiro's architecture:
- MCP integration: Kiro's native MCP support means KiroGraph tools are auto-approved and always available, no manual configuration needed.
- Hooks system: Kiro's file event hooks (
fileEdited,fileCreated,fileDeleted,agentStop) keep the index fresh automatically with zero overhead during editing. No background watcher process. - Steering files: Kiro's steering mechanism teaches the agent to prefer graph tools over file scanning, always in context with no extra tool calls.
- CLI agent: Kiro CLI's agent system allows a dedicated KiroGraph agent with inlined instructions and session-boundary sync hooks.
This tight integration is why Kiro is the primary and fully supported target. The hooks, steering, and agent config are all Kiro-native concepts that make the experience seamless.
Scope and other tools
The core of KiroGraph (the graph database, tree-sitter parsing, MCP server, and CLI) is tool-agnostic. Any MCP-capable client can query the same graph. Experimental integrations for Claude Code and Codex are available via kirograph install --target claude|codex, but they lack the automatic sync hooks and steering that make the Kiro experience seamless.
Issues and PRs for non-Kiro targets are welcome, but there is no guarantee they will be supported or merged without active help from the contributor. The project's development focus remains on the Kiro integration.
Installation
From npm
npm install -g kirograph
From source
git clone https://github.com/davide-desio-eleva/kirograph.git
cd kirograph
npm install
npm run build
sudo npm install -g .
After building, both kirograph and the short alias kg are available globally.
Verify
kirograph --version
Uninstalling
# Remove from a project
kirograph uninit [path] # prompts to remove integration files and .kirograph/ data
kirograph uninit --force # remove everything without confirmation
# Remove the CLI globally (npm)
npm uninstall -g kirograph
# Remove the CLI globally (from source)
cd kirograph && npm uninstall -g .
Quick Start
Run this inside any project you want to index:
kirograph install # interactive setup: wires MCP + hooks + steering + CLI agent
The installer prompts you for:
- Whether to enable embeddings (semantic search)
- Embedding model and semantic engine
- Whether to enable architecture analysis
- Caveman mode level
- Whether to run an initial index immediately
Then restart Kiro IDE (or run kiro-cli --agent kirograph). Kiro will now use KiroGraph tools automatically whenever you ask it to work on your code.
kg install.
How Indexing Works
Indexing has three layers: structural (always on), semantic (opt-in), and architecture (opt-in).
Structural layer
tree-sitter parses every source file into an AST. Nodes and edges are extracted and written to .kirograph/kirograph.db. This powers all graph traversal tools and exact/FTS symbol search. No extra dependencies. Runs on every kirograph index or kirograph sync.
Extracts 24 node kinds: function, method, class, interface, struct, trait, protocol, enum, type_alias, property, field, variable, constant, enum_member, parameter, import, export, route, component, file, module, namespace, and more.
13 edge types: calls, imports, exports, extends, implements, contains, references, instantiates, overrides, decorates, type_of, returns, uses.
Semantic layer (opt-in)
When enableEmbeddings: true, KiroGraph generates 768-dimensional vector embeddings for every embeddable symbol using nomic-ai/nomic-embed-text-v1.5 (~130 MB, downloaded once to ~/.kirograph/models/). Powers natural-language search in kirograph_context.
Seven pluggable semantic engines:
| Engine | Store | Search type | Extra deps |
|---|---|---|---|
cosine (default) | kirograph.db | Exact cosine, linear scan | none |
sqlite-vec | .kirograph/vec.db | ANN, sub-linear | better-sqlite3, sqlite-vec |
orama | .kirograph/orama.json | Hybrid (full-text + vector) | @orama/orama |
pglite | .kirograph/pglite/ | Hybrid, exact (WASM pgvector) | @electric-sql/pglite |
lancedb | .kirograph/lancedb/ | ANN, sub-linear | @lancedb/lancedb |
qdrant | .kirograph/qdrant/ | ANN (HNSW), sub-linear | qdrant-local |
typesense | .kirograph/typesense/ | ANN (HNSW), sub-linear | typesense |
Architecture layer (opt-in)
When enableArchitecture: true, KiroGraph detects packages and architectural layers (api, service, data, ui, shared) and computes coupling metrics (Ca, Ce, instability) between them. Results stored in arch_* tables in kirograph.db.
Supported Languages
General-purpose
| Language | Extensions |
|---|---|
| TypeScript | .ts |
| JavaScript | .js |
| TSX | .tsx |
| JSX | .jsx |
| Python | .py |
| Go | .go |
| Rust | .rs |
| Java | .java |
| C | .c, .h |
| C++ | .cpp, .cc, .cxx, .hpp |
| C# | .cs |
| PHP | .php |
| Ruby | .rb |
| Swift | .swift |
| Kotlin | .kt |
| Dart | .dart |
| Scala | .scala, .sc, .sbt |
| Lua | .lua |
| Zig | .zig, .zon |
| Bash | .sh, .bash, .zsh |
| OCaml | .ml, .mli |
| Elm | .elm |
| Objective-C | .m |
Frontend & UI
| Language | Extensions |
|---|---|
| React / React Native | .tsx, .jsx (via TypeScript/JSX grammars) |
| Next.js | .tsx, .jsx (via TypeScript/JSX grammars) |
| Angular | .ts, .html (via TypeScript/HTML grammars) |
| Svelte | .svelte |
| Vue | .vue |
| HTML | .html, .htm |
| CSS | .css |
| SCSS / Sass | .scss, .sass |
Domain-specific
| Language | Domain | Extensions |
|---|---|---|
| Solidity | Blockchain / Web3 | .sol |
| Elixir | Distributed systems / Real-time | .ex, .exs |
Configuration & Infrastructure
| Language | Extensions |
|---|---|
| YAML | .yaml, .yml |
| HCL (Terraform) | .tf, .tfvars |
Framework Detection
KiroGraph auto-detects frameworks and enriches the graph with framework-specific semantics (routes, components, lifecycle methods).
Web Frameworks
| Language | Frameworks |
|---|---|
| JavaScript / TypeScript | React, Next.js, React Native, Angular, Svelte, SvelteKit, Express, Fastify, Koa |
| Vue | Vue, Nuxt |
| Python | Django, Flask, FastAPI |
| Ruby | Rails |
| Java | Spring, Spring Boot, Spring MVC |
| Scala | Play, Akka HTTP, http4s |
| Go | Generic Go resolver |
| Rust | Generic Rust resolver |
| C# | ASP.NET Core |
| Swift | SwiftUI, UIKit, Vapor |
| PHP | Laravel |
| Elixir | Phoenix |
| Solidity | Hardhat, Foundry, Truffle (OpenZeppelin patterns) |
Infrastructure as Code
| Tool | Detection |
|---|---|
| AWS CDK | cdk.json or aws-cdk-lib in deps |
| SST | sst.config.ts or sst in deps |
| Serverless Framework | serverless.yml or serverless.ts |
| AWS SAM | template.yaml with AWS::Serverless |
| Terraform / OpenTofu | .terraform/ or .tf files |
| Pulumi | Pulumi.yaml or @pulumi/* deps |
| CloudFormation | AWSTemplateFormatVersion in template |
| AWS Amplify Gen 2 | amplify/backend.ts or @aws-amplify/backend in deps |
Containers & Orchestration
| Tool | Detection |
|---|---|
| Kubernetes / Helm | Chart.yaml or K8s manifest directories |
| Docker Compose | docker-compose.yml or compose.yaml |
Configuration Management
| Tool | Detection |
|---|---|
| Ansible | ansible.cfg or standard role directory structure |
Detected frameworks are stored in config and used to improve symbol extraction and resolution. Routes, components, and lifecycle methods are extracted as first-class nodes in the graph.
Using with Kiro
kirograph install sets up four things in your Kiro workspace. All coexist, so you can switch between IDE and CLI freely. Kiro is the primary and fully supported target.
MCP Server (.kiro/settings/mcp.json)
Registers the KiroGraph MCP server with all 18 tools auto-approved. Used by both the IDE and the CLI agent.
{
"mcpServers": {
"kirograph": {
"command": "kirograph",
"args": ["serve", "--mcp"],
"autoApprove": [
"kirograph_search", "kirograph_context", "kirograph_callers",
"kirograph_callees", "kirograph_impact", "kirograph_node",
"kirograph_status", "kirograph_files", "kirograph_dead_code",
"kirograph_circular_deps", "kirograph_path", "kirograph_type_hierarchy",
"kirograph_architecture", "kirograph_coupling", "kirograph_package",
"kirograph_hotspots", "kirograph_surprising", "kirograph_diff"
]
}
}
}
IDE Auto-Sync Hooks (.kiro/hooks/)
| Hook file | Event | Action |
|---|---|---|
kirograph-mark-dirty-on-save.json | fileEdited | kirograph mark-dirty |
kirograph-mark-dirty-on-create.json | fileCreated | kirograph mark-dirty |
kirograph-sync-on-delete.json | fileDeleted | kirograph sync-if-dirty |
kirograph-sync-if-dirty.json | agentStop | kirograph sync-if-dirty --quiet |
Hooks fire for: .ts, .tsx, .js, .jsx, .py, .go, .rs, .java, .cs, .rb, .php, .swift, .kt, .dart, .ex, .exs
CLI Agent Config (.kiro/agents/kirograph.json)
A custom agent for Kiro CLI that wires up the MCP server and inlines steering instructions. Sync is handled at session boundaries:
| Event | Action |
|---|---|
agentSpawn | kirograph sync-if-dirty --quiet (catches edits made between sessions) |
userPromptSubmit | kirograph sync-if-dirty --quiet (keeps graph fresh within a session) |
stop | kirograph sync-if-dirty --quiet (deferred flush, mirrors IDE agentStop) |
kiro-cli --agent kirograph
# or, inside an active session:
/agent swap kirograph
Steering File (.kiro/steering/kirograph.md)
Teaches the Kiro IDE to prefer graph tools over file scanning when .kirograph/ exists. Uses inclusion: always so it's in context on every turn. The CLI agent has the same instructions inlined in its prompt field.
Other Tools (Experimental)
KiroGraph can also be installed for other MCP-capable coding agents. All targets share the same .kirograph/ data; if the project is already initialized, installing another target only writes that tool's integration files.
Claude Code
kirograph install --target claude
Writes .mcp.json (project-scoped MCP config), .kirograph/claude.md (tool guidance), and imports it from CLAUDE.md. Claude Code prompts for MCP approval the first time it sees .mcp.json.
Codex
kirograph install --target codex
Writes .kirograph/codex.md (tool guidance) and a generated block in AGENTS.md. Codex MCP configuration is user-scoped, so the installer prints the exact codex mcp add ... command instead of editing files outside the project.
Configuration
All configuration is in .kirograph/config.json. The interactive kirograph install writes this for you.
| Field | Type | Default | Description |
|---|---|---|---|
enableEmbeddings | boolean | false | Enable semantic (vector) search |
semanticEngine | string | "cosine" | Vector engine: cosine, sqlite-vec, orama, pglite, lancedb, qdrant, typesense |
embeddingModel | string | "nomic-ai/nomic-embed-text-v1.5" | HuggingFace model ID |
embeddingDim | number | 768 | Embedding dimension (auto-corrected on mismatch) |
enableArchitecture | boolean | false | Enable architecture analysis layer |
architectureLayers | object | — | Override layer glob patterns |
cavemanMode | string | "off" | Communication compression: off, lite, full, ultra |
syncWarningThreshold | number | 10 | Pending-file count above which kirograph_status warns. Set 0 to disable. |
extractDocstrings | boolean | true | Extract docstrings/comments during indexing |
trackCallSites | boolean | true | Track precise call-site locations |
exclude | string[] | — | Glob patterns to exclude from indexing |
Caveman Mode
Caveman mode compresses the agent's communication style, cutting token usage on responses without affecting tool calls or code output. Inspired by caveman by JuliusBrussee.
The rules are injected at session start via the steering file (IDE) and the inline agent prompt (kiro-cli), so they're always in context with no extra tool calls.
| Mode | Style |
|---|---|
off | Normal responses (default) |
lite | Compact, no filler, full sentences |
full | Fragments, no articles, short synonyms |
ultra | Maximum compression, abbreviations, → for causality |
Caveman mode never touches code blocks, file paths, URLs, or technical terms, only prose.
Auto-clarity exceptions: the agent temporarily reverts to normal prose for security warnings, confirmations of irreversible actions (delete, overwrite, force-push), and multi-step sequences where fragment order could cause misunderstanding. Compressed style resumes immediately after.
kirograph caveman lite # set mode
kirograph caveman # show current mode
Credits
Original idea
KiroGraph is inspired by CodeGraph by Colby McHenry. The original concept of building a semantic code graph for AI coding agents comes from his work.
Contributors
- Alessandro Franceschi: Claude Code and Codex integration, Elixir/Phoenix language and framework support.
- Mauro Argo: original idea for the architecture layer analysis feature.
Stargazers & Community
Thank you to everyone who contributed and starred the project on GitHub.