← 返回
未分类 中文

Memory Defragmenter

Defragment and optimize agent memory files by cleaning duplicates, merging similar entries, archiving stale content, and ensuring proper tiering. Use when: (...
对代理记忆文件进行碎片整理和优化,清理重复项、合并相似条目、归档陈旧内容并确保层级划分合理。适用场景:(...
klemenska
未分类 clawhub v1.0.1 1 版本 99762.5 Key: 无需
★ 0
Stars
📥 420
下载
💾 1
安装
1
版本
#latest

概述

Memory Defragmenter

Clean, merge, and optimize memory files to keep them lean and effective.

Purpose

Memory files grow over time and become:

  • Bloated with duplicates
  • Stale with outdated info
  • Scattered across tiers
  • Inconsistent in format

This skill defragments them.

When to Run

TriggerAction
-----------------
Weekly maintenanceFull defragment
Before context optimizationClean first
After many sessionsRemove stale entries
Explicit requestClean specified files

Defragmentation Workflow

Step 1: Analyze Memory State

python3 scripts/analyze_memory.py

Reports:

  • Files analyzed and sizes
  • Duplicate detection
  • Stale entry detection (30+ days old)
  • Tier distribution
  • Formatting consistency

Step 2: Generate Defragmentation Plan

python3 scripts/defragment.py --plan

Creates defragment-plan.md with:

  • Entries to merge
  • Entries to archive
  • Entries to delete
  • Entries to promote/demote

Step 3: Review Plan

Read the plan and approve/modify before execution.

Step 4: Execute Defragmentation

python3 scripts/defragment.py --execute

Backs up original files first, then:

  • Merges duplicate entries
  • Archives stale content to archive/
  • Promotes hot entries to HOT tier
  • Demotes cold entries to archive
  • Normalizes formatting

Step 5: Verify

python3 scripts/verify_memory.py

Checks:

  • All files readable
  • No broken links
  • Consistent formatting
  • Tier limits respected

Memory Tiers Reference

TierLocationMax SizeAge Policy
--------------------------------------
HOTmemory.md, ~/self-improving/memory.md≤100 lines eachReview monthly
WARMmemory/*.md, ~/self-improving/domains/≤200 lines eachReview quarterly
COLDarchive/UnlimitedArchive at 90 days

Safety Rules

  1. Always backup before executing
  2. Review plan before applying
  3. Never delete - only archive
  4. Keep originals for 24h after
  5. Verify after every defragment

Files

  • scripts/analyze_memory.py — Analyze memory state
  • scripts/defragment.py — Plan and execute cleanup
  • scripts/verify_memory.py — Verify integrity
  • references/rules.md — Defragmentation rules and patterns

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-31 08:53 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

Twitter/X API

klemenska
通过API管理X/Twitter消息,包括读取、发布推文、回复、发送私信、搜索和查看分析数据。用于用户与X/Twitter互动场景。
★ 0 📥 1,825

Context Window Optimizer

klemenska
优化上下文窗口使用,通过总结旧对话片段,提取关键事实和决定存入永久记忆,并保持当前上下文精简
★ 0 📥 436

Klemenska Security Auditor

klemenska
对已安装技能进行安全扫描与审计,检测风险、可疑行为及权限过度。使用场景:①安装新技能前;②定期检查。
★ 0 📥 334