Code
Knowledge Graph
for Claude CLI
Reduce token usage by 5-10x with intelligent, graph-aware code retrieval. Fully local. Zero config. No API keys.
$ rg "authentication" --files-with-matches
src/auth/middleware.py
src/auth/tokens.py
src/api/views.py
src/api/permissions.py
... 8 more files
$ cat src/auth/middleware.py # 200 lines
$ cat src/auth/tokens.py # 150 lines
$ cat src/api/views.py # 300 lines
~8,000 tokens consumed $ search_code("authentication middleware")
auth/middleware.py:15 — AuthMiddleware
class AuthMiddleware(BaseHTTPMiddleware)
lines: 15-45
calls: verify_token, get_user
auth/tokens.py:8 — verify_token
def verify_token(token: str) -> User
lines: 8-22
~800 tokens consumed Why Avicenna?
A smarter way for Claude to understand your codebase — semantic search, dependency graphs, and architectural advice in one MCP extension.
Semantic Code Search
Natural language queries instead of regex. Ask for 'authentication middleware' and get precise results with file paths and line numbers.
Dependency Analysis
Trace what any file or symbol depends on, and what depends on it. Impact analysis before refactoring — in a single tool call.
Advisor Skills
Built-in guidance for Django, React, SOLID principles, and design patterns. Extensible with custom SKILL.md files.
Fully Local & Free
No API keys, no Ollama, no external services. FastEmbed runs on CPU. LanceDB and SQLite are file-based. Everything stays on your machine.
Per-Repo Isolation
Each repository gets its own isolated knowledge graph. Index multiple repos in parallel with no cross-contamination.
Token Savings
5-10x reduction in exploration tokens. Returns signatures and line numbers instead of full source files. Built-in metrics tracking.
Use Cases
Real workflows where Avicenna saves time and tokens.
Semantic Code Search
Search for "authentication middleware" across a Python project and instantly find the relevant functions by meaning, without knowing exact file names or function names.
Pre-Refactoring Impact Analysis
Before refactoring a utility function, run find_symbol and get_dependents to see every file and function that depends on it.
Onboarding to Unfamiliar Codebases
Index a new TypeScript monorepo and use get_file_summary to quickly understand the structure of unfamiliar files without reading their full contents.
Keeping Search Fresh After Edits
After making edits to several files, call refresh_index to update the knowledge graph, then use search_code to verify your changes are reflected.
Understanding Code Dependencies
Use get_dependencies to trace what a module imports and calls, helping you understand unfamiliar code before making changes.
12 MCP Tools
Everything Claude needs to navigate your codebase — nothing it doesn't.
Code Exploration
search_code Semantic search across indexed code by meaning
find_symbol Find function/class/variable with dependency graph
get_dependencies What a file or symbol imports, calls, or extends
get_dependents Reverse dependencies — what depends on a target
get_file_summary Structural summary without reading full contents
index_repository Parse and index a codebase (incremental support)
refresh_index Re-index only files changed since last run
Architecture Advice
advise Best-practice advice matched by semantic similarity
list_skills List all loaded advisor skills with metadata
Analytics
index_status Indexing stats: file count, entities, languages
usage_stats Token savings report with daily breakdown
cancel_indexing Cancel a currently running indexing operation
Advisor Skills
Built-in knowledge about frameworks, principles, and patterns — extensible with your own SKILL.md files.
django framework Django architecture, views, models, ORM optimization, DRF, testing, and security best practices.
react framework React patterns, hooks, component design, state management, performance optimization, and TypeScript integration.
solid-principles principle SRP, OCP, LSP, ISP, and DIP explained with real Python and TypeScript code examples.
strategy-pattern pattern Strategy pattern: when to use, Python and TypeScript implementations, comparison with other behavioral patterns.
Skill Discovery Locations
{repo}/.avicenna/skills/
Team-specific overrides
priority +20~/.avicenna/skills/
User-installed skills
priority +10Built-in
Ships with Avicenna
priority +0SKILL.md Format
---
name: my-framework
description: Best practices for...
category: framework
domains: [django, python, orm]
triggers: ["django views", "manage.py"]
priority: 50
depends-on: [solid-principles]
---
# My Framework Guide
Markdown body with best practices... Get Started in 60 Seconds
Zero config. No API keys. Just install, init, and go.
Install as Plugin (Recommended)
$ /plugin install avicenna@claude-plugins-official Run this inside Claude Code. That's it — Avicenna tools are immediately available in all your projects.
Or Install from Source
$ git clone https://github.com/smrf1093/Avicenna.git
$ cd Avicenna
$ python -m venv .venv && source .venv/bin/activate
$ pip install -e .
$ python -m avicenna init /path/to/your/project Registers the MCP server, indexes your codebase, and creates a CLAUDE.md — all in one command.
Use
$ cd /path/to/your/project && claude Avicenna tools are now available. Try asking Claude to search your code or analyze dependencies.
Supported languages
How It Works
From source code to intelligent responses — no cloud services required.
Embeddings generated locally by FastEmbed on CPU
LanceDB (vectors) + SQLite (graph + state)
Each repo gets ~/.avicenna/repos/{hash}/
SHA-256 content hashes detect only changed files
Project Structure
src/avicenna/
config/ Pydantic settings from .env
models/ 6 DataPoint subclasses
parser/ tree-sitter engine + language queries
indexer/ File discovery, hashing, incremental state
graph/ SQLite + LanceDB engines, search, ingestion
advisor/ Skill registry, matching, formatting
server/ FastMCP server + tool implementations
stats/ Token savings tracker Token Savings
Real metrics from actual usage — not theoretical estimates.
Token savings measured over 7 days of real use
=== Avicenna Token Savings Report ===
Period: Last 7 day(s)
Total tool calls: 47
Avicenna tokens: 3,842
Traditional est.: 28,650
Tokens saved: 24,808
Savings: 86.6% Task-by-Task Comparison
Finding a function
3-5 grep calls + 2-3 file reads
~4,000 tokens
1 find_symbol call
~400 tokens
Understanding dependencies
grep imports + read 4 files
~6,000 tokens
1 get_dependencies call
~600 tokens
Exploring a module
ls + read 5 files
~10,000 tokens
1 get_file_summary call
~500 tokens