How memory works
Every conversation is an opportunity for an agent to learn. At the end of each session, the Claude Code writes structured memory files to the agent’s working directory. SlackHive’sMemoryWatcher detects these files in real time, parses them, and persists them to Postgres.
On next restart — or when hot-reloaded — all stored memories are compiled back into the agent’s CLAUDE.md as a Learned Memory section. The agent starts every conversation with its full accumulated knowledge.
Memory file format
Memory files are Markdown with YAML frontmatter. Agents write them tomemory/{name}.md in their session working directory:
| Field | Required | Description |
|---|---|---|
name | Yes | Short snake_case identifier for this memory (used as a unique key) |
description | No | One-line summary shown in the memory viewer UI |
type | Yes | Memory category — one of user, feedback, project, reference |
Memory types
Agents are instructed to categorize memories into four types:| Type | Purpose | Example |
|---|---|---|
feedback | Behavioral corrections and validated approaches | ”Don’t mock the database in integration tests” |
user | Information about people the agent works with | ”Kai is the data team lead, prefers concise answers” |
project | Ongoing work context, goals, decisions, deadlines | ”Merge freeze starts March 5 for mobile release” |
reference | Pointers to external systems and resources | ”Pipeline bugs tracked in Linear project INGEST” |
Memory instructions
SlackHive injects a# Memory System section into every agent’s CLAUDE.md at the framework level — not as a skill. This section instructs the agent to:
- Save a memory whenever it learns who a user is, their preferences, a correction, a recurring task, or where resources live
- Default to saving — a slightly over-captured memory is better than a missed one
- Update existing memories when new information supersedes them (overwrite the file rather than creating a duplicate)
- Maintain a
memory/MEMORY.mdindex with one-line entries for each memory file
“At the end of every conversation, proactively save anything useful you learned — this is how you get smarter over time. Memories persist across all future conversations with every user.”
Memory storage path
Each Slack thread gets its own isolated session working directory:MemoryWatcher watches both the root memory/ directory and all per-session memory/ directories. A 200ms debounce prevents duplicate writes on rapid file changes.
Memory sync is belt-and-suspenders
Memories are synced to Postgres via two mechanisms:- MemoryWatcher —
fs.watchdetects file changes in real time and upserts to DB immediately - Post-query scan — after every conversation,
ClaudeHandlerscans the session’s memory directory and upserts any valid memory files. This ensures memories are never lost even if the fs.watch event was missed.
How memories appear in CLAUDE.md
All stored memories are compiled into a structured section appended to the agent’sCLAUDE.md on each reload. Memories are grouped by type in this order: feedback, user, project, reference.
Viewing memories in the UI
Open any agent’s detail page and click the Memory tab. Memories are displayed grouped by type. For each memory you can:- View the full content
- See the memory type and description
- Delete a memory (this removes it from both the UI and the database; it will not be included in future
CLAUDE.mdcompilations)
Updating a memory
If an agent learns new information that supersedes an existing memory, it overwrites the file with the samename field. The upsert logic in the database uses name as the unique key per agent — so updating a memory never creates a duplicate.