memory-optimize

memory-optimize is a command for Claude Code from yeaight7/agent-powerups. It costs 26 tokens per session (592 once invoked), scanned A, original, Apache-2.0.

A routing workflow that chooses one context path: direct reading, web-page cleaning, document conversion, graph building, graph updating, or graph querying. It bases the choice on the input type and whether the information will be reused.

In plain words
What is it for?
Use it to choose an efficient approach for plain text, noisy web pages, PDFs or office documents, mixed collections, existing graphs, or changed source files.
Why use it?
It helps control current reading cost and future rereading cost without choosing a complex process for a small, simple task. It also checks whether required tools are available.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the memory-optimization plugin — 6 skills, 3 commands, 2 agents shipped together

Good fit Use it to choose an efficient approach for plain text, noisy web pages, PDFs or office documents, mixed collections, existing graphs, or changed source files.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/yeaight7/agent-powerups/memory-optimize
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.

Clone the repo
git clone --depth 1 https://github.com/yeaight7/agent-powerups

Made for: Claude Code.

Or install memory-optimization, the plugin that ships this one along with the rest of its 6 skills, 3 commands, 2 agents.

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-optimize

README.md
[![agentmods](https://agentmods.dev/badge/commands/yeaight7/agent-powerups/memory-optimize/github.svg)](https://agentmods.dev/commands/yeaight7/agent-powerups/memory-optimize)
Your own site
<a href="https://agentmods.dev/commands/yeaight7/agent-powerups/memory-optimize"><img src="https://agentmods.dev/badge/commands/yeaight7/agent-powerups/memory-optimize/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-optimize

Your own site · 80×15
<a href="https://agentmods.dev/commands/yeaight7/agent-powerups/memory-optimize"><img src="https://agentmods.dev/badge/commands/yeaight7/agent-powerups/memory-optimize.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 26 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 592 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.
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.00026 $0.00592
Opus 5 $0.00013 $0.00296
Sonnet 5 $0.00005 $0.00118
Haiku 4.5 $0.00003 $0.00059

Measured yesterday against content hash 3251a2bfa89a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-15, from the pricing page.

Security

Grade A, and why

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

plugins/memory-optimization/commands/memory-optimize.md · 71 lines

How it starts

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

Objective

Recommend the cheapest memory workflow that preserves answer quality and future reuse.

Context

Inputs:

  • optional path or URL
  • optional question or task goal

Optimization targets:

  • lower token cost now
  • lower reread cost later
  • better persistence when repeated queries are likely

Process

  1. Inspect input shape and reuse horizon:
    • plain text or small local file
    • noisy web page
    • PDF/Office doc or other hard-to-read binary-ish source
    • mixed corpus
    • existing graph with new question
    • existing graph with changed sources
  2. Check requirements:
    • apx check graphify
    • apx check markitdown-file-intake
    • apx check defuddle
  3. Recommend exactly one primary path:
    • direct read for small, simple, one-shot text
    • defuddle -> Markdown -> read or build when web chrome is the main problem
    • markitdown-file-intake -> Markdown -> read or build when document format is the main problem
    • graphify full build when repeated questions or relationship navigation justify persistent memory
    • graphify --update when a graph already exists and sources changed
    • graph query against existing graph when the graph exists and the task is retrieval, tracing, or explanation
  4. State why that path is cheapest:
    • lower immediate token cost
    • lower repeated reread cost
    • better persistence across future sessions
  5. Include exact next command(s) for the recommended path.
  6. If a required tool for the best path is missing, either:
    • recommend the next-best lower-capability path that still preserves answer quality, or
    • stop and say the missing requirement makes the cheap path unavailable

Stop Conditions

  • input is too ambiguous to choose between direct read, helper conversion, build, update, or query
  • the recommended path depends on a missing tool and no credible fallback preserves answer quality
  • user asks for persistent graph advice but the target path or URL is unavailable

Rules

  • optimization target = lower token cost, lower reread cost, better persistence
  • graphify is long-lived memory path
  • helpers are normalization tools only
  • keep graphify primary for persistent memory, helpers secondary, Obsidian optional
  • do not recommend a graph build for trivial one-shot text when direct read is cheaper
  • do not claim a helper or graph path is available before requirement checks pass
  • do not claim bundled upstream code

Read the full file on GitHub · 71 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. yesterday First seen · 71 lines · 26 tokens per session scan A 3251a2bfa89a

Subscribe to this mod's changes

memory-optimize is a command published in the GitHub repository yeaight7/agent-powerups (6 stars, last pushed 2d ago), licensed Apache-2.0. It adds 26 tokens to every session and 592 once invoked, about $0.0001 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-09-14.