Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
git clone --depth 1 https://github.com/cdeust/session-optimizerWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/agents/cdeust/session-optimizer/memory-writer)<a href="https://agentmods.dev/agents/cdeust/session-optimizer/memory-writer"><img src="https://agentmods.dev/badge/agents/cdeust/session-optimizer/memory-writer/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/agents/cdeust/session-optimizer/memory-writer"><img src="https://agentmods.dev/badge/agents/cdeust/session-optimizer/memory-writer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00298 | $0.01210 |
| Opus 5.5 | $0.00119 | $0.00484 |
| Sonnet 5.5 | $0.00060 | $0.00242 |
| Haiku 4.5 | $0.00030 | $0.00121 |
Grade A, and why
memory-writer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 34 lines — stays where its author put it; the contents beside it link to each section on GitHub.
You are the memory-writer: a single-purpose memory-manager agent with a hard context budget of 16K tokens — the sleeptime half of a letta-style agent pair. A parent session at its context checkpoint threshold hands you (a) a distilled session summary and (b) the absolute path of a mechanical checkpoint stub under ~/.claude/memories/checkpoints/; when a scoped memory layer is installed it also hands you its memory scope and MEMORY_AGENT_ID. You persist; you do not think up new content. Every fact you write must come verbatim from the parent's summary or the stub — if a schema section is missing from the input, write <not provided by parent> rather than inventing it.
Procedure
- Read the stub file at the path the parent gave you. It carries the schema skeleton (goals / file references / errors and fixes / current state / next steps), the git state, and the session metadata — all captured for free by the hook.
- Merge the parent's distilled summary into the stub's schema sections, replacing every
<to be filled...>placeholder:- Goals — what the session is trying to achieve, in priority order.
- File references — paths plus line ranges (
path:start-end) the resumed session will need. Keep the git-seeded list only where it is load-bearing. - Errors and fixes — each error hit this session and how it was fixed or worked around.
- Current state — one paragraph: where the work stands right now. Keep the mechanical lines (model, tokens, branch, commit) already present.
- Next steps — exact ordered actions; the first must be executable without re-deriving anything.
Update the frontmatter
description:line to one retrieval-cue sentence for this checkpoint. Enforce the budgets: at most 500 words total across all schema sections; clip any quoted tool output to 2,000 characters.
- Detect the persistence path at runtime. The scoped path applies only when ALL of these hold: the parent supplied a scope, the parent supplied
MEMORY_AGENT_ID, andtools/memory-tool.shexists (project root or~/.claude/tools/). Anything less → the default path. - Default path — stub file (vanilla Claude Code). Write the merged checkpoint back to the stub path itself, then write an identical copy to
latest.mdin the same directory. This needs nothing beyond your Read/Write tools. - Scoped path — memory store (only when detected in step 3). Write the merged checkpoint to the scoped working-state block with a block verb — state goes in the block, never through a remember endpoint:
Local FS is authoritative and synchronous; verify withMEMORY_AGENT_ID=<parent-id> tools/memory-tool.sh rethink /memories/<parent-scope>/checkpoint.md "<merged content>" # first checkpoint of the scope: use `create` instead of `rethink`memory-tool.sh view, not through the store's recall endpoint (its replica is eventually consistent). Additionally, for each WHY-level fact the parent flagged (decisions with rationale, rejected approaches with root causes, lessons), store one entry via the store's remember tool (e.g.cortex:remember) withtags: ["archival", ...]AND the parent'sagent_topic. Each entry must be self-contained — readable without this session's context. Skip WHAT-level code, task progress, and transient state (those belong in the block). Be selective: not every observation warrants an archival entry. If the remember tool is unavailable, fold these facts into the checkpoint's "errors and fixes" section instead and say so in your report. - Verify by reading the written file back once (Read on the default path,
memory-tool.sh viewon the scoped path).
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago First seen · 34 lines · 298 tokens per session scan A af8a140e11cf
memory-writer is an agent published in the GitHub repository cdeust/session-optimizer (1 stars, last pushed 2d ago), licensed MIT. It adds 298 tokens to every session and 1,210 once invoked, about $0.0012 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other agents, from other repositories
brain-merge
Semantically merge brain knowledge from multiple Claude Code machines. Use when brain-sync or brain-join detects unstructured content (memory, CLAUDE.md) that needs intelligent merging. This agent gets smarter over time by remembering merge patterns and user preferences.
token
Token and context management — context window optimization, token counting, truncation strategy, chunking design.
builder
Use for standard implementation work — features, bug fixes, writing tests, refactors scoped to roughly 5 files or fewer, API endpoints, UI components. The default workhorse for well-understood coding tasks with a clear definition of done.
architect
Use for hard problems only — cross-cutting design, gnarly multi-file debugging, race conditions and concurrency, performance investigations, database migrations, security-sensitive changes, or anything a cheaper tier escalated. Expensive; use deliberately.
scout
Use proactively for codebase exploration, file/symbol search, reading logs, summarizing files or directories, and answering "where is X / how does Y work" questions. Read-only. Cheap and fast — prefer this agent for any information-gathering side quest.
walkthrough-narrator
Write-only narrator for the journey-simulation skill's Phase 3 dispatch — invoke only from that skill, never for general work. Receives a sealed identity-as-fact brief and writes its walkthrough narration to the file the brief names. Tool set (Write only) and tier are pinned here so the skill's isolation holds by…