tree-ring-memory — Claude Code hook: features and setup
tree-ring-memory is a Claude Code hook that loads saved context when a session starts and checks memory when it ends. It also runs at subagent start and stop.
MIT ★ 1,596 updated 2026-10-29
.claude/settings.jsonWhat tree-ring-memory does
The hook loads a bounded amount of Tree Ring context at session startup, then checks memory when the session ends. It calls codex-hook.sh from the plugin directory. The same actions are configured for subagents.
At shutdown, the check creates an agent-mediated memory checkpoint. The memory workflow covers evidence-backed lessons, privacy-safe capture, audits, consolidation, and explicit forgetting. For Claude Code, the setup file is .claude/settings.json.
What it helps with
- load saved context at session startup
- check memory when an agent or subagent stops
- create an agent-mediated memory checkpoint
- audit and consolidate stored lessons
Example prompts for the agent
- Start a session with Tree Ring context for this task.
- Finish the task and check whether a memory checkpoint is needed.
- Stop the subagent after the task and check its memory.
How to install tree-ring-memory
Manually: put the files in place
.claude/settings.jsonThe hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json
Step by step, with commands for each platform: Claude Code hooks: what they are, where to configure them, how to block a risky command
Questions about tree-ring-memory
How do I install tree-ring-memory in Claude Code?
Add the hook configuration to .claude/settings.json.
What does tree-ring-memory do?
It loads context at session startup, then checks memory and creates an agent-mediated checkpoint when the session ends.
Which events trigger tree-ring-memory?
It runs when a session starts or stops, and when a subagent starts or stops.
Source text
codex-hooks.json · MIT
Hooks bundle shipped with the tree-ring-memory plugin for Claude Code.
Local-first memory lifecycle guidance for Codex agents with recall, evidence-backed lessons, privacy-safe memory capture, audit, consolidation, and explicit forgetting.
Triggers on: SessionStart, Stop, SubagentStop.
```json
{
"description": "Load bounded Tree Ring context at startup and enforce one agent-mediated memory checkpoint at stop.",
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "\"${PLUGIN_ROOT}/hooks/codex-hook.sh\"",
"timeout": 10,
"statusMessage": "Loading Tree Ring context",
"additionalContextLimit": 6000
}
]
}
],
"SubagentStart": [
{
"hooks": [
{
"type": "command",
"command": "\"${PLUGIN_ROOT}/hooks/codex-hook.sh\"",
"timeout": 10,
"statusMessage": "Loading Tree Ring worker context",
"additionalContextLimit": 6000
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "\"${PLUGIN_ROOT}/hooks/codex-hook.sh\"",
"timeout": 10,
"statusMessage": "Checking Tree Ring memory"
}
]
}
],
"SubagentStop": [
{
"hooks": [
{
"type": "command",
"command": "\"${PLUGIN_ROOT}/hooks/codex-hook.sh\"",
"timeout": 10,
"statusMessage": "Checking Tree Ring worker memory"
}
]
}
]
}
}
```
© TerminallyLazy · MIT · hashgraph-online/awesome-codex-plugins