Adding Persistent Memory to Claude Code with claude-mem —…
    Neura MarketNeura Market/DeepSeek
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsGamesBlogVideosGuidesCoursesCommunityTrending
    DeepSeekBlogAdding Persistent Memory to Claude Code with claude-mem — Plus a DIY Lightweight Alternative
    Back to Blog
    Adding Persistent Memory to Claude Code with claude-mem — Plus a DIY Lightweight Alternative
    claudecode

    Adding Persistent Memory to Claude Code with claude-mem — Plus a DIY Lightweight Alternative

    kanta13jp1 April 13, 2026
    0 views

    The Problem: Claude Code Forgets Everything Every time you start a new Claude Code...

    The Problem: Claude Code Forgets Everything

    Every time you start a new Claude Code session, the slate is wiped clean. Your coding style preferences, project architecture decisions, yesterday's debugging session — all gone.

    You end up repeating yourself: "We use Supabase, not Firebase. The Edge Functions are in supabase/functions/. Don't use dummy data."

    claude-mem fixes this by adding persistent memory across sessions. It hit 46K GitHub stars within 48 hours of launch. I installed it, built a lightweight DIY alternative first, and here's what I found.

    What is claude-mem?

    GitHub: https://github.com/thedotmack/claude-mem

    A plugin that gives Claude Code a long-term memory. It automatically captures what you do during sessions and injects relevant context into future conversations.

    Architecture

    • 5 Lifecycle Hooks: SessionStart / UserPromptSubmit / PostToolUse / Stop / SessionEnd
    • SQLite + Chroma: Hybrid search (keyword + vector similarity)
    • Bun HTTP Worker: Background service on localhost:37777
    • MCP Tools: 3-layer progressive disclosure (search → timeline → get_observations)
    • Web UI: Visual memory browser

    Installation

    npx claude-mem install
    npx claude-mem start  # Requires Bun
    

    The DIY Alternative I Built First

    Before discovering claude-mem, I built a minimal memory system using just two PowerShell scripts and Claude Code's native hooks API.

    PostToolUse Hook (auto-capture.ps1)

    Triggered after every Bash or Write tool use. Captures git commits and new file creations to a daily markdown file:

    memory/auto-capture/2026-04-13.md
    - 09:15 [abc1234] feat: Add user authentication
    - 09:32 [Write] auth_middleware.dart
    - 10:01 [def5678] fix: Token refresh logic
    

    SessionStart Hook (session-resume.ps1)

    Reads the last 3 days of captures and injects them as context when a new session starts. The AI immediately knows what you've been working on.

    Registration in settings.json

    {
      "hooks": {
        "PostToolUse": [{
          "matcher": "Bash|Write",
          "hooks": [{
            "type": "command",
            "command": "powershell -File auto-capture.ps1"
          }]
        }],
        "SessionStart": [{
          "hooks": [{
            "type": "command",
            "command": "powershell -File session-resume.ps1"
          }]
        }]
      }
    }
    

    Head-to-Head Comparison

    Featureclaude-memDIY Hooks
    Setupnpx install (1 command)2 scripts, manual
    Auto-captureAll tool usagegit commits + Write only
    SearchVector similarity + keywordgrep (text search)
    Web UIlocalhost:37777None
    DependenciesBun + SQLite + (Chroma)None
    Token costLLM compression (Gemini = free)Zero
    Git-friendlyDB file (gitignored)Markdown files (shareable)
    Multi-instanceSession-scoped isolationFile sharing for coordination

    Running Both Together

    The good news: they coexist perfectly. claude-mem registers as a plugin, DIY hooks register directly in settings.json. Both fire on the same events without conflict.

    When claude-mem shines

    • Smart compression: Uses an LLM (Gemini/Claude) to summarize tool outputs into compact observations
    • Semantic search: "What did I do with the auth system last week?" actually works
    • Web dashboard: Visual overview of what's been captured

    When DIY hooks shine

    • Zero dependencies: No server, no database, no runtime
    • Team sharing: Markdown files can be committed to git and shared across instances
    • Full control: You decide exactly what gets captured and how
    • Truly free: No API calls whatsoever

    Cost Optimization Tip

    claude-mem defaults to using Claude API for compression, which consumes your tokens. Switch to Gemini (free) to eliminate this:

    // ~/.claude-mem/settings.json
    {
      "CLAUDE_MEM_PROVIDER": "gemini",
      "CLAUDE_MEM_GEMINI_API_KEY": "your-free-key-from-aistudio.google.com"
    }
    

    Our 3-Layer Memory Architecture

    In our project (Flutter Web + Supabase, 3 parallel Claude Code instances), we use a layered approach:

    LayerToolPurpose
    L1: Intra-sessionclaude-mem (SQLite)Auto-record all tool usage, semantic search
    L2: Inter-sessionDIY hooks (markdown)Git commit history, cross-instance sharing
    L3: Cross-projectNotebookLM Master BrainDeep research, long-term architectural knowledge

    Verdict

    claude-mem delivers on its promise of turning Claude Code from a "disposable tool" into a "growing partner." The vector search and Web UI are genuinely useful features that are hard to replicate with simple scripts.

    However, for teams that want zero dependencies, zero token cost, and git-friendly memory sharing, a DIY hook approach is a solid starting point.

    My recommendation: Start with DIY hooks for minimal memory, then layer on claude-mem when you need semantic search and automatic compression.


    Built with Claude Code | Project: https://my-web-app-b67f4.web.app/ #ClaudeCode #AI #buildinpublic

    Tags

    claudecodeaiproductivityllm

    Comments

    More Blog

    View all
    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught megemma

    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught me

    I ported the whole Gemma-4 family — E2B, E4B, 12B, 31B, and the 26B-A4B MoE — to run on...

    X
    xbill
    Hey DEV, I'm Tobore. Let's actually connect.community

    Hey DEV, I'm Tobore. Let's actually connect.

    Hey DEV, I'm Tobore. Let's actually connect. I've been on here for a while now, mostly writing and...

    L
    Laurina Ayarah
    I burned through thousands of AI tokens. Then a friend did it for freeai

    I burned through thousands of AI tokens. Then a friend did it for free

    (yep, kinda clickbait, just for the funsies 😊) At the beginning of the year, I relaunched my...

    P
    Paulo Henrique
    Claude might be saturating your machineai

    Claude might be saturating your machine

    My laptop was sitting idle with the fan at full tilt. Nothing was running that I knew of. The culprit...

    S
    Sidhant Panda
    Automated GitHub Code Reviews Using Google Geminigithubactions

    Automated GitHub Code Reviews Using Google Gemini

    I Built a Thing! TL;DR — Google Gemini-based Pull Request reviews and Issue Triaging for...

    D
    Darren "Dazbo" Lester
    What is an "agentic harness," actually?ai

    What is an "agentic harness," actually?

    I've been hearing the word "harness" thrown around a lot lately. I assumed it just meant "the IDE" or...

    T
    Tilde A. Thurium

    Stay up to date

    Get the latest DeepSeek prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for DeepSeek and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions for your business.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this DeepSeek resource

    • Create a Smart Shopping Assistant with Persistent Memory Using Zep, GPT-4, and Google Sheetsn8n · $4.99 · Related topic
    • Provide Real-time Updates for Notion Databases via Webhooks with Supabasen8n · $14.99 · Related topic
    • Conversational Google Calendar Management with Claude 3.5, Haiku & Telegramn8n · $9.99 · Related topic
    • Real-time Chat Translation with DeepLn8n · $4.99 · Related topic
    Browse all workflows