
Memory Optimize
Shrink Claude Code memory files through dedupe, rule migration, compression, and validation for faster context and lower token cost.
Overview
memory-optimize is an agent skill most often used in Operate (also Build) that runs a 4-step workflow to dedupe, relocate, compress, and validate Claude Code memory for roughly 30–50% token savings.
Install
npx skills add https://github.com/kochetkov-ma/claude-brewcode --skill memory-optimizeWhat is this skill?
- Four-step interactive workflow: remove duplicates, migrate rules to proper config files, compress entries, validate
- Typical outcome cited: 30–50% reduction in memory-file token footprint
- Targets faster context loading and lower API cost for long sessions
- Moves rules out of bloated memory into the right Claude Code config surfaces
- Ends with validation so optimized memory still loads correctly
- 4-step workflow: dedupe, migrate rules, compress, validate
- Typical savings: 30–50% on memory-file token count (per skill README)
Adoption & trust: 1.3k installs on skills.sh; 27 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Claude Code memory files balloon with duplicate rules and stale context, slowing every session and wasting tokens on repeat instructions.
Who is it for?
Power users of Claude Code who maintain project memory across weeks and notice duplicated policies or sluggish startup context.
Skip if: Fresh repos with minimal memory or teams that do not use Claude Code memory files at all.
When should I use this skill?
Claude Code memory feels duplicated or oversized, context load is slow, or you are consolidating rules into proper config files.
What do I get? / Deliverables
You end with leaner validated memory and rules living in the right config files so context loads faster and costs less per turn.
- Optimized memory file set with duplicates removed
- Rules migrated to appropriate Claude Code config locations
- Validation confirmation that memory still parses and loads
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Canonical shelf is operate/iterate because memory hygiene is ongoing production tuning of how your agent loads standing instructions. Iterate subphase covers incremental optimization of agent configuration rather than one-off feature delivery.
Where it fits
Monthly pass to dedupe MEMORY.md after several feature sprints added redundant rules.
After cloning a starter template, migrate generic rules to settings and compress repo-specific memory.
Before scaling agent use across more repos, standardize lean memory so support playbooks do not bloat context.
How it compares
Interactive memory housekeeping workflow, not an automatic always-on MCP or runtime profiler.
Common Questions / FAQ
Who is memory-optimize for?
Solo builders using claude-brewcode or Claude Code memory who want deliberate, guided cleanup instead of hand-editing megabyte-scale instruction files.
When should I use memory-optimize?
In operate when memory grows noisy mid-project, or in build/agent-tooling when bootstrapping a new codebase’s agent instructions before heavy implementation.
Is memory-optimize safe to install?
It edits local memory and config—commit before running and review migrations; see the Security Audits panel on this Prism page for the package.
SKILL.md
READMESKILL.md - Memory Optimize
MIT License Copyright (c) 2025-2026 Maxim Kochetkov (kochetkov-ma) https://github.com/kochetkov-ma/claude-brewcode Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # Memory Optimizer Optimize Claude Code memory files through a 4-step interactive workflow: remove duplicates, migrate rules to proper config files, compress remaining entries, and validate the result. Typical savings: **30-50%** on token count in memory files, meaning faster context loading and lower API cost. ## Quick Start 1. Install: ```bash npx skills add kochetkov-ma/claude-brewcode ``` 2. Use via slash command: ``` /memory-optimize ``` Or via natural language prompt: ``` Optimize my Claude memory files Clean up memory duplicates ``` The skill scans all memory files under `~/.claude/projects/`, cross-references them against your CLAUDE.md and rules files, then walks you through each optimization step with approval prompts before making changes. ## Why Use This - **Token savings** -- 30-50% fewer tokens in memory context means lower cost and more room for actual work - **Interactive** -- approve each step, skip steps you don't want; nothing changes without your confirmation - **Safe** -- shows before/after preview before making changes; content is only deleted when it provably exists elsewhere - **Smart migration** -- moves rules to proper config files (CLAUDE.md, `.claude/rules/`, `~/.claude/rules/`) so they load reliably instead of depending on memory ## What It Does ### Step 1: Remove Duplicates Finds memory entries that already exist in CLAUDE.md or rules files. Shows a table of what is redundant, asks for approval before deleting. Example: ``` Found 4 duplicate/redundant entries (35% of memory): | Entry | Memory File | Already In | Action | |-------|-------------|------------|--------| | "Use grepai first" | MEMORY.md:5 | rules/grepai-first.md | DELETE | | "Constructor injection" | MEMORY.md:12 | CLAUDE.md:## DI | DELETE | | "No System.out" | MEMORY.md:18 | rules/best-practice.md:7 | DELETE | | "Edit bottom-up" | MEMORY.md:23 | rules/avoid.md:8 | DELETE | ``` Options: "Yes, delete all" / "Review each" / "Skip this step" ### Step 2: Migrate to Rules/CLAUDE.md Identifies remaining entries that belong in persistent config files rather than memory. Uses a decision tree to categorize each entry: - Global rule (all projects) --> `~/.claude/rules/` - Project rule (this project) --> `.claude/rules/` - Architectural decision --> project `CLAUDE.md` - Reusable fact/pattern --> keep in memory - Session context --> delete (ephemeral) Shows a migration plan with target files and token savings, asks for approval before moving anything. ### Step 3: Compress Converts remaining entries to token-efficient formats: prose to table rows, multiple entries to a single table, verbose descriptions to imperative one-liners. Before: ```markdown ## Plugin Development (2026-01-15) When developing plugins, remember to update BOTH plugin.json and marketplace.json files on v