Skip to main content

Persistent hybrid-search memory store for Claude Code (Free Edition)

Project description

N3MemoryCore (N3MC)

A NeuralNexusNoteโ„ข product

๐Ÿ›ก๏ธ AI-Native Development Policy This project prioritizes Instructions over Static Code. Please read our Development Philosophy to understand why you should let AI generate your execution environment.

๐Ÿ‡ฏ๐Ÿ‡ต Click here for the Japanese Documentation (ๆ—ฅๆœฌ่ชž็‰ˆ) ๐Ÿ›ก๏ธ Development Philosophy & AI-Native Policy

I know Java and C#, but Python is completely new to me. The code Claude Code generated โ€” I built it without fully understanding it.

But I tested it, refined the specification, rebuilt it, and shipped both Japanese and English versions โ€” Free and Pro.

Because if I could do it, so can you.

The first draft of the specification was written by Copilot. Claude Code turned it into working code. Gemini reviewed it. Iterated across three AIs โ€” that process is N3MemoryCore.

N3MemoryCore gives Claude Code long-term memory across sessions. Two install paths supported: drop the spec into Claude Code and let it build the system, or pip install the reference build and run n3mc --init. Either way, no manual hook editing. (See Setup below.)


Features

  • ๐Ÿ’พ Fully local โ€” Your conversations stay on your machine. Nothing sent to the cloud.
  • ๐Ÿ” Semantic search โ€” Finds relevant past conversations even when the exact words differ. Multilingual by default (intfloat/multilingual-e5-base) โ€” works for Japanese, English, Chinese, Korean, and ~100 other languages out of the box. Swap to a language-specialised model via config.json if you need higher single-language precision.
  • ๐Ÿ”„ Persistent across sessions โ€” Pick up tomorrow where you left off today.
  • โšก Works automatically โ€” Saving and searching happen automatically. No manual steps needed.
  • ๐Ÿค– Multi-agent ready โ€” Multiple AI agents share one memory DB. Each agent prioritizes its own memories while accessing the team's collective knowledge.
  • ๐Ÿข Team & organization support โ€” Deploy the server on your network and share memories across your entire team.
  • ๐Ÿ”— DB merge ready โ€” Databases built from the same specification are fully compatible. Transfer knowledge when handing off roles, or import memories accumulated in other environments โ€” the DB structure is designed for integration from the ground up.
  • ๐Ÿ’ฐ Reduces token waste โ€” No more re-explaining past context. Memory search uses local embeddings (zero Claude tokens), and accurate context injection means fewer corrections and back-and-forth.

How It Works

User's message
    โ”‚
    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  1. Auto-save โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚ 2. Semantic   โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚ 3. Context    โ”‚
โ”‚  Save last    โ”‚     โ”‚    search     โ”‚     โ”‚    injection   โ”‚
โ”‚  response     โ”‚     โ”‚  Find related โ”‚     โ”‚  Feed to       โ”‚
โ”‚  to DB        โ”‚     โ”‚  memories     โ”‚     โ”‚  Claude        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                 โ”‚
                                                 โ–ผ
                                          Claude responds
                                          with full context

Powered by Claude Code's hook system. Everything happens automatically โ€” no user action required.

Relationship with Claude's built-in auto-memory

Claude Code has a built-in auto-memory system (~/.claude/projects/.../memory/). N3MemoryCore complements it rather than competing with it.

Claude auto-memory N3MemoryCore RAG
Strengths Reliable, loads every session, great for fixed facts Conversation context, detailed history
Weaknesses Cannot capture conversation flow or context Depends on search quality; not guaranteed to surface
Best for User profile, folder paths, stable settings Conversation threads, past decisions, reasoning

Recommended usage:

  • Fixed information needed every session (folder paths, user preferences) โ†’ save to auto-memory
  • Conversation context and history (discussion threads, past decisions) โ†’ N3MemoryCore accumulates automatically

Free vs Pro

Free Pro
Core features (save, search, auto) โœ… โœ…
Refresh (dedup & update) - โœ… Auto-replaces outdated memories
Session/environment bias - โœ… Prioritizes recent & local context
GC (garbage collection) - โœ… Auto-cleanup of old memories
Import/Export - โœ… Data migration & sharing
Delete - โœ… Individual record deletion

Start with Free. You can upgrade to Pro later using the Upgrade specification.

Specification Files

File Description
N3MemoryCore_v1.2.0_Free_JP.md Free edition (Japanese)
N3MemoryCore_v1.2.0_Free_EN.md Free edition (English)

๐Ÿ’ก A note on annotations in the specification Throughout the specification file (Markdown), you'll find annotations describing the design intent behind each instruction โ€” written to give you precise control over AI behavior. Before having Claude generate the code, take a moment to read through them. They contain more than just code: the logic behind how to work with AI effectively.

Setup

There are two supported setup paths. Pick whichever fits your style.

Path A โ€” AI-Native Setup (canonical)

  1. Pick a specification file from the table above
  2. Drop the file into the Claude Code prompt
  3. Say: "Please implement this."

That's it. Claude Code writes the code, configures the hooks, and sets everything up. Setup takes roughly 15โ€“30 minutes (varies by environment and model). Memory kicks in from the next session.

Path B โ€” Quick Start with pip

If you'd rather skip the AI implementation step and use the reference build directly:

1. Install

git clone https://github.com/NeuralNexusNote/n3mc-free.git
cd n3mc-free
pip install -e .          # or  pip install .

Requirements: Python 3.10+. The first server start will download the embedding model (intfloat/multilingual-e5-base, ~470 MB) โ€” expect a 2โ€“10 minute one-time delay.

2. Connect to Claude Code

n3mc --init

This single command does everything needed to wire N3MC into Claude Code:

  • Creates ~/.n3mc/ (data lives here โ€” DB, config, audit log, PID file).
  • Writes ~/.n3mc/config.json with auto-generated owner_id / local_id.
  • Registers the UserPromptSubmit and Stop hooks in your user-global ~/.claude/settings.json, pointing to the installed n3mc-hook / n3mc-stop-hook entry-point scripts. The "user-global" location is essential โ€” it means hooks fire from any project directory, not just this repo.

The command is idempotent: re-running it is safe and won't create duplicates.

3. Verify the hook registration

Run this one-liner โ€” it should print OK:

python -c "import json,os; s=json.load(open(os.path.expanduser('~/.claude/settings.json'))); h=s.get('hooks',{}); assert any('n3mc' in c.get('command','').lower() for e in h.get('UserPromptSubmit',[]) for c in e.get('hooks',[])), 'UserPromptSubmit hook missing'; assert any('n3mc' in c.get('command','').lower() for e in h.get('Stop',[]) for c in e.get('hooks',[])), 'Stop hook missing'; print('OK')"

If you see OK, the hooks are registered correctly. If you see an AssertionError, re-run n3mc --init.

4. Restart Claude Code

Close every running Claude Code session (terminal CLI windows, IDE extensions like VS Code's "Claude Code" panel, etc.) and start a fresh one. Hooks are read at session startup; sessions started before n3mc --init will not pick up the new hooks.

5. Confirm it's working

In a fresh Claude Code session, send any message. After Claude responds, run:

n3mc --list

You should see at least two records โ€” one with a [user] prefix (your message) and one with a [claude] prefix (Claude's response). If the list is empty, jump to Troubleshooting below.

Optional: change where data lives

Override the data location by setting N3MC_HOME=/path/to/dir before running n3mc --init (the chosen path is then permanent for that install).


Troubleshooting (Path B)

n3mc: command not found after pip install Your Python Scripts/ (Windows) or bin/ (macOS/Linux) directory is not on PATH. Either add it to PATH, or invoke as python -m n3memorycore.n3memory --init instead.

--list shows zero records after a real conversation You opened the Claude Code session before running n3mc --init. Close it completely and open a new session โ€” hooks are loaded at session start.

Hooks register, but nothing saves Check the audit log:

cat ~/.n3mc/.memory/audit.log | tail -3

Each user prompt should produce one JSON line. If the file is empty, the hooks aren't firing โ€” confirm Step 3's verification command prints OK, and confirm ~/.claude/settings.json (user-global, not project-local) was the file modified.

n3mc --search returns nothing the first time, but works after The intfloat/multilingual-e5-base model is downloading (~470 MB) on the first call. Wait 2โ€“10 minutes for the download to finish, then retry.

What to expect after setup

Once setup is complete, everything works automatically from the next session:

  • Past conversations relevant to your current message are retrieved and injected automatically
  • Claude responds with full context ("Regarding what we discussed last time...")
  • Saving and searching happen in the background โ€” no action needed on your part

Backup and restore

To migrate memories to another environment or keep a safe backup, save these 2 files from ~/.n3mc/:

  • .memory/n3memory.db โ€” the memory database
  • config.json โ€” contains owner_id and local_id UUIDv4 keys

These 2 files must be kept together. If the keys don't match, owner verification will fail.

Uninstall

pip uninstall n3memorycore-free
rm -rf ~/.n3mc/                                      # delete data (irreversible)
# Then manually remove the hook entries from ~/.claude/settings.json.

Or, if you set up via Path A, ask Claude Code: "Please uninstall N3MemoryCore."

ID Hierarchy

N3MemoryCore uses 5 ID fields to identify the origin and context of each record:

ID Stored in Generated Granularity Purpose
id (PK) DB record Per record (UUIDv7, time-ordered) One record Unique identifier for each memory โ€” used for deletion and dedup
owner_id config.json First startup (UUIDv4) Owner / N3MC server Identifies whose data this is โ€” for shared/multi-user scenarios and import provenance
session_id In-memory or supplied by host Per task / project / conversation (UUIDv4) Task / project / conversation Groups memories that belong to one task / project / conversation. In Free, drives the b_session ranking bias (match=1.0, mismatch=0.6) so the ongoing exchange ranks above unrelated past sessions
local_id (agent_id) config.json / API First startup (UUIDv4), or per request Agent / install UUIDv4 identifier for the speaking agent. Each agent gets its own UUID in multi-agent setups (in Free, stored but not used in ranking; b_local is a Pro feature)
agent_name DB record Per buffer call (free-form string) Agent display name Human-readable label for the agent (e.g. "claude-code")
owner_id  (one N3MC server / data owner)
  โ””โ”€โ”€ session_id  (one task / project / conversation)
        โ””โ”€โ”€ local_id  (the speaking agent within that session)
              โ”œโ”€โ”€ agent_name  (its display name: "claude-code", etc.)
              โ””โ”€โ”€ id  (one memory record)

Requirements

  • Claude Code (required)
  • Python 3.10+
  • OS: Windows 11 (tested) / macOS and Linux (designed for, but not yet verified)

To check if Python is installed, run python --version in your terminal. If missing, Claude Code will guide you during setup.

Extensibility

N3MemoryCore is built from a specification, so extending it is as simple as asking Claude Code.

  • MCP server โ€” Expose N3MC as an MCP server so other AI tools can access the memory
  • PostgreSQL migration โ€” Move from SQLite to PostgreSQL + pgvector for team-scale deployments
  • Custom search logic โ€” Tune bias coefficients and ranking formulas
  • Alternative embedding models โ€” Swap in a different model to suit your use case
  • Custom ID fields โ€” Add fields like project_id or tag to organize memories your way
  • PDF import โ€” Extract text from PDF files and store them as searchable memories
  • Hashtag support โ€” Claude auto-tags memories with #hashtags for filtered search (e.g. --search "#AWS") โ€” works with existing FTS, no DB changes needed

Just load the specification into Claude Code and say what you want to add.

โš ๏ธ Disclaimer

  • No support, no claims: This project is provided as-is with no support. Questions, bug reports, and feature requests are not guaranteed a response. Use entirely at your own discretion.
  • Use at your own risk: This system runs on AI-generated code. The author is not responsible for any data changes or issues caused by its use.
  • Backup first: Always back up your current environment before running this on important projects.

Apache License 2.0 โ€” Copyright (C) 2026 NeuralNexusNoteโ„ข / ArnolfJp019 See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

n3memorycore_free-1.3.1.tar.gz (42.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

n3memorycore_free-1.3.1-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file n3memorycore_free-1.3.1.tar.gz.

File metadata

  • Download URL: n3memorycore_free-1.3.1.tar.gz
  • Upload date:
  • Size: 42.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for n3memorycore_free-1.3.1.tar.gz
Algorithm Hash digest
SHA256 862ba0a706b99aaa010da83599bf18db7fb2042b0cdd9ce11bc414905940853c
MD5 d7e14dce11f1a50cee1465f0d0f0bc98
BLAKE2b-256 4ce03a230e2b441bc35b63395b6d201e7241f5445f959c8390a5826492ec5dc5

See more details on using hashes here.

File details

Details for the file n3memorycore_free-1.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for n3memorycore_free-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c108e6cc4d18d8421671287509d54305e09efd90e4dadcf5fe0101dca04ce2a
MD5 1c13b140a52e606981f92826d7ccdf16
BLAKE2b-256 f10869b2f49bb27c57b67c6129ff60df6f7b96424fb17ce051f205d4c0cea6ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page