What an agent has to know to write into a store, what it costs, and two prompts meant to be copied as they are.
One block answers one question on its own. Keep it under about 800 tokens; split a longer one into blocks that each stand alone. Give it a one-sentence title and three to eight keywords -- the words a future reader would actually type. Put it under the parent its subject puts it under. Do not rewrite the source bytes when you are moving something in: no polishing, no translating, no dropping sentences. Record a decision as a block of kind decision and link each block that implements it; open a session with commitments --open, which lists the decisions still owed.
One store, one daemon. theourgia serve <store> holds the store open and keeps the reduced state in memory. The client is thin: it builds a request from the command line, sends it to the daemon and prints the answer; init and eval it hands to a local program, core.sc, instead, and when it cannot reach a daemon it starts none: a `core.sc --frame` child answers that one request and exits. Requests and answers are S-expression envelopes over a unix socket. The MCP shell is thin in the same way -- it asks the daemon for the tool list with describe rather than carrying its own copy.
Two sets of figures, because they were taken under different conditions. Over MCP with the shell resident and the store at 387 blocks, a tool call took 1 ms to read a block, 2 ms for an outline and 48-68 ms for a search; initialize took 39 ms and tools/list 121 ms, the latter including the describe round trip to the daemon. Measured separately, from a source-form client with four other agents writing into the same store at the time, an insert of a 3 KB body took 108 ms end to end, including the client process starting. A client process starts in 30-50 ms once it is running from compiled objects. search is a full scan and grows with the store.
import-md opens the files itself, so the bytes never enter the agent's context. Measured on 113 documents totalling 2,717,039 bytes: 0 tokens of context to convert, against roughly 1,082,000 if the same agent had read them first. This holds only while the split needs no judgement -- import-md cuts at headings. A corpus that needs a human decision about where to cut does not get the zero. Nor does it lift the limit on one request: a directory large enough to outlast the client's 30-second wait answers transport-unknown while the daemon goes on and finishes the import, so a large memory goes in file by file.
Twenty real questions about a real agent memory, answered blind by two agents: one allowed only the store, one allowed only the markdown files. Both scored 20/20, and the answers were checked against each other question by question. The store route read 14% more bytes, all of it from search, whose replies then had no upper bound: a broad query returned every hit with its full keyword list. search now returns the best ten hits unless --all is given, and says how many it left out.
Give this to an agent together with the files to migrate.
You are moving an existing markdown memory into a theourgia store through
its command-line client, following the store's write protocol. The store is
the target of everything you write; the markdown files are read-only source.
Environment (every shell):
export THEOURGIA_ACTOR=<your-name> THEOURGIA_WRITER=<your-name>
STORE=<path of the store>
theourgia <verb> --store $STORE ... --wire
When THEOURGIA_HOME is set and not empty, the first stderr line is the
banner `(theourgia machine-home ...)`; ignore it.
Write protocol:
- A block is the unit of writing: one block answers one question on its
own. Keep a block under about 800 tokens (roughly 3000 bytes); split a
longer one into blocks that each stand alone.
- Give every block a one-line title and 3 to 8 keywords, comma separated,
the words a future reader would actually type when searching.
- Place a block under the parent its subject puts it under (--under).
- Do not rewrite the source bytes: do not polish, translate or drop
sentences. Frontmatter stays out of the body; its description may become
the title, its name and type belong in the keywords.
- A memory file is usually one block. A file holding several independent
dated instances that together exceed the limit is split by instance,
each block titled with the file's name and the instance's date; an
instance whose heading has no date is titled with the heading's text.
An instance larger than the limit stays one block: do not cut it in the
middle of what it argues.
Per file, one insert, run from a script as an argument list -- never through
a shell, which would change a body holding a backtick or a $:
["theourgia", "insert", "--store", STORE, "--under", "<parent-id>",
"--title", "<title>", "--keywords", "<k1>, <k2>, ...",
"--text", "<body verbatim>", "--wire"]
The body is one element of that list, whatever its size (a 9 KB body has
gone through this way). A success answers
(ok (events ...) (state (("<id>" . "<hash>"))) ...)
with the id and the hash as strings; record <id> without the quotes. Record
any other answer verbatim, with the command minus the body; retry at most
once.
Ledger (write it to <ledger path> as JSON):
{"group": ..., "files": [{"file": ..., "chars": n,
"blocks": [{"id": ..., "title": ..., "keywords": ..., "bytes": n}],
"refusals": [{"cmd": ..., "answer": ...}]}],
"totals": {"files": n, "blocks": n, "refusals": n, "wall_seconds": n},
"friction": ["one sentence per thing that was awkward: command line,
answers, protocol, speed"]}
Every id in the ledger comes from a real answer; never write a placeholder.
Do not modify any source file. Do not touch git. Do not kill processes. Do
nothing to the store except insert under the parents you were given. If the
client fails more than three times in a row, stop, record, report.
Turn the markdown memory off, put the store's outline into each session, and tell the agent how to recall and how to write.
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1
{ "autoMemoryEnabled": false }
{
"hooks": {
"SessionStart": [
{
"matcher": "startup",
"hooks": [
{
"type": "command",
"command": "theourgia outline --store /path/to/memory-store --depth 1"
}
]
}
]
}
}
{
"type": "command",
"command": "theourgia commitments --open --store /path/to/memory-store"
}
## Memory lives in theourgia, not in markdown files
The store at /path/to/memory-store is my memory. The markdown memory
directory is retired: do not read it and do not write to it.
Identity: export THEOURGIA_ACTOR=<agent name> and THEOURGIA_WRITER=<agent
name> before the first call. One writer id is held by one live agent at a
time; a later session may bind the same id and carry on with its drafts.
Two agents that need to edit the same draft copy it instead of sharing the
id, keeping its baseline:
theourgia read --store $STORE <id> --working-info --writer w1
theourgia write --store $STORE <id> "<text>" --writer w2 \
--based-on <based-on> --working-cut <cut>
The read answers (projection working w1 <id> <version> <based-on> <cut>
"<text>" ...); w2 must not hold a draft of that block already.
Recall, before starting a task:
theourgia search --store $STORE "<two or three words from the task>"
theourgia read --store $STORE <id> # a hit that looks relevant
theourgia read --store $STORE <id> --recursive # a block and all under it
search takes one query: quote the words, or it answers with its usage line.
The first read ends with (cut ...), the state it read, and (versions ...),
the block's version; read --recursive prints its blocks alone. Recall needs
neither clause.
Read what the search returns; do not page through the whole store. If a
search finds nothing, try the other words a past self would have used, then
stop: absence of a memory is an answer.
Write, when something worth keeping happens (a correction, a decision, a
fact about the environment, a lesson):
theourgia insert --store $STORE --under <section id> --title "<one line>" \
--keywords "<3-8 words a future reader would search for>" \
--text "<the fact, then Why: and How to apply:>"
One block answers one question; keep it under about 800 tokens. Put it under
the section it belongs to (the outline shows them). Before inserting, search
for an existing block on the same fact and change that one instead of adding
a duplicate: its text with a draft and a commit,
theourgia write --store $STORE <id> "<new text>"
theourgia commit --store $STORE <id>
(the draft is based on the block as committed now), its title or keywords
with
theourgia set --store $STORE <id> keywords "<words>"
Keep the markdown habits that still apply: say why, say how to apply, link
related blocks by id in the text.
Do not put into the store what the repository already records (code
structure, git history, CLAUDE.md itself), and nothing that only matters to
the current conversation.
claude mcp add theourgia -- \
theourgia-mcp --store /path/to/memory-store --actor <agent name>
{
"mcpServers": {
"theourgia": {
"command": "theourgia-mcp",
"args": ["--store", "/path/to/memory-store", "--actor", "<agent name>"]
}
}
}
Every block in sections 04 and 05 is copied byte for byte from docs/claude-code-memory.md at commit 3aad6fd; the document says when and how to use each one.