Skill in 《Agent Memory Implementation Guide》

Skill Description

Restructures a bloated or chaotic MEMORY.md into the 2-layer architecture Claude Code's autoDream service uses internally — keeping the always-loaded index lean and topic files on-demand, so the extraction agent can deduplicate and maintain memory correctly.

Skill.md

Agent Memory Implementation Guide

Claude Code's memory system has a hard ceiling: MEMORY.md only loads the first 200 lines (from src/memdir/memdir.ts: MAX_ENTRYPOINT_LINES = 200). On long-running projects, the index tends to bloat past this limit — and when it does, Claude silently forgets everything beyond line 200. No error, no warning. The tech stack choices you taught it, the workflow preferences, the architectural decisions — they vanish until you restructure.

This skill is grounded in Claude Code's source code (services/autoDream/, services/extractMemories/, src/memdir/) and restructures a chaotic memory directory into the 2-layer architecture that autoDream actually expects.

Core Architecture

LayerFileRole
Layer 1MEMORY.mdAlways-loaded pointer index, ≤200 lines, one - [Title](file.md) — hook per entry
Layer 2*.md topic filesOn-demand knowledge, with YAML frontmatter (name, description, type)

No third layer. autoDream does not maintain an archive/ directory — stale facts are corrected or deleted in place. The memory directory is always the current truth, not a history log.

Supported Use Cases

  • MEMORY.md exceeds 200 lines and tail entries are being silently truncated
  • The index contains inline content (paragraphs, code blocks, historical decisions) instead of pointers
  • Topic files are missing frontmatter or have vague descriptions, causing autoDream to create duplicate files
  • Taking over a project with stale memory facts (old library versions, deprecated dependencies)
  • autoDream created near-duplicate files after a long session

How to Use It

Say to Claude:

  • "Clean up my MEMORY.md"
  • "My memory files are a mess — restructure them"
  • "MEMORY.md is almost 200 lines, prune it"
  • "These description fields are too vague, fix them"

Included Tool

scripts/memory_audit.py — scans your memory directory and prints a health report: line count, broken pointers, missing frontmatter, invalid type fields, and files not updated in over 30 days.

Limitations

This skill is based on observed behavior from Claude Code's source code. autoDream is an evolving feature — Anthropic may change internal implementation details. If you're on an older Claude Code version, some specifics (like the exact MAX_ENTRYPOINT_LINES value) may differ. Run the audit script first to measure your actual state before restructuring.

Install & Use

Install command

npx skills add simbajigege/book2skills/skills/agent-memory-implementation
OR

Direct download

Related Skills

Tool Permission System AI Skill

Design a configurable, layered permission/safety system for agent tools: one permission pipeline decides allow / ask / deny across enterprise/user/project scopes.

Session Dream AI Skill

On-demand session memory distillation — extracts key decisions, eliminated approaches, new discoveries, and current b...

Compact with Memory AI Skill

Executes /compact correctly — generates a high-quality conversation summary that preserves reasoning, decisions, and ...

Harness Step 1 — Create AGENTS.md & Knowledge Base AI Skill

Scans your codebase and generates AGENTS.md (the agent's orientation file) plus a complete docs/ knowledge base skele...

Compact Memory Implementation Guide AI Skill

A developer implementation guide for adding compact memory to an Agent built with the Anthropic API or Claude Agent S...

Harness Step 3 — Session State Management AI Skill

Creates init.sh (environment health check), tasks.json (structured task queue), and progress.md (append-only session ...

LangChain Tool Builder AI Skill

Build LangChain (Python) tools using Claude Code's fail-closed design pattern — unified name, schema, security, and e...

Harness Step 2 — Fill docs/ with Real Content AI Skill

Deep-reads your codebase and fills every docs/ file with specific, accurate content grounded in what the code actuall...

Query Loop Implementation AI Skill

Implement a production-ready LLM query loop for AI applications: tool calling, structured tool_result feedback, ReAct...

Contract Drafting and Review Guide (Chinese Law) AI Skill

Apply the San Guan Si Bu Fa method to draft and review China-law contracts through transaction structure, contract st...

Creating Superfans AI Skill

Apply Brittany Hodak's SUPER Model from Creating Superfans to turn ordinary customers into advocates through story, c...