1
0
Fork 0
claude-code-complete-agent/examples/05-memory-system/prompt.md
Kjell Tore Guttormsen 0d0b83f98c feat: make examples cumulative with carry-forward chain and capstone
Add three new sections to all 14 examples:
- "Carry Forward": what output feeds into later examples (01-10)
- "The Cumulative Path": alternative prompt building on previous output (02-10)
- "Now Try It Yourself": personalized template with transferable pattern (all)
- "Building On" callout connecting back to previous examples (02-10)

Add Example 14: Build Your Personal Agent - capstone that guides reader
through writing their own CLAUDE.md, creating a personal skill, connecting
a messaging channel, setting up automation, and testing end-to-end.

Update README with cumulative path diagram, two usage modes, and example 14.
Update GETTING-STARTED.md with cross-references to relevant examples.

17 files changed, 703+ lines added. The examples now form a coherent
learning path from "see what it can do" to "build your own agent."

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 21:14:35 +01:00

4.9 KiB

Example 05: Memory System

Capability: Claude Code maintains persistent memory across sessions through a hierarchy of markdown files. What is written in one session is available in the next.

OpenClaw equivalent: Daily markdown logs + MEMORY.md + vector search (SQLite-vec).

Building on Examples 01-03. You have produced research (01), organized it (02), and verified it (03). This example shows how to save that state so your next session picks up where you left off. Without memory, every session starts from scratch.


How the Hierarchy Works

Claude Code loads context in this order, from broadest to narrowest:

  1. ~/.claude/CLAUDE.md - global preferences, always loaded
  2. CLAUDE.md in the project root - project-specific config, always loaded
  3. memory/MEMORY.md - session state, loaded if referenced in CLAUDE.md
  4. .claude/ managed memory - auto-updated by Claude when --memory is active

The file loaded earlier provides the frame. Later files narrow it.


The Prompt

Read this project's CLAUDE.md and summarize what you learn about the project
in three bullet points.

Then create a file at memory/project-notes.md with:
- Today's date as a header
- The three-bullet summary
- A note that says "Memory system demonstrated successfully"

Finally, explain in one paragraph how this file will be available in the
next Claude Code session without re-reading CLAUDE.md.

What Happens

Claude Code will:

  1. Use Read to load CLAUDE.md from the project root
  2. Synthesize the project context into three bullets
  3. Use Write to create memory/project-notes.md
  4. Explain how CLAUDE.md references cause files to be auto-loaded

Expected Output

Claude creates memory/project-notes.md and then explains how memory works. The file will look like:

# March 26, 2026

- This is a companion repo comparing OpenClaw and Claude Code capabilities
- It contains 13 examples, agents, skills, hooks, and documentation
- The project maps 22 OpenClaw features to Claude Code equivalents

Memory system demonstrated successfully.

Claude will then explain something like:

"This file is inside the memory/ directory, which is referenced in CLAUDE.md. Because Claude Code loads CLAUDE.md at every session start, and CLAUDE.md mentions the memory directory, files here persist across sessions without any extra setup."

How you know it worked:

  • memory/project-notes.md exists and contains today's date
  • The three bullets accurately summarize what CLAUDE.md says
  • Claude's explanation mentions the CLAUDE.md hierarchy

Why This Matters

OpenClaw uses SQLite-vec for semantic memory search across sessions. Claude Code uses structured markdown with explicit file references. Both achieve persistence. The markdown approach is more inspectable: you can read, edit, and version control every piece of memory Claude has about your project.

The memory/MEMORY.md file in this repo shows the pattern at scale.


Carry Forward

Memory is what turns a collection of examples into a persistent workflow. From here:

  • Example 06 uses the project context (loaded from CLAUDE.md) to guide agents
  • Example 08 relies on memory to know what cron jobs have run and what to do next
  • Example 10 writes pipeline execution logs to memory after every run

Without this capability, each session would start blind. With it, Claude knows what you did yesterday and what needs attention today.


The Cumulative Path

If you ran Examples 01-03, you have a research report in pipeline-output/research-report/. This prompt saves its state to memory.

Read this project's CLAUDE.md, then read all files in
pipeline-output/research-report/.

Create memory/research-state.md with:
- Today's date
- What topic was researched
- What files exist and their status (raw, verified, etc.)
- What the next step should be (multi-agent review in Example 06)

Then explain how this file will be available in the next Claude Code
session without re-reading the research files.

After running this, your pipeline has persistent state. If you close the session and come back tomorrow, Claude knows exactly where you left off.


Now Try It Yourself

Replace the demo with a memory entry for your actual work:

Read CLAUDE.md and summarize the current state of [your project].
Create memory/[your-topic]-state.md with:
- Today's date
- Current status and recent progress
- Open questions or blockers
- Suggested next steps

Explain how this persists across sessions.

The pattern you just learned: read context + synthesize state + write to memory. Any information you want Claude to remember across sessions goes into a file referenced from CLAUDE.md.

Ideas worth trying:

  • Project status notes that update automatically at end of each session
  • A running log of decisions made and their rationale
  • A list of recurring tasks and when they were last completed