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.
npx agentmods add agents/cdeust/session-optimizer/memory-writergit clone --depth 1 https://github.com/cdeust/session-optimizerWhat 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 | $0.00298 | $0.01210 |
| Opus 5 | $0.00149 | $0.00605 |
| Sonnet 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 yesterday.
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.
- yesterday 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 7d ago), licensed MIT. It adds 298 tokens to every session and 1,210 once invoked, about $0.0015 per session on Opus 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
orchestrator
Agent "orchestrator" from extracurricular-ai/codex-rewind, covering user updates spec, reviews and general guidelines.
Demonstrate
Agent for demonstrating VS Code features.
playwright-test-generator
Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.
.NET-Notebook-Migration-Agent
Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.
AVM Owner Triage
Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.
Ultimate Transparent Thinking Beast Mode
Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.