
Brewdoc:Memory
- 21 installs
- 29 repo stars
- Updated August 2, 2026
- kochetkov-ma/claude-brewcode
Helps with ai & agent building tasks.
About
brewdoc:memory is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.
- brewdoc:memory
- AI & Agent Building
- AI-coding skill
Brewdoc:Memory by the numbers
- 21 all-time installs (skills.sh)
- +1 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #10,307 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 3, 2026 (Skillselion catalog sync)
npx skills add https://github.com/kochetkov-ma/claude-brewcode --skill brewdocmemoryAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 21 |
|---|---|
| repo stars | ★ 29 |
| Last updated | August 2, 2026 |
| Repository | kochetkov-ma/claude-brewcode ↗ |
What it does
Helps with ai & agent building tasks.
Files
Memory Optimizer
Optimizes Claude Code memory files through 4 interactive steps.
No `context: fork` — must run in main conversation to spawn agents.
Phase 0: Load Context
0. Determine memory directory (`$MEMORY_DIR`):
CUSTOM_DIR=$(cat .claude/settings.json 2>/dev/null | jq -r '.autoMemoryDirectory // empty')
if [ -n "$CUSTOM_DIR" ]; then
MEMORY_DIR="$(git rev-parse --show-toplevel)/$CUSTOM_DIR"
else
MEMORY_DIR=~/.claude/projects/<hash>/memory
fiRead .claude/settings.json (if exists) → extract autoMemoryDirectory. If set → resolve as <git-root>/<autoMemoryDirectory>. If not set → use legacy ~/.claude/projects/<hash>/memory/ glob pattern.
1. Glob all memory files: $MEMORY_DIR/*.md (or ~/.claude/projects/**/memory/*.md for legacy) 2. Read ~/.claude/CLAUDE.md and project CLAUDE.md (if exists) 3. Glob .claude/rules/*.md — read all project rules 4. Read ~/.claude/rules/*.md — read all global rules
Build context map:
memory_dir: $MEMORY_DIR
memory_files: [paths]
claude_md_sections: [sections]
rules_files: [paths with content]Step 1: Analysis — Remove Duplicates (Interactive)
Goal: Find memory entries that duplicate content already in CLAUDE.md or rules.
1. Spawn Explore agent to cross-reference all loaded files 2. Identify entries where:
- Same rule already in CLAUDE.md
- Same pattern already in a rules file
- Contradicts CLAUDE.md (CLAUDE.md wins)
3. Show analysis:
Found X duplicate/redundant entries (Y% of memory):
| Entry | Memory File | Already In | Action |
|-------|-------------|------------|--------|
| "Use grepai first" | MEMORY.md:5 | rules/grepai-first.md | DELETE |
...4. AskUserQuestion: "Delete X duplicate entries (Y% of memory)? This is safe — content exists elsewhere." Options: "Yes, delete all" / "Review each" / "Skip this step" 5. Apply deletion via Edit if approved
Step 2: Migration — Move to Rules/CLAUDE.md (Interactive)
Goal: Identify remaining entries better suited to persistent config files.
Decision tree (per entry):
- Applies to ALL projects + IS a rule/constraint →
~/.claude/rules/ - Applies to THIS project only + IS a rule →
.claude/rules/ - IS an architectural decision → project
CLAUDE.md - IS a fact/pattern reusable across sessions → KEEP in memory
1. Show categorization:
X entries suitable for migration:
| Entry | Current Location | Target | Reduction |
|-------|-----------------|--------|-----------|
| "Always use BD_PLUGIN_ROOT" | MEMORY.md:12 | .claude/rules/brewdoc.md | 15 tokens |
...
Total: X entries → ~Y tokens saved2. AskUserQuestion: "Migrate X entries to rules/CLAUDE.md?" Options: "Yes, migrate all" / "Review each" / "Skip this step" 3. If approved: create/append to target rule files via Edit, remove migrated entries from memory, create target file if missing
Step 3: Compression (Interactive)
Goal: Compress remaining entries using LLM-efficient formatting.
Compression techniques:
- Prose → table row
- Multiple related entries → single table
- Verbose description → imperative one-liner
- List of examples → pattern + one example
1. Show compression preview:
Compression opportunities found:
| Before | After | Savings |
|--------|-------|---------|
| "When you need to... always use..." | "Use X for Y" | 8 tokens |
...
Total: ~Y% token reduction (~Z tokens)Show 2-3 specific before/after samples. 2. AskUserQuestion: "Compress remaining memory? (~Y% reduction)" Options: "Yes, compress all" / "Skip compression" 3. Apply compression via Edit (bottom-up order to preserve line numbers)
Step 4: Validation (Automatic)
Goal: Verify final state and clean orphaned references.
1. Spawn reviewer agent to verify:
- No broken file path references in memory files
- No contradictions between memory and CLAUDE.md
- Memory files are well-formed markdown
2. Clean broken references via Edit 3. Check for orphaned memory files (in $MEMORY_DIR with no MEMORY.md reference) 4. Report orphaned files and ask to delete
Final Report:
## Memory Optimization Complete
### Summary
| Metric | Before | After | Saved |
|--------|--------|-------|-------|
| Total entries | X | Y | Z |
| Duplicate entries | X | 0 | — |
| Migrated entries | — | — | X |
| Token estimate | ~X | ~Y | ~Z (~P%) |
### Changes Made
- Step 1: Deleted X duplicate entries
- Step 2: Migrated X entries to rules/CLAUDE.md
- Step 3: Compressed X entries (Y% reduction)
- Step 4: Fixed X broken references, removed X orphaned files
### Final Memory Structure
{directory listing of $MEMORY_DIR}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
Optimizes Claude Code memory files through a 4-step interactive workflow -- removes duplicates, migrates entries to persistent config, compresses remaining content, and validates the final state.
Quick Start
/brewdoc:memoryNo arguments. The skill detects your memory directory automatically and guides you through each step interactively.
How It Works
The skill loads all memory files, CLAUDE.md configs, and rules files into a context map. It then walks you through four steps: deduplication, migration, compression, and validation. Each step shows a preview of proposed changes and asks for your approval before modifying anything.
The 4 Steps
| Step | Name | What Happens | Interactive? |
|---|---|---|---|
| 1 | Remove Duplicates | Finds memory entries already present in CLAUDE.md or rules files, then deletes them | Yes -- choose "delete all", "review each", or "skip" |
| 2 | Migrate to Rules | Moves entries better suited to .claude/rules/ or CLAUDE.md out of memory | Yes -- choose "migrate all", "review each", or "skip" |
| 3 | Compress | Rewrites remaining entries using token-efficient formatting (tables, one-liners) | Yes -- choose "compress all" or "skip" |
| 4 | Validate | Checks for broken references, contradictions, and orphaned files; cleans up automatically | Automatic (asks only if orphaned files found) |
Examples
Good Usage
After many sessions with accumulated memory. Memory files grow over time as Claude saves patterns and facts. Running the optimizer consolidates and trims the bloat.
# Memory has grown to 200+ lines across multiple files
/brewdoc:memory
# Result: 40% token reduction, 12 duplicates removed, 8 entries migrated to rulesBefore a project handoff. Clean memory ensures the next person (or session) gets a concise, non-redundant context.
# Preparing project for another developer
/brewdoc:memory
# Result: memory files are compact, all reusable rules live in .claude/rules/When memory contradicts CLAUDE.md. Over time, memory entries may drift from the authoritative config. The optimizer detects contradictions and resolves them (CLAUDE.md always wins).
Common Mistakes
Running on a fresh project with minimal memory. If you only have a few entries, there is nothing to optimize. Wait until memory has grown meaningfully.
Skipping all steps every run. If you skip deduplication, migration, and compression, the skill does nothing useful. Engage with at least one step for meaningful results.
Running after every single session. The optimizer is most effective after 10+ sessions of accumulated memory. Running it daily on a lightly-used project wastes time.
What Gets Optimized
| Source | Location | What Happens |
|---|---|---|
| Project memory | .claude/projects/<hash>/memory/*.md or custom autoMemoryDirectory | Deduplicated, compressed, validated |
| Global CLAUDE.md | ~/.claude/CLAUDE.md | Read-only -- used as reference for duplicate detection |
| Project CLAUDE.md | ./CLAUDE.md | Read-only reference; migration target for architectural decisions |
| Global rules | ~/.claude/rules/*.md | Read-only reference; migration target for cross-project rules |
| Project rules | .claude/rules/*.md | Read-only reference; migration target for project-specific rules |
Removed: Entries duplicating existing rules or CLAUDE.md content, contradictions (CLAUDE.md wins), broken file references.
Migrated: Rules/constraints moved to .claude/rules/, architectural decisions moved to CLAUDE.md.
Compressed: Prose rewritten as table rows, related entries merged into tables, verbose descriptions replaced with imperative one-liners.
Output
The skill produces a summary report at the end:
## Memory Optimization Complete
### Summary
| Metric | Before | After | Saved |
|----------------|--------|-------|------------|
| Total entries | 45 | 28 | 17 |
| Duplicates | 12 | 0 | -- |
| Migrated | -- | -- | 8 |
| Token estimate | ~1200 | ~720 | ~480 (40%) |
### Changes Made
- Step 1: Deleted 12 duplicate entries
- Step 2: Migrated 8 entries to rules/CLAUDE.md
- Step 3: Compressed 5 entries (25% reduction)
- Step 4: Fixed 1 broken reference, removed 0 orphaned filesFiles modified: memory files in $MEMORY_DIR, and optionally .claude/rules/*.md or CLAUDE.md (migration targets).
Tips
- Run after 10+ sessions when memory has accumulated enough content to benefit from optimization.
- Say "review each" on your first run to understand what the skill considers duplicate or migratable. After that, "delete all" / "migrate all" is safe.
- Check the migration targets after Step 2 -- the skill creates or appends to rules files, so verify the new rules fit your project structure.
- Memory directory auto-detection reads
.claude/settings.jsonfor a customautoMemoryDirectory. If unset, it falls back to the legacy~/.claude/projects/<hash>/memory/path.
Documentation
Full docs: memory
Memory Guide
Decision Tree: Where Does This Information Belong?
Is this information?
├── A rule/constraint (should always apply)
│ ├── Applies to ALL projects → ~/.claude/rules/{topic}.md
│ └── Applies to THIS project only → .claude/rules/{topic}.md
├── An architectural decision (project-specific)
│ └── → project CLAUDE.md (## Architecture or ## Decisions section)
├── A reusable pattern/fact (sessions may forget)
│ └── → MEMORY.md (or topic file linked from MEMORY.md)
└── Session-specific context (current task state)
└── → DO NOT save (ephemeral, delete if found)File Location Map
| Content Type | Location | Format |
|---|---|---|
| Global rules | ~/.claude/rules/*.md | Table: # \ |
| Project rules | .claude/rules/*.md | Same format |
| Global instructions | ~/.claude/CLAUDE.md | Sections + tables |
| Project instructions | CLAUDE.md or .claude/CLAUDE.md | Sections |
| Cross-session memory | ~/.claude/projects/{hash}/memory/MEMORY.md | Sections by topic |
| Topic memory | ~/.claude/projects/{hash}/memory/{topic}.md | Linked from MEMORY.md |
Compression Patterns
| Pattern | Before | After | Savings |
|---|---|---|---|
| Prose → imperative | "When you need to update files, you should always use Edit tool..." | "Use Edit (not Write) for existing files" | ~70% |
| List → table row | "Avoid: X. Instead: Y. Because: Z" | `\ | X \ |
| Multiple facts → table | 3 separate entries about the same topic | 1 table row per entry | ~30% |
| Verbose → concise | "It is important to note that..." | Remove filler | ~20% |
Duplicate Detection
An entry IS a duplicate if: 1. Same rule appears in CLAUDE.md (exact or paraphrase) 2. Same pattern in a rules file 3. References a pattern that's been generalized in CLAUDE.md
An entry is NOT a duplicate if: 1. More specific than the CLAUDE.md version (add detail, not replace) 2. Context-specific exception to a general rule 3. Recent discovery not yet in CLAUDE.md
Compression Examples
Before:
## Plugin Development (2026-01-15)
When developing Claude Code plugins, you should always remember to update BOTH plugin.json and marketplace.json files when bumping the version number, otherwise autocomplete functionality will break because the versions won't match.After:
## Plugin Dev
| Rule | Why |
|------|-----|
| Update BOTH plugin.json + marketplace.json on version bump | Autocomplete breaks on mismatch |Bottom-Up Editing
Always apply edits in descending line number order: 1. Sort all changes by line number (descending) 2. Apply from last line to first 3. This preserves line numbers for subsequent edits