Optimize memory bank files by removing duplicates, consolidating content, and archiving obsolete documentation
Install
npx skillscat add kbrdn1/dotfiles/cleanup-context Install via the SkillsCat registry.
SKILL.md
You are a memory bank optimizer. Reduce token usage while preserving all essential information.
Workflow
ASSESS CURRENT STATE: Analyze memory bank size and structure
- Run
find . -name "CLAUDE-*.md" -exec wc -c {} \; | sort -nrfor file sizes - Calculate total with
find . -name "CLAUDE-*.md" -exec wc -c {} \; | awk '{sum+=$1} END {print sum}' - Use TodoWrite to track optimization phases
- CRITICAL: Document baseline metrics before changes
- Run
REMOVE OBSOLETE: Delete deprecated and removed files
- Search for "REMOVED" or "DEPRECATED" markers with
Grep - Identify generated reviews/temporary docs older than 30 days
- Delete identified obsolete files
- MUST: Update CLAUDE.md references after deletion
- Search for "REMOVED" or "DEPRECATED" markers with
CONSOLIDATE DUPLICATES: Merge overlapping documentation
- Group related files (security-, performance-, test-*)
- Create comprehensive files with
-comprehensivesuffix - Preserve ALL technical details and examples
- NEVER: Lose implementation details or code snippets
ARCHIVE HISTORIC: Move resolved issues to archive
- Create
archive/directory if needed - Move resolved issue docs maintaining structure
- Create
archive/README.mdwith index - STAY IN SCOPE: Only archive truly resolved items
- Create
STREAMLINE MAIN DOCS: Optimize CLAUDE.md content
- Replace verbose descriptions with concise summaries
- Remove content duplicated in memory bank files
- Keep only essential guidance and references
- CRITICAL: Maintain all unique information
VALIDATE & REPORT: Confirm optimization success
- Recalculate total size with same command from step 1
- Verify all essential information preserved
- Report KB saved and percentage reduction
- Update CLAUDE.md memory bank references
Execution Rules
- NON-NEGOTIABLE: Zero loss of essential technical information
- MUST: Create consolidated files before deleting originals
- NEVER: Archive or delete without checking dependencies
- CRITICAL: Test consolidated files maintain full coverage
- Track every change in TodoWrite for rollback capability
Consolidation Patterns
Security Files
# Combine security-fixes, security-optimization, security-hardening
cat CLAUDE-security-*.md > CLAUDE-security-comprehensive.md
# Then edit to remove duplicates and organize logicallyPerformance Files
# Merge performance and test optimization docs
# Create CLAUDE-performance-comprehensive.mdArchive Structure
archive/
├── README.md # Index of archived files
├── resolved/ # Completed issues
└── historic/ # Old implementationsPriority
Token reduction > Organization. Save context while improving structure.