SAME Documentation
SAME (Stateless Agent Memory Engine) is a local-first persistent memory system for AI coding agents. It gives tools like Claude Code, Cursor, Windsurf, Codex CLI, and Gemini CLI the ability to remember decisions, context, and patterns across sessions. ~12MB Go binary. SQLite + vector embeddings (Ollama, OpenAI, or any compatible provider). Your data never leaves your machine.
Quickstart
Get running in minutes. No accounts, no API keys.
curl -fsSL statelessagent.com/install.sh | bash
Then explore the interactive demo:
same demo
Or start using it immediately with a project:
# Initialize SAME in your project directory
cd ~/my-project && same init
# Set up Claude Code integration (hooks + MCP)
same setup hooks
same setup mcp
# Start Claude Code — SAME activates automatically
claude
On your first session, SAME orients the agent with relevant context (~200 tokens). On your second session, it surfaces the handoff from the first. By session 10, your agent knows your architecture, your decisions, and your patterns.
No Ollama? SAME works without it. Semantic search requires Ollama, but keyword search (FTS5), session handoffs, decisions, and all core features work out of the box.
See the homepage for the interactive terminal demo showing SAME in action.
What's New in v0.12.0
- Memory integrity — Provenance tracking records where notes came from (file sources, SHA256 hashes). Trust states:
validated,stale,contradicted,unknown. Source divergence detection flags when source files change. - Trust-aware retrieval — Stale notes rank 25% lower, contradicted notes rank 60% lower. Trust state returned on all search results.
- 5 new MCP tools —
save_kaizen,mem_consolidate,mem_brief,mem_health,mem_forget(17 total). same healthcommand — Vault health score with trust analysis and recommendations.same kaizencommand — Continuous improvement tracking — log friction, bugs, and ideas with provenance.- Thinking model compatibility — Works with reasoning models like o1 and DeepSeek-R1. Thinking tokens are stripped automatically.
- Graph LLM enrichment — Use an LLM for richer knowledge graph extraction. Control with
SAME_GRAPH_LLMenv var.
Full changelog: CHANGELOG.md
Installation
curl -fsSL statelessagent.com/install.sh | bash
Other install methods
npm
npm install -g @sgx-labs/same
Windows (PowerShell)
irm statelessagent.com/install.ps1 | iex
Manual — macOS (Apple Silicon)
mkdir -p ~/.local/bin
curl -fsSL https://github.com/sgx-labs/statelessagent/releases/latest/download/same-darwin-arm64 -o ~/.local/bin/same
chmod +x ~/.local/bin/same
export PATH="$HOME/.local/bin:$PATH"
Manual — Linux (x86_64)
mkdir -p ~/.local/bin
curl -fsSL https://github.com/sgx-labs/statelessagent/releases/latest/download/same-linux-amd64 -o ~/.local/bin/same
chmod +x ~/.local/bin/same
export PATH="$HOME/.local/bin:$PATH"
Build from source
git clone --depth 1 https://github.com/sgx-labs/statelessagent.git
cd statelessagent && make install
Requires Go 1.25+ and CGO.
For semantic search, install Ollama separately. SAME pulls the nomic-embed-text model (~270MB) on first use. Total footprint under 300MB.
How It Works
SAME sits between your AI tools and a local knowledge vault. It indexes your markdown notes, captures decisions as you work, and surfaces relevant context at session start.
Session lifecycle
Three automatic phases drive the memory loop:
- Session Start — Loads vault context, registers this instance, detects other active instances, injects relevant decisions (~200 tokens), surfaces last session handoff.
- During Session — Agent-driven search via MCP. Zero auto-injection per prompt. The agent queries SAME only when it needs context. Zero tokens overhead per turn.
- Session End — Extracts new decisions, generates handoff summary, logs session to vault, deregisters instance. Graceful recovery if skipped.
Close the terminal early? Not a problem. Next session recovers from data the IDE already persists. The stop hook is not critical path.
Hooks vs MCP — two integration points
SAME connects to your AI tools in two complementary ways:
- Hooks are automatic triggers at session start and stop. They inject context and capture decisions without the agent doing anything. Currently supported by Claude Code.
- MCP (Model Context Protocol) provides on-demand tools the agent can call mid-session — search notes, save decisions, create handoffs. Works with any MCP client: Claude Code, Cursor, Windsurf, Codex CLI, Gemini CLI, and more.
Claude Code gets both (hooks + MCP) for the richest experience. Cursor, Windsurf, Codex CLI, and Gemini CLI use MCP only. Use same init --mcp-only to skip hooks.
Ranking — the 6-gate evaluation chain
Not every prompt needs context. SAME evaluates whether to surface anything at all through a 6-gate chain:
- Relevance gate — Is the prompt related to indexed knowledge?
- Distance threshold — Are the nearest embeddings close enough to matter?
- Composite scoring — Blend of semantic similarity, keyword overlap, and recency
- Gap detection — Is the best result meaningfully better than the second?
- Token budget — Does the result fit within the configured budget?
- Staleness check — Is the note fresh enough to be trustworthy?
~80% of prompts are correctly skipped. When SAME speaks, it matters.
Keyword-only mode
No embedding provider? SAME works out of the box with SQLite FTS5 keyword search. All core features work — session handoffs, decisions, pinned notes, context surfacing. Add Ollama, OpenAI, or any OpenAI-compatible provider when you want semantic search.
Key Concepts
What is a vault?
A vault is simply a directory of markdown files. It can be your project root, an Obsidian vault, a Logseq graph, or any folder containing .md files. When you run same init, SAME creates a .same/ subdirectory for its database and config — your existing files are never modified.
SAME auto-generates some files into your vault:
sessions/— session handoffs (auto-created at session end)decisions.md— structured decision log (auto-appended)
You can also write your own notes — architecture docs, patterns, research — and SAME will index and surface them when relevant.
## Use cursor-based pagination (not offset)
**Date:** 2026-01-15
**Context:** API pagination for transactions list
**Decision:** Cursor-based pagination using `created_at` + `id` composite key
**Rationale:** Offset pagination causes count(*) on large tables. Rejected after prod incident on 2026-01-12.
**Status:** Accepted
# Session Handoff: Auth Refactor
**Left off at:** Refresh token migration — routes done, middleware needs update
**Key files:** src/middleware/auth.go, src/routes/refresh.go
**Blockers:** Integration tests need new token fixtures
**Decisions made:** Context-based auth pattern (replacing header injection)
**Next steps:** Update middleware, add test fixtures, deploy to staging
What is MCP?
MCP (Model Context Protocol) is an open standard that lets AI tools call external tools. Think of it like a plugin system. SAME registers itself as an MCP server so your AI agent can search your notes, save decisions, and create handoffs — without you doing anything manually. Transport is stdio (no network server, no HTTP ports).
What is Ollama?
Ollama runs AI models locally on your machine. SAME uses it to convert your notes into numerical representations (embeddings) so it can find semantically similar content — not just keyword matches. For example, searching for "throttling" can find a note about "rate limiting."
Ollama is optional. Without it, SAME uses keyword search (SQLite FTS5). With it, you get semantic search. Install: brew install ollama on macOS, or see ollama.ai/download. SAME pulls nomic-embed-text (~270MB) automatically on first use.
Features
| Feature | Description | Ollama Required? |
|---|---|---|
| Semantic search | Find notes by meaning, not just keywords | Yes |
| Per-project vault isolation | Each project gets its own .same/ database, auto-detected | No |
| Knowledge graph | Relationship tracing across notes via same graph | No |
| Keyword search (FTS5) | Fast full-text search as fallback | No |
same ask | RAG chat with cited answers from your vault | Yes (chat model) |
| Session handoffs | Auto-generated summaries for the next session | No |
| Session recovery | Graceful recovery if terminal is closed early | No |
| Decision extraction | Auto-captures structured decisions from sessions | No |
| Pinned notes | Always-included notes in every session | No |
| Context surfacing | 6-gate chain for intelligent injection | No* |
| Push protection | Guard against accidental git pushes | No |
| MCP server (17 tools) | Agent-callable tools via MCP protocol | No* |
| Privacy tiers | Three-tier directory privacy structure | No |
| Cross-vault search | Federated search across multiple vaults | No* |
same demo | Interactive demo experience | No |
same tutorial | 7 hands-on lessons | No |
same doctor | Comprehensive diagnostic checks | No |
same web | Local web dashboard — browse, search, inspect | No |
* Semantic mode requires Ollama; keyword fallback is automatic.
Memory integrity
SAME tracks where knowledge comes from and whether it's still trustworthy:
- Provenance tracking — Records file sources and SHA256 hashes for every note. Know exactly where each piece of knowledge originated.
- Trust states — Each note carries a trust state:
validated,stale,contradicted, orunknown. - Source divergence detection — When source files change on disk, SAME flags affected notes as potentially stale.
Trust-aware retrieval
Search results are weighted by trust state. Stale notes rank 25% lower. Contradicted notes rank 60% lower. Trust state is returned on all search results so your agent can reason about knowledge quality, not just relevance.
Vault health: Run same health for a vault-wide trust analysis with provenance statistics and actionable recommendations.
CLI Reference
All commands are run as same <command>. Run same --help for the full list.
Setup
Commands you run once during initial setup:
.same/ directory and config. Use --mcp-only for Cursor/Windsurf/Codex CLI/Gemini CLI (skip hooks)..claude/settings.jsonSearch & Query
Find and retrieve knowledge from your vault:
Note Management
Create, pin, and organize notes in your vault:
Vault Management
Manage multiple vaults for different projects. Each project gets its own isolated database, auto-detected by directory:
Seed Vaults
Install pre-built knowledge vaults:
Knowledge Graph
Inspect and traverse relationships between notes, concepts, and decisions:
Configuration
Security & Guard
Push protection for multi-agent environments:
git push without a ticket)Maintenance & Utilities
--force drops and fully reconstructs from markdown files.--check queries latest releaseMCP Tools
SAME exposes 17 tools via MCP (Model Context Protocol). Your AI agent calls these tools on-demand to search, read, and write to your vault.
same mcp --vault /path/to/notes
Read tools (9)
| Tool | Description |
|---|---|
search_notes | Semantic search across your knowledge base |
search_notes_filtered | Search with domain/workstream/tag filters |
search_across_vaults | Federated search across multiple registered vaults |
get_note | Read full note content by path |
find_similar_notes | Discover related notes by similarity |
get_session_context | Pinned notes + latest handoff + recent activity |
recent_activity | Recently modified notes |
reindex | Re-scan and re-index the vault |
index_stats | Index health and statistics |
Write tools (4)
| Tool | Description |
|---|---|
save_note | Create or update a markdown note (auto-indexed) |
save_decision | Log a structured project decision |
create_handoff | Write a session handoff for the next session |
save_kaizen | Log improvement items (friction, bugs, ideas) with provenance tracking |
Memory management tools (4)
| Tool | Description |
|---|---|
mem_consolidate | Consolidate related notes into knowledge summaries via LLM |
mem_brief | Generate an orientation briefing from vault contents |
mem_health | Vault health score with trust state and provenance analysis |
mem_forget | Suppress a note from search results without deleting it |
MCP configuration examples
SAME registers itself automatically via same setup mcp. If you need to configure manually:
{
"mcpServers": {
"same": {
"command": "same",
"args": ["mcp", "--vault", "/path/to/your/notes"]
}
}
}
{
"mcpServers": {
"same": {
"command": "same",
"args": ["mcp", "--vault", "/path/to/your/notes"]
}
}
}
Write-side memory means your agent doesn't just consume context — it contributes back. Decisions, handoffs, and session notes are saved automatically.
Works With
| Tool | Integration | Experience |
|---|---|---|
| Claude Code | Hooks + MCP | Full automatic context + 17 MCP tools |
| Cursor | MCP | 17 MCP tools (use same init --mcp-only) |
| Windsurf | MCP | 17 MCP tools (use same init --mcp-only) |
| Codex CLI | MCP | 17 MCP tools (use same init --mcp-only) |
| Gemini CLI | MCP | 17 MCP tools (use same init --mcp-only) |
| Obsidian | Vault detection | Point SAME at your Obsidian vault — indexes directly |
| Logseq | Vault detection | Point SAME at your Logseq graph — indexes directly |
| Any MCP client | MCP server | 17 tools via stdio transport |
Configuration
Configuration lives at .same/config.toml in your vault root. Edit with same config edit.
[vault]
path = "/home/user/notes"
handoff_dir = "sessions" # where session handoffs are saved
decision_log = "decisions.md" # where decisions are logged
[ollama]
url = "http://localhost:11434" # must be localhost
[embedding]
provider = "ollama" # "ollama", "openai", "openai-compatible", "llama.cpp", "vllm", "lm-studio"
model = "nomic-embed-text" # embedding model name
[memory]
max_token_budget = 800 # max tokens injected at session start
max_results = 2 # max notes surfaced per query
distance_threshold = 16.2 # max embedding distance (lower = stricter)
composite_threshold = 0.65 # min composite score (higher = stricter)
[hooks]
context_surfacing = true # inject context at session start
decision_extractor = true # auto-extract decisions at session end
handoff_generator = true # auto-generate handoff at session end
feedback_loop = true # track note usefulness
staleness_check = true # flag outdated notes
Environment variables
Override config via environment. Priority order:
- CLI flags (
--vault) - Environment variables (
VAULT_PATH,OLLAMA_URL,SAME_*) - Config file (
.same/config.toml) - Built-in defaults
Full environment variable reference
| Variable | Description | Default |
|---|---|---|
VAULT_PATH | Path to markdown notes | Auto-detected |
OLLAMA_URL | Ollama API endpoint (localhost only) | http://localhost:11434 |
SAME_DATA_DIR | Database location | <vault>/.same/data |
SAME_HANDOFF_DIR | Handoff directory | sessions |
SAME_DECISION_LOG | Decision log path | decisions.md |
SAME_EMBED_PROVIDER | Embedding provider | ollama |
SAME_EMBED_MODEL | Embedding model name | nomic-embed-text |
SAME_EMBED_API_KEY | API key (for OpenAI provider) | — |
SAME_SKIP_DIRS | Extra directories to skip (comma-separated) | — |
SAME_NOISE_PATHS | Paths filtered from context | — |
Precision profiles
Tune how aggressively SAME surfaces context:
| Profile | Max Results | Threshold | Use Case |
|---|---|---|---|
precise | 2 | 0.75 | Fewer tokens, only highly relevant notes |
balanced | 2 | 0.65 | Default — good coverage without noise |
broad | 4 | 0.55 | ~2x tokens, thorough exploration |
Display modes
Control output verbosity during context surfacing:
| Mode | Command | Description |
|---|---|---|
| full | same display full | Box with titles, match terms, token counts (default) |
| compact | same display compact | One-line summary |
| quiet | same display quiet | Silent context injection (context still surfaces, just no output) |
Ollama URL is validated to localhost-only. SAME will reject any non-localhost URL to ensure embeddings never leave your machine.
Privacy & Security
Three-tier privacy structure
| Directory | Indexed? | Committed? | Purpose |
|---|---|---|---|
| Your notes | Yes | Your choice | Docs, decisions, research |
_PRIVATE/ | No | No | API keys, credentials, secrets |
research/ | Yes | No | Research, analysis — searchable but local-only |
Security hardening
- Local-only architecture — no outbound network calls from SAME
- Ollama localhost-only — embedding never leaves
127.0.0.1 - stdio-only MCP transport — no network ports opened, no HTTP server
- Path traversal blocked across all tools
- Dot-directory writes blocked
- Symlink escapes prevented
- Error messages sanitized — no internal paths leak
- Config files use owner-only permissions (
0o600) - Prompt injection patterns scanned before context injection
- No telemetry, no analytics, no phone-home
- No accounts, no signup, no API keys for SAME itself
- Vault files never modified — SAME never changes your existing notes
Clean uninstall: same guard uninstall removes the guard hooks. Delete the same binary from your PATH and rm -rf ~/.same/ to remove everything else. Your vault files (markdown) are never modified by SAME.
Troubleshooting
"No vault found"
- Run
same initfrom your notes folder - Set
VAULT_PATH=/path/to/notesexplicitly - Use
same vault add myproject /path/to/notes
"Ollama not responding"
- Check if Ollama is running:
curl http://localhost:11434/api/tags - Set a non-default port:
OLLAMA_URL=http://localhost:<port> - SAME falls back to keyword search automatically — this is not a blocker
Hooks not firing
- Run
same setup hooksto install - Verify with
same status - Check that
.claude/settings.jsonexists in your project root - Hooks are Claude Code only — Cursor/Windsurf/Codex CLI/Gemini CLI use MCP
Context not surfacing
- Run
same doctorfor full diagnostics - Run
same reindexto rebuild the index - Test with
same search "your query"to verify search works - Check display mode:
same display full(quiet mode hides output but still surfaces context)
"Cannot open SAME database"
- Run
same repair(backs up current DB automatically, then rebuilds) - Or
same initfor a fresh setup - Or
same reindex --forceto drop and rebuild the index - The database is a derived index — your markdown files are the source of truth and are never affected
FAQ
Do I need Obsidian?
No. Any directory of .md files works. Obsidian, Logseq, or just a folder of markdown.
Do I need Ollama?
Recommended but not required. Without Ollama, SAME falls back to FTS5 keyword search. You can also use OpenAI, llama.cpp, VLLM, LM Studio, OpenRouter, or any OpenAI-compatible server via SAME_EMBED_PROVIDER=openai-compatible.
Does it slow down my prompts?
50–200ms total, with embedding as the bottleneck. Search and scoring run under 5ms. Per-prompt overhead is zero tokens — the agent queries SAME via MCP only when it decides to.
Is my data sent anywhere?
No. Everything is fully local. Context surfaced to AI tools is sent as part of the normal conversation with your AI provider (same as if you pasted it manually). SAME itself makes zero network calls.
How much disk space?
5–15MB for a few hundred notes. The database is a derived index — delete it and same reindex, your notes are untouched.
Multiple vaults?
Yes. Register and switch between vaults:
same vault add work ~/work-notes
same vault add personal ~/personal-notes
same vault default work
What are seeds?
Pre-built knowledge vaults. Install one and your AI has expert-level context immediately. same seed list to browse, same seed install <name> to install. 17 seeds available with 870+ curated notes across technical and lifestyle domains, all free. Seeds grow smarter as you use them — your decisions and handoffs build on top of the seed knowledge.
Can I create my own seed?
Yes. Seeds are a community project. The seed-vaults repo includes a template with everything you need. Write markdown notes, add a CLAUDE.md for governance, and submit a pull request.
Can I switch embedding models?
same model use <name> switches models. 10 models supported from 384 to 1,536 dimensions. Run same reindex --force after switching.
Does SAME work with providers other than Ollama?
Yes. SAME supports any OpenAI-compatible embedding API. Set provider = "openai-compatible" in your config and point to llama.cpp, VLLM, LM Studio, or OpenRouter. Also supports the OpenAI API directly. 6 providers, no vendor lock-in.
Is my data sent to the cloud?
By default, no. SAME uses Ollama for fully local embeddings. If you choose an API provider (OpenAI, OpenRouter), embedding vectors are sent to that provider. Your raw notes never leave your machine regardless of provider.
How is this different from CLAUDE.md?
CLAUDE.md is a notepad you maintain manually (~200 lines). SAME captures decisions automatically, provides semantic search across hundreds of notes, coordinates multiple instances, generates handoff notes, and scores knowledge by freshness and confidence. SAME is a searchable, growing knowledge base that builds itself.
What is same web?
A local web dashboard that lets you browse, search, and inspect your vault in the browser. Run same web --open to launch. It's read-only, localhost-only, and makes no network calls. You can see every note, search with the same semantic engine MCP uses, and inspect index health — all in a UI.
Can I use SAME at work on commercial projects?
Yes. The BSL 1.1 license allows free use for individual developers and small teams. Source is available. The license converts to Apache 2.0 on 2030-02-02. Same model as MariaDB, CockroachDB, and HashiCorp.
Eval Methodology
All metrics are measured against a ground-truth eval harness, not estimated.
| Metric | Value |
|---|---|
| Retrieval precision | 99.5% (105 synthetic test cases) |
| Mean Reciprocal Rank | 0.949 (105 test cases) |
| Coverage (recall) | 90.5% |
| Prompt overhead | <200ms |
| Binary size | ~12MB |
| Setup time | Minutes |
Harness: 105 ground-truth test cases against a 273-note vault. Tuning constants: maxDistance=16.3, minComposite=0.70, gapCap=0.65.
When SAME surfaces context, it's almost always relevant. When it stays quiet, it's almost always right to. The eval methodology is published on GitHub — challenge it.
Community & Support
- Discord — community chat, support, feature requests
- GitHub Discussions — longer-form questions and ideas
- GitHub Issues — bug reports
- GitHub Sponsors
- Buy me a coffee
License
BSL 1.1 (source-available). Free for personal, educational, hobby, research, evaluation, and commercial use by individuals and small teams. Converts to Apache 2.0 on 2030-02-02. Same model as MariaDB, CockroachDB, HashiCorp.
Built with
Go · SQLite + sqlite-vec · Ollama / OpenAI