News thumbnail
Technology / Tue, 16 Jun 2026 MakeUseOf

I fixed Claude's memory problem with a Postgres database and it changed everything

But with the right memory, Claude Code can be an army in itself. In this case, it gives Claude read and write access to a Postgres database to save and fetch files. If everything works, you can start saving to your Postgres database right away. Subscribe for hands-on Claude memory and Postgres guides Get the newsletter for practical Claude memory playbooks—step‑by‑step Postgres + Memory Vault wiring, config snippets, Windows fixes, and reusable troubleshooting to apply to your projects; subscribe to access these guides. The manual memory file approach gets you out of most daily frustrations fast, but it's not a full solution.

If you've spent any serious time with Claude Code, you've likely already been frustrated by the AI forgetting everything. You spend the first twenty minutes of the session describing project structure, coding conventions, and why you're using specific libraries or tools, and Claude forgets everything in the next session.

But with the right memory, Claude Code can be an army in itself. So if the Claude token window seems too small for your projects, there are some simple ways you can supplement it.

Claude isn't really forgetting—it's starting over

Why context windows and chat history aren't the same thing as memory

Claude forgetting what you described isn't a bug in the traditional sense. Claude Code operates on a context window — a working memory that holds your current conversation, file reads, tool outputs, and instructions. Depending on your plan and model, that window can be anywhere from 200,00 tokens to a million. It sounds enormous, but it fills up faster than you'd expect.

Every file you open, every bash command Claude runs, every long back-and-forth eats into that context window. When the window gets close to full, Claude automatically starts compacting your chat. It deletes older tool outputs first, then summarizes the earlier conversation. The problem, however, is that compaction is lossy, and detailed instructions or decisions from earlier in the session can quietly get lost.

There are two fixes for this issue. You can either ask Claude to manually save a summary of everything in a separate file and read it to remember details every time you start a new session or clear the context window, or you can wire a Postgres database that gives Claude genuine long-term memory that survives every session, every /clear command, and even switching machines.

Claude Developer Anthropic PBC Price model Free, subscription available

A Postgres database changes the equation

Giving Claude persistent memory that survives every conversation

Photo by Yadullah Abidi | No Attribution Required.

For anything serious like a long-running project, a team environment, or a codebase where context drift can cost you hours and thousands of tokens, you'd want memory that lives completely outside Claude's context window. That's where Postgres comes in, wired to Claude via MCP (Model Context Protocol) — an open standard that lets AI tools like Claude connect to external tools and services. In this case, it gives Claude read and write access to a Postgres database to save and fetch files.

The tool that makes this work is called Memory Vault, an open-source project that combines Postgres with pgvector for hybrid search — semantic similarity and keyword matching combined, so Claude can find the right memory even when you don't remember the exact words. Setup is as simple as cloning the official GitHub repository and spinning up a docker container. Run these commands one after the other:

Screenshot by Yadullah Abidi | No Attribution Required.

git clone https://github.com/mihaibuilds/memory-vault.git

cd memory-vault

docker compose up -d

And that's it for the database side. Docker pulls the images, runs migrations, and starts everything automatically. You can verify whether everything is up and running by using this command:

Screenshot by Yadullah Abidi | No Attribution Required.

docker compose exec app memory-vault status

You should see a Database: healthy and a chunk count of zero for fresh installations. As you start saving things to memory, this chunk count will rise. Memory Vault also spins up a web dashboard at http://localhost:8000 where you can browse, search, and manage stored memories directly.

Next, you need to wire it to Claude Code. To do so, just add the following snippet to your .claude.json file:

{ "mcpServers": { "memory-vault": { "command": "python", "args": ["-m", "src.mcp"], "cwd": "/path/to/memory-vault", "env": { "PYTHONPATH": "/path/to/memory-vault", "DB_HOST": "localhost", "DB_PORT": "5432", "DB_NAME": "memory_vault", "DB_USER": "memory_vault", "DB_PASSWORD": "memory_vault" } } } }

Make sure to replace /path/to/memory-vault with wherever you cloned the repository. You'll also need Python 3.11 or higher and the Memory Vault dependencies installed by running pip install -e ".[mcp]" from inside the cloned directory. Once done, restart Claude Code and type in /mcp to check if the server is connected. If everything works, you can start saving to your Postgres database right away.

Screenshot by Yadullah Abidi | No Attribution Required.

If you're using Claude Code on Windows but want to host your Postgres database on a Linux server, you will have to deal with an additional issue. Python's default async loop on Windows (ProactorEventLoop) is incompatible with psycopg3, the database driver Memory Vault uses. So even if you've got the database path set right, it'll time out after 30 seconds without a useful error. The fix is to change one line in the cloned repository's src/mcp/__main__.py file. Open it and make it look like this:

"""Allow running the MCP server with: python -m src.mcp""" import asyncio import sys if sys.platform == "win32": asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) from src.mcp.server import main main()

Make sure to set DB_HOST in your .env file to your Linux machine's local IP address instead of localhost. With these changes, you should be able to get the MCP server up and running on Windows and connected to your remote database cleanly.

Don't underestimate simple memory files

Why markdown documents still solve a surprising number of problems

Photo by Yadullah Abidi | No Attribution Required.

If you don't want to spin up database infrastructure, you can solve a majority of the problem without ever leaving your terminal. Claude Code has a built-in mechanism for this via CLAUDE.md — a plain text file that reads automatically at the start of every session. You can also ask it to create specific files for specific sessions and have it read them to get project-specific information. If you're using the built-in CLAUDE.md file, you can also run /memory to open the file directly in your system editor for editing and reorganization.

Subscribe for hands-on Claude memory and Postgres guides Get the newsletter for practical Claude memory playbooks—step‑by‑step Postgres + Memory Vault wiring, config snippets, Windows fixes, and reusable troubleshooting to apply to your projects; subscribe to access these guides. Get Updates By subscribing, you agree to receive newsletter and marketing emails, and accept our Terms of Use and Privacy Policy . You can unsubscribe anytime.

Another limitation is that the content from these files gets injected into the context window every time you access them, meaning it does consume tokens. If your notes grow to thousands of lines, you're eating into the same budget you're trying to protect. It's best to keep the file focused and trim it regularly.

The difference shows up in everyday use

Less repetition, better continuity, and conversations that actually build on themselves

Once this is running, you no longer have to manually ask Claude to remember from individual files or have your notes eat into your context window. Simply ask it to remember what you worked on, and you can ask Claude anything from your previous sessions, and it answers with full context. The compaction problem doesn't go away entirely, but it stops mattering. The important things Claude needs to remember are already saved in the Postgres database.

Related 6 Reasons I Use Claude Instead of ChatGPT ChatGPT is great; don't get me wrong. But Claude is so much better.

With a shared backend, multiple developers can work with a Claude instance that knows the full project history. The memory will compound across the full project rather than staying siloed per session.

The manual memory file approach gets you out of most daily frustrations fast, but it's not a full solution. The Postgres setup is what you reach for when you genuinely need something that scales, survives everything, and starts feeling less like a workaround and more like Claude actually knowing your project.

© All Rights Reserved.