gitwtfhub

wtf is optmem?

victortaelin/optmem — explained in plain English

Analysis updated 2026-08-13

1,250PythonAudience · developerComplexity · 2/5Setup · easy

TL;DR

A tiny Python tool plus a short prompt block that gives AI coding agents permanent, searchable memory across sessions.

Mindmap

mindmap
  root((OptMem))
    What it does
      Permanent AI agent memory
      Append-only memory log
      Binary tree summaries
    Tech stack
      Python
      Shell install script
    Use cases
      Cross-session memory
      Regex memory search
      Synced or git-backed storage
    Audience
      AI agent builders
      Developers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Give an AI coding agent memory that survives across sessions and model changes.

REASON 2

Search back through everything an agent has ever learned with a regex-based recall command.

REASON 3

Store agent memories in a plain append-only log that can live in a synced folder or git repo.

What's in the stack?

PythonBash

How it stacks up

victortaelin/optmemalxndrtl/little-book-rlclaudiodrews/memory-os
Stars1,2501,2511,222
LanguagePythonPythonPython
Last pushed2026-06-10
MaintenanceMaintained
Setup difficultyeasyeasymoderate
Complexity2/52/54/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min

No API key or dependencies, a single curl install script and a prompt block pasted into AGENTS.md or CLAUDE.md.

Wtf does this do

OptMem is a small tool that gives AI coding agents a permanent memory across sessions. It consists of a single Python script with no dependencies, plus a short prompt block, about 426 tokens, that a person pastes into their agent's instructions file, such as AGENTS.md or CLAUDE.md, to wire the memory system in. After installing it with a one line curl command, the installer prints a Memory section explaining to the agent how to use the tool. The agent is told to run a wake command as the first action of every session, which reads back relevant memories, and to run a note command whenever it learns something worth keeping, such as a finished task, a fact the user shared, or a decision that was made. Each note is a single line up to 280 bytes, and notes should avoid duplicating what is already recorded. Memories are stored in a plain append only log file, one memory per line, that is never edited after being written. On top of that log, the tool builds a binary tree of summaries: pairs of memories get merged into a one line summary, then pairs of those summaries merge again, and so on. These merges happen one at a time as a side effect of running the note command, never in the background. A person can search every memory ever recorded with a recall command using a regular expression, open a summary node into its two halves with a zoom command, or drop a bad summary with a forget command so the next merge rebuilds it. Because each memory record is a fixed width, looking anything up is a single direct read rather than a scan, so the tool stays fast at scale: the README says waking takes about 0.03 seconds even with a million stored memories, around 608 megabytes on disk. The only setting worth adjusting is how many lines the wake command prints, changeable anytime without rebuilding anything, since it affects only how much gets read, not how much is stored. The memory folder's location can also be moved, for example into a synced folder or a git repository. If an agent spawns a subagent, the README instructs it to tell the subagent not to run the memory tool, since a subagent cannot judge what its parent already knows.

Yoink these prompts

Prompt 1
Install OptMem and add the Memory prompt block to my agent's AGENTS.md file.
Prompt 2
Explain how OptMem's binary tree of memory summaries works and how to zoom into one.
Prompt 3
Show me how to change how many lines OptMem's wake command prints.

Frequently asked questions

wtf is optmem?

A tiny Python tool plus a short prompt block that gives AI coding agents permanent, searchable memory across sessions.

What language is optmem written in?

Mainly Python. The stack also includes Python, Bash.

How hard is optmem to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is optmem for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.