Skip to main content

AI-Memory

Stop burning API tokens on file-by-file exploration. AI-Memory builds a self-updating knowledge graph of your entire codebase so your AI assistant answers instantly — with full context — instead of asking "can you show me that file?" repeatedly.

Before: You ask AI a question → AI opens 5 files → 8,000 tokens → still confused
After:  AI-Memory knows your code → AI queries the graph  → 500 tokens  → precise answer

The Problem (You Know This Pain)

You ask your AI assistant: "How do I add pagination to the user list?"

Step What AI Does Tokens
1 Opens routes.py, reads 200 lines 1,500
2 Opens models.py, reads 150 lines 1,200
3 Opens controllers.py, reads 300 lines 2,400
4 Asks "Can you show me the User model?" —
5 You paste it 500
6 Re-reads everything again 2,500
Total ~8,000 tokens

With AI-Memory: AI runs one internal query and gets list_users(self, db, skip=0, limit=100) with full body, types, and callers. 500 tokens. One shot. Correct answer.

How It Works

Engine What It Does
Scan Tree-sitter parses Python, JS/TS, Ruby, Go, Rust, Java, C#, C/C++, SQL
Graph Functions, classes, imports, calls, inheritance in SQLite
Import Resolution Cross-file imports resolved to real symbol definitions
Execution Flows Pre-computed call chains from every entry point
Communities Auto-detected code modules by directory + graph coupling
Semantic Search sentence-transformers embeddings: find login_user from "auth"
Type & Body Storage Full function bodies and type annotations cached
Watch Incremental updates on every file save

Supported Languages

Backend Frontend Systems Data & Config Manifests
Python JavaScript C SQL requirements.txt
Go TypeScript C++ YAML package.json
Rust JSX C# JSON Cargo.toml
Java TSX TOML pyproject.toml
Ruby Protobuf go.mod
GraphQL

DB Schemas: Table, index, column extraction from SQL and migration files.


Supported IDEs

IDE Integration Setup Required
Windsurf .windsurfrules auto-generated None — AI reads instructions automatically
Cursor .cursorrules auto-generated None — AI reads instructions automatically
Claude Desktop MCP server ai-memory-mcp One JSON config
VS Code MCP server or CLI Terminal or extension

After ai-memory init, your AI already knows about the graph. Zero IDE configuration.


Get Started (3 Commands)

# 1. Install
cd your-project
pip install ai-memory

# 2. Initialize — config, DB, gitignore, IDE rule files
ai-memory init

# 3. Scan your codebase — one time
ai-memory scan

Optional:

# Enable semantic search (~2 min one-time)
ai-memory embed

# Auto-update on file changes (background daemon)
ai-memory watch

What Happens After Init

your-project/
├── .ai-memory/           # Graph database (gitignored automatically)
│   └── graph.db          # SQLite: ~380 symbols, ~1850 relations, 34 deps
├── .ai-memory.toml       # Your project config
├── .windsurfrules        # Windsurf: "Use ai-memory for context"
├── .cursorrules          # Cursor: "Use ai-memory for context"
└── .gitignore            # Auto-added: .ai-memory/

CLI Commands

Core Workflow

Command Description
init Create config, DB, gitignore entry, IDE rule files
scan Full codebase scan + post-processing
watch Auto-incremental update on file changes
embed Build semantic embeddings for all symbols
embed --incremental Only new/changed symbols

Symbol Context

Command Description
context <symbol> Symbol + body + types + neighbors
callers <symbol> Reverse call graph — who calls this
inherits <class> Full inheritance chain

Search & Discovery

Command Description
ask "<question>" Natural language → compact context
semantic "<query>" Embedding-based semantic search
search "<query>" Full-text search over names, signatures, docstrings
find <name> Search symbols by name

Analysis

Command Description
stats Project overview (files, nodes, edges, top hubs)
flows Pre-computed execution flows from entry points
communities Detected code modules/clusters
cycles Circular dependencies
dead-code Unused symbols (zero incoming references)
api Public API surface from __init__.py, index.js, lib.rs
todos TODO, FIXME, HACK, XXX markers
test-map Map tests to implementation

Dependencies & Coverage

Command Description
deps List dependencies from manifests
coverage Load coverage data and show summary
coverage-detail Per-symbol coverage status

Export

Command Description
graph [symbol] Mermaid or DOT call graph
file <path> Summary of a single file
schemas All DB schemas / migrations
review Git diff impact analysis

MCP Server (Native IDE Integration)

For Claude Desktop, Windsurf, Cursor:

ai-memory-mcp --root /path/to/project

20 exposed tools: ai_memory_scan, ai_memory_stats, ai_memory_context, ai_memory_ask, ai_memory_semantic, ai_memory_flows, ai_memory_communities, ai_memory_schemas, ai_memory_find, ai_memory_dead_code, ai_memory_callers, ai_memory_todos, ai_memory_test_map, ai_memory_graph, ai_memory_cycles, ai_memory_inherits, ai_memory_api, ai_memory_search, ai_memory_coverage, ai_memory_deps.


Configuration

Edit .ai-memory.toml to customize:

scan_dirs = ["src", "app", "lib"]
extensions = [".py", ".js", ".ts", ".go", ".rs"]
ignore_patterns = ["node_modules", "venv", "__pycache__"]
output_format = "markdown"
max_context_tokens = 4000

Architecture

Source Code
    │
    ▼
Tree-sitter Parsers (Python, JS/TS, Go, Rust, Java, C#, C/C++, Ruby)
    │
    ▼
Symbol Extractor ──→ Symbols (functions, classes, imports)
│                     Body Extractor ──→ Full function bodies
│                     Type Extractor ──→ Type annotations
│
Relation Extractor ──→ Calls, Inherits, Imports
    │
    ▼
Import Resolver ──→ Cross-file links resolved
    │
    ▼
SQLite Graph DB ──→ nodes, edges, files, schemas, flows, communities
    │
    ▼
┌─────────────────┬─────────────────┬─────────────────┐
│  Semantic       │  Execution      │  Community      │
│  Embeddings     │  Flows          │  Detection      │
│  (MiniLM)       │  (BFS from      │  (Leiden        │
│                 │   entry points) │   algorithm)    │
└─────────────────┴─────────────────┴─────────────────┘
    │
    ▼
CLI / MCP Server / Watch Daemon
    │
    ▼
AI Assistant (Windsurf, Cursor, Claude Desktop)

Metadata

Release files for codebase-memory 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codebase-memory 0.1.2
File Size Uploaded
codebase_memory-0.1.2.tar.gz 54.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codebase-memory 0.1.2
File Interpreter ABI Platform
codebase_memory-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 117.8 kB

Release files / codebase_memory-0.1.2.tar.gz

Download URL codebase_memory-0.1.2.tar.gz
Size 54.4 kB
Tags Source
SHA-256 checksum
How to use checksums
20353edfda27b3dc6f2cc5e0773e26fe656c26faf3f5ee38494745d27b53f098
BLAKE2b-256 checksum
How to use checksums
68363b18212746f0a270ea9a0ef5fdd5439e37662afc366d88761218a25a18bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2026.

Transparency log

Release files / codebase_memory-0.1.2-py3-none-any.whl

Download URL codebase_memory-0.1.2-py3-none-any.whl
Size 63.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9662de6a68f18286e68cc9174e9b5dde7d93bd2b60bc65b11eeff9472a9d5858
BLAKE2b-256 checksum
How to use checksums
1aa0690211b353d7e993784eb1bd127aae1cb7ae83f5a700cefc59f465f90df4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page