Long-Term Memory Structure

A command-line tool, ltms, that reads Claude Code’s transcripts across their compactions and gives an agent a small index of its own history, with an address back to every line.

Installnpm install -g long-term-memory-structure
Commandltms; without installing, npx long-term-memory-structure, which asks the npm registry on every run. Do not run npx ltms: that npm name is not this package.
NeedsNode.js 20 or newer; no runtime dependencies
Readswhat you name on the command line, such as ~/.claude/projects/<project>: Claude Code’s transcripts, and for ltms pin their sessions’ other files too; local files only
Printsaddresses, paths, counts, lengths, hashes, timestamps and a few short labels; no prompts, replies, tool inputs or tool outputs (ltms shapes --unlisted aside: for your own review, not to be sent, it lists the names and values the report’s vocabulary lacks, as the transcripts write them)
Writesto stdout and stderr; ltms pin also writes, only into the directory you give it with --to
Networknone: no network connections, no telemetry
LicenceMIT
Sourcegithub.com/long-term-memory-structure/long-term-memory-structure
Packagenpmjs.com/package/long-term-memory-structure
DocsREADME · the ten-minute check
Bugsthe repository’s issues page, which is public: github.com/long-term-memory-structure/long-term-memory-structure/issues
Status0.3.1, early: the output format may change between versions

LTMS Reader, for VS Code

Your Claude Code sessions in VS Code, as a map of what each turn says, with exact search, search by meaning, and the records behind each turn. A Preview, free, and it keeps your data on your machine.

LTMS Reader

First steps

A first look at a project’s sessions, newest first:

ltms index ~/.claude/projects/-home-me-my-app

-home-me-my-app stands for your project’s directory path with every character other than an ASCII letter or digit written as -: /home/me/my.app becomes -home-me-my-app. Claude Code cuts a name longer than 200 characters and adds a hash, so for a very long path find the folder with ls ~/.claude/projects/.

To give your agent the skill that teaches it these commands:

mkdir -p ~/.claude/skills/ltms && npx -y long-term-memory-structure@0.3 skill > ~/.claude/skills/ltms/SKILL.md.tmp && mv ~/.claude/skills/ltms/SKILL.md.tmp ~/.claude/skills/ltms/SKILL.md

Keep the -y: without it, npx asks before installing the package, and its question would be written into the file.

What compaction leaves on disk

When a Claude Code session fills its context window, or on /compact, Claude Code compacts it: the conversation in the model’s context is replaced by a summary, and the model carries on from the summary. The details, such as which commands ran, which of them failed and which files were read or changed, are no longer in front of the model. They are still on disk.

Claude Code appends each session to its transcript, a .jsonl file under ~/.claude/projects/. A compaction adds a boundary record and the summary to the file, and every record before them stays where it was. The summary itself gives the transcript’s path, so the details can be read back from it.

Claude Code also deletes a transcript, and its session’s files, once it is older than cleanupPeriodDays, 30 days by default.

What compaction writes, and what each model keeps through it, measured:

Preserve potential indefinitely

This is the design’s first constraint, and the claim to test it by. Nothing ltms does destroys a record. A version of a transcript, once a pin has copied it, is never deleted or written over by ltms: a rewrite keeps the old copy beside the new one, and ltms pin --check reads back every version PINS.log records.

What ltms cannot keep is what it never copied: a version is kept from the pin that copies it, so pin at the end of every session and from cron, and run ltms pin --check now and then. One pin directory is one copy on one disk: keep another.

The README’s technical debt lists every way an adversarial reading of the code found the claim false, each with its state in this release and the test that reproduces it. A check anyone can run in about ten minutes covers the package against its source, its tests, each repair against the code before it, no network, and the report’s figures.

Five facts

Five facts about the setting decide the design. Each can be checked on a machine that runs Claude Code, and each part of ltms answers one of them.

  1. The record is on disk. Claude Code appends each session to its transcript, a .jsonl file under ~/.claude/projects/. A compaction (when the context window fills, or on /compact) adds a boundary and a summary to the file; every record before them stays where it was.
  2. The record is deleted. Claude Code deletes a transcript, and its session’s files, once it is older than cleanupPeriodDays, 30 days by default.
  3. The record is far larger than the window. A project’s history outgrows any context window, and every token read into the window is taken from the work: an agent can afford a small index and a few passages, each found by its address.
  4. A wrong recollection becomes a wrong action. An agent acts on what it remembers. A summary, a model’s or anyone’s, is a guide to the record, never the record: before acting, the agent reads back the line it cites.
  5. One agent, one user, one machine. The memory serves one long-lived agent of one user, on a local disk; nothing is sent anywhere.

What follows: keep every version of the record (1, 2), since a deletion cannot be undone and a copy can, and no one can say today which question a later session will ask: preserve potential indefinitely. Index it small, with an address back to the exact line (3). Read the line back before acting on it (4). No network, no shared store (5).

The commands

ltms index <path>...
Lists a project’s sessions, one line each, newest first: when each ran, its turns, calls and failures, and the addresses of its prompts, its compaction summaries and its last reply.
ltms skeleton <file.jsonl>...
An index of one transcript without its content: one JSON line per turn and per tool call. A turn’s line gives the address of its prompt. A tool call’s line gives the addresses of the call and of its result, and hashes of what went in and what came out.
ltms search <query> <path>...
Finds the turns that hold every word of a query, and prints their addresses.
ltms stats <file.jsonl>...
Counts each transcript’s turns, calls and failures.
ltms pin <path>... --to <dir>
Keeps copies of the transcripts outside Claude Code’s config directory, where its cleanup does not delete them, so the addresses still lead somewhere after it. Its log is only appended to, and each line after the first holds the sha256 of the line before it.
ltms shapes <path>...
A report of what transcripts are made of (record kinds, key paths, types, versions), never what they say, made to be sent to the maintainers of ltms or of any other program that reads these transcripts.
ltms records <file.jsonl>
One transcript as records of a protocol’s format (version 0, a draft), one for each line of the file, each with the address of its bytes, its kind and the addresses of the records the file links it to, and no text.
ltms skill
Prints a skill, a SKILL.md, that teaches an agent to use them.

On the 2,539 transcripts it was tested on (3.35 GB), the index ltms skeleton prints came to 0.7 % of their size, so it fits in a context window where the transcript does not.

One turn of the synthetic test transcript test/fixtures/demo.jsonl, as ltms skeleton prints it: a hook blocks a command, the tests fail twice, a fix is made, the tests pass.

{"k":"turn","a":"demo.jso:L20","ta":"demo.jso:T003","ch":"typed","n":47}
{"k":"call","a":"demo.jso:L22","ta":"demo.jso:T003","tool":"Bash","verb":"rm","in":"8672006e23d8","ok":false,"ek":"hook-block:demo-gate","r":"demo.jso:L23","out":"f69cbd101377","n":111}
{"k":"call","a":"demo.jso:L24","ta":"demo.jso:T003","tool":"Bash","verb":"npm","in":"84c7c646123a","ok":false,"ek":"exit-1","r":"demo.jso:L25","out":"429ad9a9f725","n":58}
{"k":"call","a":"demo.jso:L26","ta":"demo.jso:T003","tool":"Bash","verb":"npm","in":"d990b201195a","ok":false,"ek":"exit-1","r":"demo.jso:L27","out":"3953f9b8b91c","n":69}
{"k":"call","a":"demo.jso:L28","ta":"demo.jso:T003","tool":"Edit","verb":".js","in":"42eb1ba06a92","ok":true,"r":"demo.jso:L29","out":"99a70feb06ce","n":56}
{"k":"call","a":"demo.jso:L30","ta":"demo.jso:T003","tool":"Bash","verb":"npm","in":"5d0af2eddc4d","ok":true,"r":"demo.jso:L31","out":"12112eacc5de","n":35}

An address such as demo.jso:L22 means line 22 of the file whose name starts with demo.jso. To read what a line hides, open that line of the transcript: sed -n 22p <file.jsonl>.

Search by meaning: ltms-semantic

A second package, ltms-semantic, searches the same transcripts by meaning. It reads them through ltms’s own parser and answers with the same addresses, so whatever it finds opens the way an ltms result does. ltms search finds the turns that hold every word of a query; ltms-semantic search ranks the turns by how near their text is in meaning to the query, including when the question’s words are not the record’s words, or not even in its language. Its model, bge-m3, reads more than 100 languages (its card says so), among them Hebrew and English.

ONNXRUNTIME_NODE_INSTALL=skip npm install -g ltms-semantic
ltms-semantic model fetch
ltms-semantic index ~/.claude/projects/-home-me-my-app
ltms-semantic search 'how did we decide where to keep the vectors' --max 5

It needs Node.js 22.13.0 or newer, for its built-in SQLite, and was tested on Linux x64, not on macOS or Windows. ONNXRUNTIME_NODE_INSTALL=skip skips the CUDA libraries that one dependency’s install script downloads on Linux x64 from NuGet’s feed; this package runs on the CPU and never loads them.

The network: only ltms-semantic model fetch uses it, to download the model’s three files, 2.28 GB, from Hugging Face, each pinned by its size and sha256. index, search and check (which checks what index built) read local files only, and ONNX Runtime’s telemetry is switched off before the runtime loads.

The costs: the model takes 2.28 GB of disk. A search holds about 1.6 GB of memory; give an index 4 GiB at the least. Indexing runs on the CPU: measured, about 23 minutes per million tokens on a 12-core laptop CPU, and 1.2 to 1.6 hours on a 4-core one shared with other work.

Measured: on the author’s own set of 16 topics (not published), each asked once in English and once in Hebrew and written to avoid the words of the sessions that answer it, over 187 sessions, the turn of an answering session ranked first for 13 of the 16 English questions and 9 of the 16 Hebrew ones, and within the first 10 for all 32.

Before Hebrew text is cut into tokens, its points and cantillation marks are removed, and a maqaf becomes a space.

Version 0.1.0. Early: the output format may change between versions.

Read more

The design and its measurements are in the report Durable Memory on a Fixed Context Budget (Ben Yanai 2026).