Hybrid AI Memory Layer: Local Knowledge Graph + AI-Powered Reasoning
Never lose context when switching AI coding agents. context-memo combines local code analysis (Graphify-style) with AI-powered task reasoning to create persistent memory that survives agent switches.
When working with AI coding agents (Claude, Cursor, Windsurf, Copilot, etc.) and your credits run out or you switch accounts β the new AI agent has ZERO memory of the project. You waste time and tokens re-explaining everything from scratch.
context-memo uses a hybrid approach:
-
Local Knowledge Graph (Graphify-style) β Zero-cost code understanding
- Analyzes imports, exports, functions, classes
- Maps dependencies and relationships
- Identifies "god nodes" (critical components)
- 100% private, runs locally
-
AI-Powered Reasoning (Gemini API) β Smart task continuation
- Understands project purpose and progress
- Tracks what works, what's broken, what's missing
- Provides exact continuation points
- Generates handoff messages
-
Incremental Updates β Minimal token usage
- Detects changed files using hashes
- Only sends changes to API (not full codebase)
- Saves 60-90% tokens on subsequent scans
- Local-only mode available (--local flag)
- π Local Knowledge Graph β Analyzes code structure without API calls
- π§ AI-Powered Reasoning β Uses Gemini for deep insights
- π Incremental Updates β Only scans changed files (saves 60-90% tokens)
- οΏ½ Privacy Mode β Local-only scanning (--local flag)
- π― Exact Continuation β Tells next agent exactly where to continue
- π Decision Log β Tracks key architectural decisions
- π€ Agent Integration β Works with Claude, Cursor, Windsurf, Copilot, Aider, etc.
- π Auto-Scan β Watch mode for active development
- π 100% free β Uses Gemini 2.5 Flash Lite API (no credit card needed)
- π° Token Efficient β Incremental scans save massive amounts of tokens
npm install -g context-memo# 1. Initialize in your project
memo init
# 2. Set your free Gemini API key
memo config --key YOUR_KEY
# 3. Scan your project
memo scan
# 4. Load the briefing (copies to clipboard)
memo loadPaste the briefing into your AI agent and it instantly understands your entire project.
- Visit: https://aistudio.google.com/app/apikey
- Click "Create API Key" (no credit card required)
- Copy your key
- Run:
memo config --key YOUR_KEY
Initialize .recall/ folder in your project with blank templates.
Scan entire project and generate memory.
Modes:
- First scan: Full analysis with AI
- Subsequent scans: Incremental (only changed files) β saves 60-90% tokens
- --quick: Faster scan with fewer files
- --local: Privacy mode (no API calls, local analysis only)
What it does:
- Builds local knowledge graph (imports, exports, dependencies)
- Detects changed files (incremental updates)
- Identifies "god nodes" (most critical components)
- Calls Gemini API (only for changes, or skip with --local)
- Generates comprehensive memory.yaml
Token optimization:
- First scan: ~15,000 tokens
- Incremental scan: ~2,000-5,000 tokens (60-90% savings!)
- Local mode: 0 tokens
Watch project and auto-scan on file changes.
- Monitors code files for changes
- Auto-scans 10 seconds after changes stop
- Uses incremental scanning (saves tokens)
- Perfect for active development
- Press Ctrl+C to stop
Load and display agent briefing (copies to clipboard).
full(default): Complete briefing (~2000 tokens)quick: Condensed briefing (~400 tokens)onboard: Full briefing + asks agent to confirm understanding
Show terminal dashboard with project status, progress, components.
Update task state and progress interactively.
Install context-memo integration for AI agents:
claudeβ.claude/CLAUDE.mdcursorβ.cursor/rules/context-memo.mdwindsurfβ.windsurf/rules/context-memo.mdcopilotβ.github/copilot-instructions.mdaiderβ.aider.conf.ymlantigravityβ.antigravity/rules.md
Configure settings (API key stored at ~/.recall/config.json).
context-memo uses a 3-layer hybrid architecture:
memo scan --local # No API calls- Parses all JS/TS files locally
- Extracts imports, exports, functions, classes
- Builds dependency graph
- Identifies "god nodes" (most connected files)
- Saves to
.recall/graph.json - Cost: $0 | Privacy: 100% local
memo scan # Automatic after first scan- Hashes all files (MD5)
- Detects changed/added/removed files
- Only sends changes to API (not full codebase)
- Reuses previous memory for unchanged parts
- Saves 60-90% tokens on subsequent scans
memo scan # First time or when changes detected- Sends: changed files + graph summary + previous memory
- Gemini analyzes: purpose, progress, issues, next steps
- Generates: comprehensive memory.yaml
- Smart token usage: only what's needed
- First scan:
memo scanβ ~15,000 tokens β Full analysis - Edit 3 files:
memo scanβ ~2,000 tokens β Incremental update (87% savings!) - No changes:
memo scanβ 0 tokens β Reuses cached memory - Privacy mode:
memo scan --localβ 0 tokens β Local-only analysis
.recall/memory.yaml contains:
- Project DNA: name, purpose, stack, constraints
- Knowledge Graph: components, dependencies, data flow, god nodes
- Progress: what works, what's broken, what's missing, tech debt
- Task State: last task, current problem, exact continuation point
- Decisions: key architectural decisions with reasoning
- Handoff Message: 4-6 sentence summary for new agents
# Day 1: Start project with Claude
memo init
memo scan
memo load # Paste into Claude
# ... work with Claude until credits run out ...
# Day 2: Switch to Cursor
memo update # Update progress
memo load # Paste into Cursor
# Cursor instantly knows everything!
# Day 3: Switch to Windsurf
memo load # Paste into Windsurf
# No re-explanation needed!- π³ Credits ran out β switch to different AI agent without losing context
- π₯ Team handoffs β new developer gets instant project understanding
- π Context switching β return to project after weeks away
- π€ Multi-agent workflows β use different agents for different tasks
- π Documentation β auto-generated project memory as documentation
your-project/
βββ .recall/
β βββ memory.yaml β Complete project memory
β βββ task_state.yaml β Current task state
β βββ decisions.log β Decision history
β βββ .gitkeep β Commit this folder!
- Run
memo scanafter major changes - Run
memo updatebefore switching agents - Use
memo watchduring active development for auto-updates - Commit
.recall/folder to git for team sharing - Use
memo statusfor quick project overview - Use
--quickflag for faster scans during development
memo watchAutomatically scans when you save files. Perfect for active development!
# Run setup script
bash setup-auto-scan.sh # Unix/Mac/Linux
setup-auto-scan.bat # WindowsAutomatically scans before every git commit. Great for keeping team memory in sync!
memo scanRun manually when you want to update the memory.
- Node.js (ES modules)
- Gemini 1.5 Flash API (free tier)
- commander, js-yaml, chalk, inquirer, clipboardy
- Node.js >= 18.0.0
- Free Gemini API key
MIT
Issues and PRs welcome!
Inspired by:
- Graphify (knowledge graphs for code)
- Agent handoff patterns
- The pain of losing AI context when switching agents
Never lose AI context again. One command. Instant understanding.