All checks were successful
Reindex Knowledge Base / reindex (push) Successful in 3s
Adds title, description, type, domain, and tags frontmatter to every doc for improved KB semantic search. The description field is prepended to every search chunk, and domain/type/tags enable filtered queries. Type values: context, guide, runbook, reference, troubleshooting Domain values match directory structure (networking, docker, etc.) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
56 lines
2.3 KiB
Markdown
56 lines
2.3 KiB
Markdown
---
|
|
title: "Claude Code Memory Auto-Load"
|
|
description: "How MEMORY.md symlinks to cognitive memory CORE.md provide automatic context injection into every Claude Code session. Covers the symlink mechanism, daily refresh via systemd, and manual refresh commands."
|
|
type: guide
|
|
domain: development
|
|
tags: [claude-code, cognitive-memory, symlinks, systemd, automation]
|
|
---
|
|
|
|
# Claude Code Memory Auto-Load (CORE.md Symlinks)
|
|
|
|
## Problem
|
|
Claude Code's CLAUDE.md can instruct the AI to load files at session start, but this relies on the model choosing to follow the instruction — which it often doesn't.
|
|
|
|
## Solution
|
|
Claude Code has a built-in auto-memory feature: each project gets a `MEMORY.md` file at `~/.claude/projects/<project-path>/memory/MEMORY.md` that is **automatically injected into the system prompt** every session. No tool calls needed.
|
|
|
|
We symlink every project's `MEMORY.md` to our cognitive memory `CORE.md` (`~/.claude/memory/CORE.md`), which is an auto-curated summary of the most relevant memories (~1,000-1,100 tokens).
|
|
|
|
## How It Works
|
|
|
|
```
|
|
~/.claude/projects/<project>/memory/MEMORY.md → ~/.claude/memory/CORE.md
|
|
```
|
|
|
|
- CORE.md is regenerated daily by `cognitive-memory-daily.service`
|
|
- Symlinks are refreshed daily by the same service (catches new projects)
|
|
- Cost: ~1% of 200k context window — negligible
|
|
|
|
## Files
|
|
|
|
| File | Purpose |
|
|
|------|---------|
|
|
| `~/.local/bin/claude-memory-symlinks` | Script that creates/refreshes symlinks for all projects |
|
|
| `~/.config/systemd/user/cognitive-memory-daily.service` | Daily timer that runs decay → core → embed → symlinks |
|
|
| `~/.claude/memory/CORE.md` | Auto-curated cognitive memory summary (symlink target) |
|
|
|
|
## Manual Refresh
|
|
|
|
```bash
|
|
# Regenerate CORE.md and refresh symlinks
|
|
claude-memory core && claude-memory-symlinks
|
|
|
|
# Just refresh symlinks (e.g., after creating a new project)
|
|
claude-memory-symlinks
|
|
```
|
|
|
|
## What Changed
|
|
|
|
- **Removed** from `~/.claude/CLAUDE.md`: "Session start: Load CORE.md" instruction
|
|
- **Added** to `~/.claude/CLAUDE.md`: "CORE.md auto-loads via MEMORY.md symlinks"
|
|
- **Migrated** project-specific MEMORY.md content (major-domo, strat-gameplay-webapp) into cognitive memory before replacing with symlinks
|
|
- **Added** `claude-memory-symlinks` step to daily systemd service
|
|
|
|
## Date
|
|
2026-02-16
|