Lance Martin's Claude Diary

Table of content
Lance Martin's Claude Diary

Lance Martin is a software engineer at LangChain who created Claude Diary, a plugin that gives Claude Code the ability to learn from experience and update its own memory. The idea: humans refine their skills through reflection, so agents should too.

Background

GitHub | Twitter | Blog

The Problem with Agent Memory

Most agents are stateless across sessions. They forget what they learned, repeat the same mistakes, and never adapt to your preferences. Martin noticed this gap after extensive work on context engineering.

His solution draws from the CoALA paper (Sumers et al. 2023), which proposes three memory types:

Memory TypePurposeExample
ProceduralInstructions that steer behaviorCLAUDE.md rules
EpisodicExamples of desired behaviorPast session logs
SemanticTask-relevant factsProject-specific context

Claude Diary focuses on procedural memory, turning session experiences into persistent rules.

How Claude Diary Works

The plugin adds two slash commands:

/diary captures what happened in a session:

Entries save to ~/.claude/memory/diary/YYYY-MM-DD-session-N.md.

/reflect analyzes diary entries for patterns:

The reflection process tracks processed entries in processed.log to avoid duplicate analysis.

# Manual diary entry
/diary

# Automatic via PreCompact hook
# Triggers before context compaction

What It Learns

After a month of use, Martin’s CLAUDE.md accumulated rules about:

CategoryExample Rules
Git workflowUse atomic commits, specific branch naming
TestingRun targeted tests first for quick feedback
Code patternsPrefer composition over inheritance
Token efficiencyCompress verbose explanations
PR feedbackAddress reviewer comments systematically

Each rule is a single imperative line. The system strengthens weak rules when they’re violated and adds new rules when patterns emerge.

Architecture

The system follows the generative agents framework:

  1. Observations - Raw session conversations recorded as diary entries
  2. Reflection - Pattern identification across multiple entries
  3. Retrieval - Rules loaded into future sessions via CLAUDE.md

Martin kept reflection manual (not fully automated) so users can review proposed changes before committing them to CLAUDE.md.

Context Engineering Background

Claude Diary emerged from Martin’s broader work on context engineering, which he defines as populating an LLM’s context window with the right information at each step.

Four strategies from his framework:

StrategyMethod
Write contextSave scratchpads and memories for later
Select contextRetrieve relevant information via RAG
Compress contextSummarize long trajectories
Isolate contextSplit work across sub-agents

Claude Diary implements the “write context” strategy for procedural memory specifically.

Key Takeaways

PrincipleImplementation
Agents should learnBuild feedback loops from sessions to instructions
Memory needs structureSeparate procedural, episodic, and semantic
Reflection beats loggingTransform experiences into actionable rules
Manual review mattersLet humans approve memory updates

Next: Harper Reed’s LLM Codegen

Topics: claude-code agents automation knowledge-management