OptMem README

The project's README from github.com/VictorTaelin/OptMem. As one markdown file: README.md.

OptMem

Permanent memory for AI agents. A 426-token prompt, a script, plug and play.

how OptMem works

Install

curl -fsSL https://raw.githubusercontent.com/VictorTaelin/OptMem/main/install.sh | sh

It prints a ## Memory block. Paste that at the top of your agent's AGENTS.md (or CLAUDE.md), and you are done. Run the same line again to update.

The tool lands at ~/.optmem/memo; put ~/.optmem on PATH to type memo.

Commands

memo wake read the memory — the first command of every session
memo note "..." record one memory: one line, up to 280 bytes
memo nap answer the merges that came due
memo recall <regex> search every memory ever recorded, word for word
memo zoom <lo>-<hi> open a tree node into its two halves
memo forget <lo>-<hi> drop a bad summary; the next nap rebuilds it

Merges arrive one at a time, in the output of note. Nothing ever runs in the background.

Files

~/.optmem/
  memo          the tool: one file of Python 3, no dependencies
  memory/
    LOG.txt     every memory, one per line, append-only, never edited
    TREE/       the summaries: a cache, rebuildable from the log alone
    config      the sizes, written by `memo config`
memo config                  # show the sizes
memo config WAKE_LINES=300   # how many lines wake prints (96 ≈ 8k tokens)
memo config WAKE_LINES=      # back to the default

WAKE_LINES is the only size worth touching, and it is a reading budget, not a storage budget: change it whenever, in either direction, and nothing is recomputed.

Records are fixed width, so position is identity and every lookup is one seek. At a million memories (608 MB), wake takes 0.03s.

Set $MEMORY_DIR to keep memory/ elsewhere — a synced folder, a git repo.

The prompt

This is what the installer prints, and the whole of the integration.

## Memory

Your memory is OptMem:
- The tool is `~/.optmem/memo`
- Your memories are in `~/.optmem/memory`

OptMem outlives every session, compaction, model and vendor change.
Without it you do not know who you are, or what was decided and tried.

### At startup: activating OptMem (mandatory)

Run `~/.optmem/memo wake` before any other tool call, in every session, and
then do exactly what it prints, to the end of its output.

### While working: register memories (mandatory)

Call `~/.optmem/memo note "<1 line, max 280 bytes>"` whenever you learn
something new, or something worth keeping happens. That covers a task
worth real effort, a fact or insight the user teaches you, anything you
learn about their life (even indirectly), any event of lasting effect.

Do not register redundant memories.

If `~/.optmem/memo note` asks a compression: do it before your next action.

Never edit or delete anything under `~/.optmem/memory`: the tool manages it.

### When you need an old memory: search, or navigate

`~/.optmem/memo recall <regex>` searches every memory, word for word.

Your memories also form a binary tree: #0-1, #2-3 ... exist as one-line
summaries, pairs of those as #0-3, and so on -- every `#a-b` line wake
prints is one node of it. `~/.optmem/memo zoom <a-b>` opens a node into its
two halves, down to the raw memories.

### If you're a subagent: skip everything above

Parallel sessions on this machine are all you, and may all write memories.
A subagent is not: it must never run `memo`, because it cannot judge what
is already known, and its notes would arrive duplicated and incorrectly.
When you spawn one, write: `You are a subagent. Don't run memo.`

OptMem (VictorTaelin/OptMem)

Searching Database…

2.2K ·GitHub
这是什么?OptMem 给 AI 智能体提供跨会话的永久记忆:一小段提示词加一个本地脚本,智能体因此能记录和回忆笔记,而不是每次运行之间把一切都忘光。
这是提示词、库,还是命令行工具?两者都是:一个名为 memo 的本地 CLI 工具,负责存储和读取记忆;外加一小段 Memory 提示词块,粘贴到你智能体的 AGENTS.md 或 CLAUDE.md 里,让它知道怎么调用 memo。
怎么把它跑起来?运行安装器,它会输出一个 Memory 块;把该块粘贴到 AGENTS.md(或 CLAUDE.md)顶部就完成了。memo 二进制本身位于 ~/.optmem/memo,你可以把它加进 PATH,之后直接敲 memo 就行。
哪些编程智能体能用它?任何会读取 AGENTS.md 或 CLAUDE.md 系统提示词的智能体都可以,包括 Claude Code——Memory 块就位后,智能体会自己去调用 memo CLI。
memo 会在后台跑什么东西吗?不会。合并建议(记忆整合)只在 memo note 的输出里逐条出现,由你自己用 memo nap 来处理——没有任何东西是自动计算的。
我的记忆存在哪里?存在本地 memory/ 文件夹里;想备份或共享记忆的话,可以用 $MEMORYDIR 环境变量指向别处,比如同步文件夹或 git 仓库。
memo wake 是干什么的?它是每个会话的第一条命令:读回智能体存下的记忆,让智能体带着过去会话的完整上下文开始对话。
memo 在大规模数据下快吗?在一百万条记忆(磁盘上约 608 MB)的规模下,memo wake 只需 0.03 秒,因为每条记忆记录都是固定宽度,查找只需一次磁盘寻道。
memo zoom 是干什么的?它把一个已摘要的记忆树节点重新展开为原来的两半,让你能钻进合并时被折叠起来的细节。
能修复一条糟糕的记忆摘要吗?能——memo forget 会丢掉糟糕的摘要,下一次 memo nap 会从底层的原始记忆重建它。
Size
11 MB
Stars
2.2K
Updated
CommitJul 31
Age
2mo
Commits · 90 Days