Skip to content
Back to search

claude-diary

SkillWorks with Claude CodeGitHub

A simple memory system for claude code

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/rlancemartin--claude-diary/badge.svg)](/listings/rlancemartin--claude-diary)

HTML

<a href="/listings/rlancemartin--claude-diary"><img src="/api/listings/rlancemartin--claude-diary/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

1. **Clone this repository**:

git clone https://github.com/rlancemartin/claude-diary claude-diary
cd claude-diary

2. **Install commands**:

cp commands/*.md ~/.claude/commands/

3. **Install PreCompact hook** (for auto-diary generation):

mkdir -p ~/.claude/hooks
cp hooks/pre-compact.sh ~/.claude/hooks/pre-compact.sh
chmod +x ~/.claude/hooks/pre-compact.sh

4. **Configure the hook in settings**:

Add the following to `~/.claude/settings.json` (global) or `.claude/settings.local.json` (project-specific):

   {
     "hooks": {
       "PreCompact": [
         {
           "matcher": "auto",
           "hooks": [
             {
               "type": "command",
               "command": "bash ~/.claude/hooks/pre-compact.sh"
             }
           ]
         }
       ]
     }
   }

Alternatively, use the interactive command:

   /hooks

Then select `PreCompact` event, `auto` matcher, and enter `bash ~/.claude/hooks/pre-compact.sh` as the command.

5. **Use the system**: - Run `/diary` after important sessions (or let the PreCompact hook auto-generate) - After any collection of diary entries, run `/reflect` to analyze patterns - `CLAUDE.md` automatically updated with learnings

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 174 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Claude Diary
  2. A long-term memory plugin for Claude Code that learns from your activity over time and continuously improves Claude's understanding of your preferences, patterns, and workflows.
  3. - **Diary**: Generate a diary entry for any Claude Code session
  4. - **Reflection**: Performs reflection across multiple diary entries
  5. - **Memory**: Reflection updates your `CLAUDE.md` with observed patterns and preferences
  6. Read more: [Blog post](https://rlancemartin.github.io/2025/12/01/claude_diary/)
  7. <img width="951" height="667" alt="cd" src="https://github.com/user-attachments/assets/d0b1deef-b027-4014-b761-67e36c221edc" />
  8. ## Quickstart
  9. 1. **Clone this repository**:
  10. ```bash
  11. git clone https://github.com/rlancemartin/claude-diary claude-diary
  12. cd claude-diary
  13. ```
  14. 2. **Install commands**:
  15. ```bash
  16. cp commands/*.md ~/.claude/commands/
  17. ```
  18. 3. **Install PreCompact hook** (for auto-diary generation):
  19. ```bash
  20. mkdir -p ~/.claude/hooks
  21. cp hooks/pre-compact.sh ~/.claude/hooks/pre-compact.sh
  22. chmod +x ~/.claude/hooks/pre-compact.sh
  23. ```
  24. 4. **Configure the hook in settings**:
  25. Add the following to `~/.claude/settings.json` (global) or `.claude/settings.local.json` (project-specific):
  26. ```json
  27. {
  28. "hooks": {
  29. "PreCompact": [
  30. {
  31. "matcher": "auto",
  32. "hooks": [
  33. {
  34. "type": "command",
  35. "command": "bash ~/.claude/hooks/pre-compact.sh"
  36. }
  37. ]
  38. }
  39. ]
  40. }
  41. }
  42. ```
  43. Alternatively, use the interactive command:
  44. ```bash
  45. /hooks
  46. ```
  47. Then select `PreCompact` event, `auto` matcher, and enter `bash ~/.claude/hooks/pre-compact.sh` as the command.
  48. 5. **Use the system**:
  49. - Run `/diary` after important sessions (or let the PreCompact hook auto-generate)
  50. - After any collection of diary entries, run `/reflect` to analyze patterns
  51. - `CLAUDE.md` automatically updated with learnings
  52. ## Overview
  53. `CLAUDE.md` files serve as [long-term memory](https://code.claude.com/docs/en/memory) for Claude Code. But, they are typically updated manually (e.g., via the `#` shortcut or `/memory` command). This plugin aims to automates the process of updating `CLAUDE.md` with the learnings from your activity over time. It is inspired by [an interview between Dan Shipper and Cat Wu / Boris Cherny from the Claude Code team](https://www.youtube.com/watch?v=IDSAMqip6ms&t=352s), which mentions that some Anthropic employees have started generating diary entries for Claude sessions and performing reflection over them. The approach follows that general flow, and also borrows ideas from the [Generative Agents paper](https://arxiv.org/pdf/2304.03442), which introduces a memory architecture with three key components:
  54. 1. **Observations**: Raw experiences recorded in natural language (like our diary entries)
  55. 2. **Reflection**: Higher-level insights and patterns (like our `/reflect` command)
  56. 3. **Retrieval**: Accessing memories to inform behavior (like reading CLAUDE.md into each session)
  57. <img width="510" height="408" alt="Screenshot 2025-11-22 at 8 54 30 PM" src="https://github.com/user-attachments/assets/36c88072-9958-462e-b020-ad344445912a" />
  58. ### Diary Entries
  59. The `/diary` command creates diary entries from the current session. It uses a context-first approach, reflecting on the conversation already in Claude Code's context, but can also parse JSONL transcripts, which are logged for each session to the project directory. See [diary.md](commands/diary.md) for details. The `diary` command can be run in two ways:
  60. 1. **Automatic**: PreCompact hook runs before conversation compacts (long sessions, 200+ messages). This could be customized to run at different points using different [Claude Code hooks](https://code.claude.com/docs/en/hooks-guide).
  61. 2. **Manual**: Run `/diary` anytime to capture important context in the current session
  62. #### How the Diary Command Works
  63. The command instructs Claude to create diary entries by reflecting on the conversation history in context (user messages, tool invocations, files modified, errors, solutions). It then instructs Claude to write the diary entry to a file in the `~/.claude/memory/diary/` directory as a markdown file with sections for task summary, work done, design decisions, user preferences, code review feedback, challenges, solutions, and code patterns. It instructs Claude to be factual and specific, capture the "why" behind decisions, document ALL user preferences (especially commits/PRs/linting/testing), include failures as learning. The output location is `~/.claude/memory/diary/YYYY-MM-DD-session-N.md`.
  64. ### Reflection
  65. The `/reflect` command analyzes diary entries to identify patterns and automatically updates `CLAUDE.md`. See [reflect.md](commands/reflect.md) for details. The `reflect` command can be run in manually in any session; run `/reflect` anytime you have accumulated diary entries and want to update `CLAUDE.md` with new learnings.
  66. #### How the Reflect Command Works
  67. The reflect command instructs Claude to perform multi-diary pattern analysis. First, it has Claude check `processed.log` to skip already-analyzed diary entries (avoids duplicate analysis). Then, it has Claude recognize patterns that appear repeatedly (2+ occurrences = pattern, 3+ = strong pattern). In particular, it asks Claude to scan for violations of existing CLAUDE.md rules (highest priority for strengthening) and synthesize insights across 6 categories: PR review feedback, persistent preferences, design decisions that worked, anti-patterns to avoid, efficiency lessons, project-specific patterns. Finally, it has Claude auto-update CLAUDE.md with new rules that must be one-line bullets in imperative tone (no verbose explanations).
  68. #### Reflect Command Options
  69. ```bash
  70. # Analyze last 20 unprocessed entries
  71. /reflect last 20 entries
  72. # Analyze specific date range
  73. /reflect from 2025-01-01 to 2025-01-31
  74. # Filter by project
  75. /reflect for project /Users/username/Code/my-app
  76. # Filter by topic/keyword
  77. /reflect related to testing
  78. # Combine filters
  79. /reflect last 15 entries for project /Users/username/Code/my-app related to React
  80. # Re-analyze including already-processed entries
  81. /reflect include all entries
  82. # Re-analyze specific entry
  83. /reflect reprocess 2025-11-07-session-1.md
  84. ```
  85. ## Directory Structure
  86. This plugin follows the [Claude Code plugin structure](https://code.claude.com/docs/en/plugins):
  87. ```
  88. cc-memory/
  89. ├── .claude-plugin/
  90. │ └── plugin.json # Plugin metadata
  91. ├── commands/
  92. │ ├── diary.md # /diary command prompt
  93. │ └── reflect.md # /reflect command prompt
  94. ├── hooks/
  95. │ ├── pre-compact.sh # Auto-diary generation hook
  96. │ └── README.md # Hook installation guide
  97. ├── examples/
  98. │ ├── sample-diary-entry.md # Example diary output
  99. │ └── sample-reflection.md # Example reflection output
  100. ├── INSTALL.md # Installation instructions
  101. ├── LICENSE # MIT License
  102. ├── README.md # Main documentation
  103. ```
  104. To modify or extend:
  105. 1. Edit command files in `commands/`
  106. 2. Test locally using the local marketplace approach
  107. 3. Share your improvements
  108. ## Use Cases
  109. Claude Diary excels at capturing and learning from:
  110. - **PR review feedback**: Automatically incorporate reviewer preferences into future sessions
  111. - **Git workflow**: Learn commit style, branch naming, and message formatting conventions
  112. - **Testing practices**: Capture patterns like running targeted tests first, then comprehensive suites
  113. - **Code quality**: Identify and avoid anti-patterns (naming conflicts, stale directories, verbose code)
  114. - **Agent design**: Learn preferences around token efficiency, delegation patterns, and context management
  115. - **Self-correction**: Reinforce existing CLAUDE.md rules when violations are detected
  116. ## Future work
  117. **Opportunities for improvement**:
  118. 1. **Project-level memory** - Support Claude Code's multiple memory tiers to enable context-appropriate rules (React patterns for React projects, Python conventions for Python projects)
  119. 2. **Session metadata API** - An official API for session introspection would eliminate JSONL parsing workarounds
  120. 3. **Adaptive reflection** - Optionally trigger reflection when N unprocessed entries accumulate, reducing manual overhead while preserving user control
  121. 4. **Memory retrieval** - Proactively surface relevant past learnings based on current context ("Last time you worked on authentication, you preferred JWT")
  122. 5. **Cross-project learning** - Detect when the same problem appears across different projects, suggesting generalizable solutions
  123. ## License
  124. MIT License - feel free to use, modify, and share.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.