Skip to content

geckofu/agent-reflections

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

session-memo

Automatically generates session memo documents at the end of each Claude Code session, using claude --resume so the writing Claude already has full conversation context — no JSONL parsing, no cold start.

How it works

A SessionEnd hook fires when a Claude Code session exits. It:

  1. Reads session_id and cwd from the hook's stdin JSON.
  2. Skips if .claude/session-memo-hook/.ignore-this-project exists in $cwd.
  3. Creates $cwd/sessions/ if it doesn't exist, then runs claude --resume <sessionId> -p "<prompt>", which restores full conversation history and writes a memo to sessions/.

Because claude -p (non-interactive) does not fire hooks itself, there is no feedback loop.

Opt-out per project

The hook runs on all projects by default, creating sessions/ if it doesn't exist. To disable for a specific project:

mkdir -p .claude/session-memo-hook
touch .claude/session-memo-hook/.ignore-this-project

Install

1. Copy both files into ~/.claude/hooks/

The hook script reads session-memo.md from the same directory to populate its prompt.

mkdir -p ~/.claude/hooks
cp session-memo-hook.sh ~/.claude/hooks/session-memo-hook.sh
cp session-memo.md ~/.claude/hooks/session-memo.md
chmod +x ~/.claude/hooks/session-memo-hook.sh

To customize the memo format or instructions, edit ~/.claude/hooks/session-memo.md.

2. Register the hook in Claude Code settings

Add to ~/.claude/settings.json (create the file if it doesn't exist, replace YOU with your macOS username):

{
  "hooks": {
    "SessionEnd": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "/Users/YOU/.claude/hooks/session-memo-hook.sh",
            "async": true
          }
        ]
      }
    ]
  }
}

Verify

After your next session ends, check:

tail -f /tmp/session-memo-hook.log

A successful run looks like:

[2026-04-04T10:00:00+09:00] writing memo session=abc123 cwd=/Users/you/projects/foo

The memo file appears in sessions/ within a minute or two.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages