Agent skill

defragmenting-memory

Decomposes and reorganizes agent memory files into focused, single-purpose components. Use when memory has large multi-topic blocks, redundancy, or poor organization. Trigger phrases: "defrag memory", "reorganize memory", "clean up memory files", "split memory blocks".

Stars 53
Forks 5

Install this agent skill to your Project

npx add-skill https://github.com/edmundmiller/dotfiles/tree/main/pi-packages/pi-context-repo/skills/defragmenting-memory

SKILL.md

Memory Defragmentation

Requires context-repo extension with memory at .pi/memory/

Splits large, multi-purpose memory blocks into focused single-purpose files with hierarchical / naming.

When to Use

  • Memory blocks have redundant information
  • Files mix multiple unrelated topics
  • Memory lacks structure (walls of text)
  • After major project milestones
  • Every 50-100 conversation turns

Workflow

Step 1: Backup (MANDATORY)

Use the memory_backup tool before proceeding. This is your safety net.

Step 2: Analyze Current Memory

bash
find .pi/memory -name '*.md' | while read f; do
  echo "=== $f ($(wc -l < "$f") lines) ==="
  head -5 "$f"
  echo
done

For each file, determine:

  • Does it serve 2+ distinct purposes? → needs splitting
  • Is it >40 lines? → candidate for splitting
  • Does it overlap with another file? → consolidate

Step 3: Decompose

Split multi-purpose blocks into focused files using hierarchical naming:

Before:

system/project.md  (80 lines mixing overview, tooling, conventions, gotchas)

After:

system/project/overview.md
system/project/tooling.md
system/project/conventions.md
system/project/gotchas.md

Use memory_write for each new file, then delete the original:

bash
rm .pi/memory/system/project.md

Step 4: Clean Up

For each file (new and existing):

  • Add markdown structure (headers, bullets)
  • Remove redundancy across files
  • Remove speculation ("probably", "maybe")
  • Keep only actionable, concrete information
  • Resolve contradictions

Step 5: Commit

memory_commit({ message: "refactor: defragment memory — split N files into M focused blocks" })

Step 6: Report

Provide a summary:

  • Files created (new decomposed blocks)
  • Files modified (what changed)
  • Files deleted (if any, explain why)
  • Before/after file counts and line counts

Evaluation Criteria

  1. DECOMPOSITION — Each file has ONE clear purpose described by its filename
  2. STRUCTURE — Headers, bullets, scannable at a glance
  3. CONCISENESS — No redundancy, no speculation, only unique value
  4. CLARITY — Contradictions resolved, plain language, actionable
  5. ORGANIZATION — General to specific within files, important first

Naming Rules

  • Use / hierarchy: project/tooling/testing.md (not project-tooling-testing.md)
  • 2-3 levels of nesting
  • ~40 lines max per file
  • Descriptive frontmatter descriptions

What to Preserve

  • User preferences (sacred — never delete)
  • Project conventions discovered through experience
  • Important context for future sessions
  • Learnings from past mistakes

Rollback

If something goes wrong:

/memory-backups     # list available backups
/memory-restore <backup-name>

Expand your agent's capabilities with these related and highly-rated skills.

edmundmiller/dotfiles

zbench

Benchmark interactive zsh performance with zsh-bench and track regressions. Use when benchmarking shell startup, comparing zsh latency after config changes, investigating slow shell, or running git bisect on performance. Trigger phrases: "benchmark zsh", "shell is slow", "zbench", "zsh-bench", "shell startup time", "profile zsh", "zsh performance".

53 5
Explore
edmundmiller/dotfiles

nix-rebuild

Rebuild nix-darwin/NixOS system after dotfiles changes. Use when config files managed by Nix (lazygit, ghostty, etc.) need to be regenerated, or after editing any .nix file in the dotfiles repo.

53 5
Explore
edmundmiller/dotfiles

hass-config-flow

Interact with Home Assistant via the REST API on a NixOS host. Use when adding integrations, querying entities, managing config flows, creating API tokens, or automating HA setup programmatically. Also covers identifying device protocols (Matter, Zigbee, Thread, HomeKit) from the device registry. Trigger phrases: "add HA integration", "configure home assistant", "query HA entities", "create HA token", "HA REST API", "pair homekit", "set up matter in HA", "add spotify to HA", "is this device zigbee or thread", "what protocol is this device", "move devices to ZHA", "identify matter devices".

53 5
Explore
edmundmiller/dotfiles

hass-declarative

Manage Home Assistant automations, scenes, and scripts declaratively via NixOS modules. Covers adding/editing/removing entities in the domain-based Nix structure, the ensureEnabled wrapper (initial_state enforcement), the sweep service that cleans orphaned entities, entity identity (IDs, slugs, unique_ids), the eval test assertions, and the build-time manifest. Trigger phrases: "add HA automation", "new scene", "new script", "remove automation", "declarative HA", "sweep unmanaged", "entity drift", "ghost entity", "orphaned automation", "HA domain file", "eval-automations test", "hass assertion", "ensureEnabled", "initial_state".

53 5
Explore
edmundmiller/dotfiles

agenix-secrets

Create, edit, and wire up agenix-encrypted secrets in this dotfiles repo. Use when adding API keys, tokens, credentials, passwords, or any sensitive values to NixOS host configs. Trigger phrases: "add a secret", "encrypt with agenix", "new age secret", "hide this value", "agenix secret".

53 5
Explore
edmundmiller/dotfiles

linear

Read-only Linear issue access via the Linear GraphQL API.

53 5
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results