Build1 publisher3 min readPublished
myc's PreCompact hook writes the session to disk before the summary drops the reason
myc is an MIT-licensed memory layer for coding agents that installs into Claude Code's PreCompact event, writes the raw session to disk before it prints anything back, and hides the decisions it extracts until a human confirms them.
The Engineer · Build desk

What happened
- myc is an MIT-licensed local task-and-memory layer for coding agents, written in TypeScript on Bun, and it hooks the one moment when a session's context is about to be thrown away.
- Ranking boosts take MRR@10 from 0.520 to 0.867 and two-hop graph expansion takes it from 0.193 to 0.422, measured on corpora containing a control group that degrades when the feature works.
- Since 0.3.10 a note can be anchored to a span of code and the anchor follows that code across a refactor and into another file, verified on TypeScript and Python.
Compiled by The EngineerSomething wrong?How this is made
Why it matters
- constraint The whole design hangs on a host exposing the pre-compaction moment, and an agent host without a PreCompact equivalent leaves the write nowhere to go and nothing to rescue.
- cost Someone has to work the review queue: a captured decision that nobody confirms is on disk and unreachable by every retrieval path.
- decision Anyone budgeting for a retrieval layer on top of an agent has to settle a prior question first, which is whether anything writes at the instant the context is discarded.
Inside the hook, the session episode goes to disk first, raw, into the L0 layer, marked private, with secrets masked on word boundaries so ordinary prose survives [4][6]. Then a rescue packet is printed back into the context that survives compaction [4]. If the hook exceeds its timeout, you lose the summary; the record is already written [5]. Distillation of what was saved is queued and never runs on the write path [7]. In the sample output the saved episode is 265 bytes [8].
Decisions the hook lifts out of the transcript go through one more step before they count as memory. They land in `pending_review`, and they stay out of search, `recall`, `prime` and the MCP tools until a human confirms them [9]. The write-up gives the reason in one line: "a memory that hallucinates is worse than no memory, because it gets believed" [11]. Confirming a candidate turns it into knowledge the same way an ordinary note is born, and rejecting it retracts the note out of every retrieval path [12].
The latency claims come with conditions attached: p99, 100,000 nodes, darwin-arm64, myc 0.3.6, dated 2026-09-11 [14]. The write-up's own footnote says those absolute numbers are calibrated on one machine and that CI does not enforce them on other hardware [15]. CI enforces the structural claims, query plans and prefiltering, and the relative ones, healthy path against a deliberately degraded one, interleaved so hardware cancels out [15]. Whether that p99 holds on your box depends on how close your store is to 100,000 nodes and your hardware to that laptop [14][15].
The ranking evidence travels further. Boosts take MRR@10 from 0.520 to 0.867, and two-hop graph expansion takes it from 0.193 to 0.422 [16], factors of about 1.67 and 2.19 [17][18]. Both were measured on corpora containing a control group that gets worse when the feature works, so a corpus shaped to flatter the feature shows up as a loss somewhere [16]. You can run the bench script from a source checkout [25].
Since 0.3.10 a note can be anchored to a span of code, and the anchor follows that code as it moves, across a refactor and into another file, verified on TypeScript and Python [19]. When the code is no longer where the anchor put it, the note is kept and `recall` prints the penalty and the reason: `[code moved x0.64]`, `[code unverified x0.5]`, `[code gone x0.2]` [20]. A note whose every anchor is lost scores a fifth of an intact one, stays out of `prime`, and is counted in the footer as hidden [20][26].
All of this hangs off one host event. PreCompact is a Claude Code hook [2], and `myc wire` installs into it [3]. Another host has to expose the same moment for the hook to attach, and, as the write-up argues, a layer you query after the fact is useless if nothing was written when the context died [24].
The case for write-time capture over retrieval rests on one developer's account: three days of an agent re-doing the same work before he wrote the tool [21], and a cycle where the reason drowned in a compaction and the agent proposed the rejected option again, "honestly, politely, with no memory of ever thinking otherwise" [22][23]. The write-up does not report how much rework stopped after the hook went in.
What to watch
- Whether coding-agent hosts other than Claude Code expose a pre-compaction event for the write to hook.
- Whether CI ever enforces the absolute p99 latency budgets on hardware other than the darwin-arm64 machine they were calibrated on.
- Whether the pending_review gate stays on by default as confirm queues accumulate across sessions.