Token导航 LogoToken导航TokenDH.com
研究检索执行命令github未标认证来源可访问许可证需确认审计提醒

defragmenting-memory整理内存碎片

Agent Skill

defragmenting-memory 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

630

周安装

26

GitHub Stars

2,402

下载量

206
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:defragmenting-memory(整理内存碎片)
来源仓库:https://github.com/letta-ai/letta-code
仓库路径:skills/defragmenting-memory
安装命令:
npx skills add https://github.com/letta-ai/letta-code --skill defragmenting-memory
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/letta-ai/letta-code --skill defragmenting-memory

简介

用于重组内存文件系统内的碎片化记忆块,提升信息组织效率。

  • 通过子代理分解大型记忆文件,实现原位优化与结构重整。
  • 专注于拆分复杂条目而非内容创作,保持原始语义完整性。
  • 需启用Memory Filesystem功能方可使用,否则无法操作内存文件。
  • defragmenting-memory 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Memory Defragmentation Skill

Requires Memory Filesystem (memfs) This skill works by directly editing memory files on disk. It requires the memory filesystem feature to be enabled. To check: Look for a memory_filesystem block in your system prompt. If it shows a tree structure starting with /memory/ including a system/ directory, memfs is enabled. To enable: Ask the user to run /memfs enable, then reload the CLI.

This skill helps you maintain clean, well-organized memory blocks by spawning a subagent to decompose and reorganize memory files in-place.

The focus is on decomposition—splitting large, multi-purpose blocks into focused, single-purpose components—rather than consolidation.

Memory files live at ~/.letta/agents/$LETTA_AGENT_ID/memory/ and are synced to API blocks automatically by memfs sync on CLI startup.

When to Use

  • Memory blocks have redundant information
  • Memory lacks structure (walls of text)
  • Memory contains contradictions
  • Memory has grown stale or outdated
  • After major project milestones
  • Every 50-100 conversation turns

Workflow

Step 1: Commit Current State (Safety Net)

The memory directory is a git repo. Commit the current state so you can rollback if needed:

cd ~/.letta/agents/$LETTA_AGENT_ID/memory
git add -A
git commit -m "chore: pre-defrag snapshot" || echo "No changes to commit"

⚠️ CRITICAL: You MUST commit before proceeding. This is your rollback point.

Step 2: Spawn Subagent to Edit Memory Files

The memory subagent works directly on the memfs system/ directory. After it finishes, memfs sync will propagate changes to the API on next CLI startup.

Task({
  subagent_type: "memory",
  run_in_background: true,
  description: "Decompose and reorganize memory files",
  prompt: `You are decomposing and reorganizing memory files in ~/.letta/agents/${LETTA_AGENT_ID}/memory/system/ to improve clarity and focus.

These files ARE the agent's memory — they sync directly to API memory blocks via memfs. Changes you make here will be picked up automatically.

## Directory Structure

~/.letta/agents/<agent-id>/memory/
├── system/       ← Attached blocks (always loaded in system prompt) — EDIT THESE
├── notes.md      ← Detached blocks at root level (on-demand) — can create here
├── archive/      ← Detached blocks can be nested too
└── .sync-state.json  ← DO NOT EDIT (internal sync tracking)

## Files to Skip (DO NOT edit)
- memory_filesystem.md (auto-generated tree view)
- .sync-state.json (internal)

## What to Edit
- persona.md → Consider splitting into: persona/identity.md, persona/values.md, persona/approach.md
- project.md → Consider splitting into: project/overview.md, project/architecture.md, project/conventions.md, etc.
- human.md → Consider splitting into: human/identity.md, human/preferences.md, etc.
- Any other non-system blocks present

## How Memfs File ↔ Block Mapping Works
- File path relative to memory root becomes the block label (system/ prefix for attached, root level for detached)
- Example: system/project/tooling/bun.md → block label "project/tooling/bun"
- New files you create will become new memory blocks on next sync
- Files you delete will cause the corresponding blocks to be deleted on next sync
- YAML frontmatter is supported for metadata (label, description, limit, read_only)

## Evaluation Criteria

1. **DECOMPOSITION** - Split large, multi-purpose blocks into focused, single-purpose components
   - Example: A "persona" block mixing identity, values, AND approach should become persona/identity.md, persona/values.md, persona/approach.md
   - Example: A "project" block with overview, architecture, conventions, and gotchas should split into project/overview.md, project/architecture.md, project/conventions.md, project/gotchas.md
   - Goal: Each block should have ONE clear purpose described by its filename
   - Use hierarchical / naming (e.g., project/tooling/bun.md, not project-tooling-bun.md)

2. **STRUCTURE** - Organize content with clear markdown formatting
   - Use headers (##, ###) for subsections
   - Use bullet points for lists
   - Make content scannable at a glance

3. **CONCISENESS** - Remove redundancy and unnecessary detail
   - Eliminate duplicate information across blocks
   - Remove speculation ("probably", "maybe", "I think")
   - Keep only what adds unique value

4. **CLARITY** - Resolve contradictions and improve readability
   - If blocks contradict, clarify or choose the better guidance
   - Use plain language, avoid jargon
   - Ensure each statement is concrete and actionable

5. **ORGANIZATION** - Group related information logically
   - Within each block, organize content from general to specific
   - Order sections by importance

## Workflow

1. **Analyze** - Read each file and identify its purpose(s)
   - If a block serves 2+ distinct purposes, it needs decomposition
   - Flag blocks where subtopics could be their own focused blocks

2. **Decompose** - Split multi-purpose blocks into specialized files
   - Create new files using hierarchical paths (e.g., project/tooling/bun.md)
   - Ensure each new block has ONE primary purpose

3. **Clean Up** - For remaining blocks (or new focused blocks):
   - Add markdown structure with headers and bullets
   - Remove redundancy
   - Resolve contradictions
   - Improve clarity

4. **Delete** - Remove files only when appropriate
   - After moving all content to new decomposed files
   - Never delete a focused, single-purpose block
   - Only delete if a block contains junk/irrelevant data with no value

## Success Indicators
- No block tries to cover 2+ distinct topics
- Each block title clearly describes its single purpose
- Content within each block is focused and relevant to its title
- Well-organized with markdown structure
- Clear reduction in confusion/overlap across blocks

Provide a detailed report including:
- Files created (new decomposed blocks)
- Files modified (what changed)
- Files deleted (if any, explain why)
- Before/after character counts
- Rationale for how decomposition improves the memory structure`
})

The subagent will:

  • Read files from ~/.letta/agents/<agent-id>/memory/system/ (and root level for detached)
  • Edit them to reorganize and decompose large blocks
  • Create new hierarchically-named files (e.g., project/overview.md)
  • Add clear structure with markdown formatting
  • Delete source files after decomposing their content into focused children
  • Provide a detailed report of changes

After the subagent finishes, memfs sync will automatically propagate changes to API blocks on the next CLI startup. No manual restore step is needed.

Step 3: Commit Changes

After the subagent finishes, commit the changes:

cd ~/.letta/agents/$LETTA_AGENT_ID/memory
git add -A
git commit -m "chore: defragment memory blocks"
git push

Example Complete Flow

// Step 1: Commit current state (MANDATORY)
Bash({
  command: "cd ~/.letta/agents/$LETTA_AGENT_ID/memory && git add -A && git commit -m 'chore: pre-defrag snapshot' || echo 'No changes'",
  description: "Commit current memory state as rollback point"
})

// Step 2: Spawn subagent to decompose and reorganize (runs async in background)
Task({
  subagent_type: "memory",
  run_in_background: true,
  description: "Decompose and reorganize memory files",
  prompt: "Decompose and reorganize memory files in ~/.letta/agents/$LETTA_AGENT_ID/memory/system/. These files sync directly to API blocks via memfs. Be aggressive about splitting large multi-section blocks into many smaller, single-purpose blocks using hierarchical / naming. Skip memory_filesystem.md and .sync-state.json. Structure with markdown headers and bullets. Remove redundancy and speculation. Resolve contradictions. Organize logically. Each block should have ONE clear purpose. Report files created, modified, deleted, before/after character counts, and rationale for changes."
})

// Step 3: After subagent completes, commit and push
// Check progress with /task <task_id>, restart CLI to sync when done

Rollback

If something goes wrong, use git to revert:

cd ~/.letta/agents/$LETTA_AGENT_ID/memory

# Option 1: Reset to last commit (discard all uncommitted changes)
git reset --hard HEAD~1

# Option 2: View history and reset to specific commit
git log --oneline -5
git reset --hard <commit-hash>

# Push the rollback
git push --force

On next CLI startup, memfs sync will detect the changes and update API blocks accordingly.

What the Subagent Does

The subagent focuses on decomposing and cleaning up files. It has full tool access (including Bash) and:

  • Discovers .md files in ~/.letta/agents/<agent-id>/memory/system/ (via Glob or Bash)
  • Reads and examines each file's content
  • Identifies multi-purpose blocks that serve 2+ distinct purposes
  • Splits large blocks into focused, single-purpose components with hierarchical naming
  • Modifies/creates.md files for decomposed blocks
  • Improves structure with headers and bullet points
  • Removes redundancy and speculation across blocks
  • Resolves contradictions with clear, concrete guidance
  • Organizes content logically (general to specific, by importance)
  • Provides detailed before/after reports including decomposition rationale
  • Does NOT run any git commands (parent agent handles that)

The focus is on decomposition—breaking apart large monolithic blocks into focused, specialized components rather than consolidating them together.

Tips

What to clean up:

  • Duplicate information (consolidate into one well-organized section)
  • Walls of text without structure (add headers and bullets)
  • Contradictions (resolve by clarifying or choosing the better guidance)
  • Speculation ("probably", "maybe" - make it concrete or remove)
  • Transient details that won't matter in a week

Decomposition Strategy:

  • Split blocks that serve 2+ distinct purposes into focused components
  • Use hierarchical / naming: project/tooling/bun.md, not project-bun.md
  • Create parent index files that reference children
  • Example: A "persona" mixing identity + values + approach → split into persona/identity.md, persona/values.md, persona/approach.md
  • Example: A "project" with overview + architecture + conventions → split into project/overview.md, project/architecture.md, project/conventions.md
  • Add clear headers and bullet points for scannability
  • Group similar information together within focused blocks

When to DELETE a file:

  • Only delete if file contains junk/irrelevant data with no project value
  • Delete source files after fully decomposing content into child files
  • Don't delete unique information just to reduce file count

What to preserve:

  • User preferences (sacred - never delete)
  • Project conventions discovered through experience
  • Important context for future sessions
  • Learnings from past mistakes
  • Any information that has unique value

Good memory structure:

  • Use markdown headers (##, ###)
  • Organize with bullet points
  • Keep related information together
  • Make it scannable at a glance
  • Use / hierarchy for discoverability

适合场景

01

研究助手

02

事实核查

03

知识库问答

04

带来源的搜索总结

能力概览

能力 1

组合搜索和大模型调用

能力 2

支持多来源检索和总结

能力 3

强调引用来源和事实核查

能力 4

适合研究型 Agent 流程

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

39.97%
按下载量换算82

Claude

30.29%
按下载量换算62

Cursor

17.87%
按下载量换算37

Gemini CLI

9.26%
按下载量换算19

安全审计

Gen Agent Trust Hub

通过

Socket

可疑

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/letta-ai/letta-code --skill defragmenting-memory 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills