OpenMemory
Cross-agent persistent memory for AI coding assistants.
OpenMemory is a lightweight, persistent memory system that enables AI coding assistants to remember context across sessions, share knowledge between different agents, and retrieve relevant past decisions through semantic search.
Features
- Zero-Config SQLite Storage — Auto-discovers project root, stores in
.openmemory/memory.db - Cross-Agent Compatibility — Works with Claude Code, Kilo Code, Antigravity, GitHub Copilot, Cursor, Codex, and any tool with shell access
- Semantic Search — Hash-based embeddings for finding related entries without heavy ML dependencies
- Automatic Context Loading — Injects project history into prompts via plugins for OpenCode, Kilo Code, Claude Code, and Antigravity
- Simple CLI — Log, search, and retrieve context with intuitive commands
- Lightweight — No heavy dependencies, runs offline, no API keys required
Quick Start
Installation
pip install memosq
Usage
# Log a decision
memosq log \
--agent "claude-code" \
--action "refactored" \
--summary "Moved JWT validation to middleware" \
--files "src/auth.ts,src/middleware.ts" \
--decision "All auth logic should be centralized" \
--tags "auth,security,middleware"
# Search memory
memosq search --query "authentication changes" --limit 5
# Get project context
memosq context
# Show recent entries
memosq recent --limit 10
# Filter by topic
memosq topic --name "auth" --limit 10
# Initialize OpenMemory for a project (creates .openmemory/ + configs)
memosq init --all
# Initialize with specific agent configs
memosq init --with-claude --with-cursor --with-kilo --with-git
Auto-Mode (opencode Integration)
OpenMemory includes a plugin for opencode that makes memory management completely automatic:
- Session Start: Automatically loads project context
- During Chat: Logs user prompts and assistant responses
- File Changes: Tracks code modifications automatically
- No Commands Needed: The user never touches the CLI
Enable Auto-Mode
Add to ~/.config/opencode/opencode.jsonc:
{
"plugin": [
"opencode-orchestrator",
"memosq"
]
}
Auto-Mode (Kilo Code Integration)
Kilo Code is a fork of OpenCode and supports the same plugin system. OpenMemory includes a plugin for Kilo Code that makes memory management completely automatic:
- Session Start: Automatically loads project context
- During Chat: Logs user prompts and assistant responses
- File Changes: Tracks code modifications automatically
- No Commands Needed: The user never touches the CLI
Enable Auto-Mode
Add to ~/.config/kilo/kilo.jsonc:
{
"plugin": [
"opencode-orchestrator",
"/Users/ege/Desktop/fikir/openmemory/plugin/kilo-memory-plugin.js"
]
}
Auto-Mode (Antigravity Integration)
Antigravity is Google's AI coding agent with SDK support. OpenMemory includes hooks for Antigravity that make memory management completely automatic:
- Session Start: Automatically loads project context
- During Chat: Logs user prompts and assistant responses
- File Changes: Tracks code modifications automatically
- No Commands Needed: The user never touches the CLI
Enable Auto-Mode
from google.antigravity import Agent, LocalAgentConfig
from memosq.antigravity import OpenMemoryHooks
hooks = OpenMemoryHooks()
config = LocalAgentConfig(
hooks=hooks.get_hooks(),
policies=hooks.get_policies()
)
async with Agent(config) as agent:
response = await agent.chat("Hello")
Auto-Mode (Claude Code Integration)
Claude Code supports hooks that run automatically. OpenMemory includes hooks for Claude Code that make memory management completely automatic:
- Session Start: Automatically loads project context
- During Chat: Logs user prompts and assistant responses
- File Changes: Tracks code modifications automatically
- No Commands Needed: The user never touches the CLI
Enable Auto-Mode
Add to ~/.claude/settings.json:
{
"hooks": {
"SessionStart": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "memosq",
"args": ["context"],
"async": true
}
]
}
],
"UserPromptSubmit": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "memosq",
"args": ["log", "--agent", "claude-code", "--action", "user_prompt", "--summary", "{{prompt}}", "--tags", "prompt,claude"],
"async": true
}
]
}
]
}
}
Architecture
┌─────────────────────────────────────────────┐
│ AI Agent (Any) │
│ (Claude, Copilot, Cursor, Codex, etc.) │
└──────────────────┬──────────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ OpenMemory CLI / Plugin │
│ (scripts/memosq.py) │
└──────────────────┬──────────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ OpenMemory Core Library │
│ (memosq/__init__.py) │
│ │
│ • SQLite Storage │
│ • Semantic Search (Hash-based Embeddings) │
│ • Context Builder │
│ • Auto-discovery │
└──────────────────┬──────────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ .openmemory/memory.db │
│ (Shared across all agents in project) │
└─────────────────────────────────────────────┘
Data Format
Each memory entry contains:
{
"id": 1,
"timestamp": "2026-06-11T01:20:02",
"agent": "claude-code",
"action": "refactored",
"summary": "Moved JWT validation to middleware",
"files": "src/auth.ts,src/middleware.ts",
"decision": "All auth logic should be centralized",
"outcome": "success",
"tags": "auth,security,middleware",
"embedding": "[0.12, 0.05, ...]"
}
Semantic Search
OpenMemory uses a lightweight hash-based embedding system:
- No ML dependencies — No PyTorch, TensorFlow, or transformers
- Offline — Works without internet or API keys
- Fast — 128-dim vectors computed in microseconds
- Effective — Shared vocabulary creates overlap between related entries
For production use, you can swap in sentence-transformers by overriding the _generate_embedding method.
Best Practices
- Log decisions, not just actions — Include WHY, not just WHAT
- Use consistent tags — Makes filtering and searching effective
- Include file paths — Helps agents understand scope
- Search before assuming — Check if similar work was done before
- Update on failures — Log what didn't work and why
API Usage
from memosq import OpenMemory
# Initialize
memory = OpenMemory()
# Log an entry
memory.log(
agent="claude-code",
action="implemented",
summary="Added rate limiting to API endpoints",
files="src/middleware/rate-limit.ts",
tags="api,security,performance"
)
# Search
results = memory.search("authentication changes", limit=5)
# Get recent entries
recent = memory.recent(limit=10)
# Get project context
context = memory.get_context()
# Get entries by topic
topic = memory.get_topic("auth", limit=10)
Storage
Memory is stored in .openmemory/memory.db at the project root. The database is auto-discovered by:
- Looking for
.openmemory/in the current directory - Walking up the tree for
.git/or.openmemory/ - Using the first found project root
This means all agents working on the same project share the same memory automatically.
Commands
| Command | Description |
|---|---|
memosq log |
Create a new memory entry |
memosq search |
Semantic search across all entries |
memosq recent |
Show most recent entries |
memosq context |
Project summary and statistics |
memosq topic |
Filter by tag/topic |
memosq init |
Initialize OpenMemory for a project |
Initialize
Run memosq init once per project to set up automatic memory:
# Basic setup (creates .openmemory/ + database)
memosq init
# Setup with all supported agent configs
memosq init --all
# Setup with specific agents
memosq init --with-claude --with-cursor --with-kilo --with-git
What init creates:
.openmemory/directory withmemory.dbSQLite database--with-claude→.claude/settings.json(auto-log hooks)--with-cursor→.cursorrules(logging instructions)--with-kilo→kilo.jsonc+.kilo/rules/(config)--with-git→.git/hooks/post-commit(auto-log commits)--all→ Enables all of the above
Contributing
See CONTRIBUTING.md for details.
Changelog
See CHANGELOG.md for version history.
License
MIT — see LICENSE
Related
- opencode — AI coding assistant
- OpenMemory Plugin — Auto-mode for opencode
Made for agents, by agents. 🧠
Metadata
Release files for memosq 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| memosq-1.0.0.tar.gz | 21.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| memosq-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.3 kB
Release files / memosq-1.0.0.tar.gz
| Download URL | memosq-1.0.0.tar.gz |
|---|---|
| Size | 21.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92731d23a3fdb1b0962c21826dc73515e4d7ed7a8ca823b4fd88f3dab0c0a0c5
|
|
BLAKE2b-256 checksum How to use checksums |
70959e38a21202b2d814369ebcba51db5495347a04ab083e41173d478aecde05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / memosq-1.0.0-py3-none-any.whl
| Download URL | memosq-1.0.0-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b2691770134dca095ef65556a0585f2796ae5a5e2e7fa4e9a8738e65056d043c
|
|
BLAKE2b-256 checksum How to use checksums |
e26de082e36688baca7c6ebbe9ae3f3ad5b479d5a3585352bc2542b3a0b5b52a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|