memory-optimization

memory-optimization is a skill for Claude Code from eric-cielo/moflo. It costs 60 tokens per session (1,299 once invoked), scanned A, original, MIT.

A tuning guide for MoFlo’s memory and search system, including its graph-based index and stored vector data. It explains settings that trade memory use, build time, search speed, and result quality.

In plain words
What is it for?
Use it to adjust index connectivity, index-building settings, search breadth, vector compression, and batch operations.
Why use it?
It helps diagnose slow searches, poor results, or memory limits as the stored collection grows beyond about 100,000 entries.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

Good fit Use it to adjust index connectivity, index-building settings, search breadth, vector compression, and batch operations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/eric-cielo/moflo/memory-optimization
Install

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.

Any agent
npx skills add eric-cielo/moflo --skill memory-optimization
Clone the repo
git clone --depth 1 https://github.com/eric-cielo/moflo

Made for: Claude Code.

Wrote 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.

agentmods badge for memory-optimization

README.md
[![agentmods](https://agentmods.dev/badge/skills/eric-cielo/moflo/memory-optimization/github.svg)](https://agentmods.dev/skills/eric-cielo/moflo/memory-optimization)
Your own site
<a href="https://agentmods.dev/skills/eric-cielo/moflo/memory-optimization"><img src="https://agentmods.dev/badge/skills/eric-cielo/moflo/memory-optimization/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.

agentmods 80×15 button for memory-optimization

Your own site · 80×15
<a href="https://agentmods.dev/skills/eric-cielo/moflo/memory-optimization"><img src="https://agentmods.dev/badge/skills/eric-cielo/moflo/memory-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 60 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,299 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium MCP Rug Pull · line 89
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00060 $0.01299
Opus 5.5 $0.00024 $0.00520
Sonnet 5.5 $0.00012 $0.00260
Haiku 4.5 $0.00006 $0.00130

Measured 1mo ago against content hash 2bead0eafc6a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

memory-optimization 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.

.claude/skills/memory-optimization/SKILL.md · 122 lines

How it starts

The opening of the file, as written. The whole thing — 122 lines — stays where its author put it; the contents beside it link to each section on GitHub.

MoFlo Memory Optimization

When the default moflo memory settings stop being enough — past ~100k entries, or when p95 search latency climbs — these are the levers.

HNSW Parameters

HNSW has three knobs. They trade build time, query time, memory, and recall.

import { HNSWIndex } from 'moflo/dist/src/cli/memory/index.js';

const index = new HNSWIndex({
  dimensions: 1536,        // must match your embedding model
  maxElements: 1_000_000,  // pre-allocated capacity
  M: 16,                   // graph connectivity (default 16)
  efConstruction: 200,     // build-time search width (default 200)
  metric: 'cosine',        // 'cosine' | 'l2' | 'ip'
});
Knob Higher Lower When to change
M better recall, more RAM (~2×M pointers per point) less RAM, worse recall Bump to 32–64 if recall@10 < 0.95; drop to 8 if memory-bound
efConstruction better index quality, slower build faster build, worse queries 200–400 is sweet spot; only lower in test fixtures
ef (search-time, passed to search()) better recall, slower queries faster queries, worse recall Start at 2×k, raise until recall plateaus

Rule of thumb: M and efConstruction are set once. ef is the runtime dial.

Quantization

moflo memory supports scalar quantization (Float32 → Int8) for a ~4× memory reduction with a ~1-2% recall hit. Turn it on when the index doesn't fit comfortably in RAM.

const index = new HNSWIndex({
  dimensions: 1536,
  maxElements: 5_000_000,
  quantization: {
    enabled: true,
    type: 'scalar',   // scalar (Int8) is the supported path
    rebuildThreshold: 10_000,
  },
});

Measure recall before/after on your own query distribution — public benchmarks don't predict your domain.

Batch Operations

Single-entry writes pay the HNSW insert cost per call. For bulk ingest, batch:

const entries: Array<[string, Float32Array]> = buildCorpus();

// Parallelise at the adapter level; don't await sequentially.
await Promise.all(
  entries.map(([id, vec]) => index.addPoint(id, vec))
);

// Or via MCP for moflo-native batch into .swarm/memory.db:
await mcp.memory_store(/* … */);  // upsert: true + Promise.all is fine

Read the full file on GitHub · 122 lines

Changes

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.

  1. 1mo ago First seen · 122 lines · 60 tokens per session scan A 2bead0eafc6a

Subscribe to this mod's changes

memory-optimization is a skill published in the GitHub repository eric-cielo/moflo (19 stars, last pushed yesterday), licensed MIT. It adds 60 tokens to every session and 1,299 once invoked, about $0.0002 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-30.