hmem-mcp 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +384 -0
- package/dist/cli-init.d.ts +7 -0
- package/dist/cli-init.js +291 -0
- package/dist/cli-init.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +42 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.js +88 -0
- package/dist/hmem-config.d.ts +87 -0
- package/dist/hmem-config.js +120 -0
- package/dist/hmem-config.js.map +1 -0
- package/dist/hmem-store.d.ts +175 -0
- package/dist/hmem-store.js +596 -0
- package/dist/hmem-store.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/json-parser.js +63 -0
- package/dist/logger.d.ts +21 -0
- package/dist/logger.js +78 -0
- package/dist/logger.js.map +1 -0
- package/dist/mcp-server.d.ts +17 -0
- package/dist/mcp-server.js +546 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/memory-search.d.ts +18 -0
- package/dist/memory-search.js +294 -0
- package/dist/memory-search.js.map +1 -0
- package/dist/types.js +53 -0
- package/hmem.config.example.json +13 -0
- package/package.json +68 -0
- package/skills/hmem-read/SKILL.md +66 -0
- package/skills/hmem-setup/SKILL.md +200 -0
- package/skills/hmem-write/SKILL.md +94 -0
- package/skills/memory-curate/SKILL.md +76 -0
- package/skills/save/SKILL.md +65 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hmem-setup
|
|
3
|
+
description: Interactive setup guide for hmem. Run this skill to install and configure
|
|
4
|
+
the hmem MCP server — installs dependencies, configures .mcp.json, and deploys
|
|
5
|
+
skill files to the correct global locations for Claude Code, Gemini CLI, or OpenCode.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# hmem Setup
|
|
9
|
+
|
|
10
|
+
## Step 0 — Prerequisites
|
|
11
|
+
|
|
12
|
+
Check before proceeding:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node --version # must be >= 18
|
|
16
|
+
npm --version # any recent version
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`better-sqlite3` requires native build tools. If `npm install` fails later:
|
|
20
|
+
|
|
21
|
+
| OS | Install |
|
|
22
|
+
|----|---------|
|
|
23
|
+
| Linux (Debian/Ubuntu) | `sudo apt install python3 make g++` |
|
|
24
|
+
| Linux (Arch) | `sudo pacman -S python make gcc` |
|
|
25
|
+
| macOS | `xcode-select --install` |
|
|
26
|
+
| Windows | `npm install -g windows-build-tools` |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Step 1 — Clone and Build
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/Bumblebiber/hmem.git
|
|
34
|
+
cd hmem
|
|
35
|
+
npm install
|
|
36
|
+
npm run build
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Verify: `dist/mcp-server.js` must exist after build. If the build fails, fix errors
|
|
40
|
+
before continuing — everything else depends on this file.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Step 2 — Create Agent Directory
|
|
45
|
+
|
|
46
|
+
hmem stores each agent's memory at `{HMEM_PROJECT_DIR}/Agents/{AGENT_ID}/{AGENT_ID}.hmem`.
|
|
47
|
+
The SQLite file is created automatically on first write — just create the folder:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
mkdir -p /your/project/Agents/YOUR_NAME
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For shared team knowledge (optional), hmem uses a `FIRMENWISSEN.hmem` file at the
|
|
54
|
+
project root — created automatically on first `write_memory(store="company")`.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Step 3 — Configure MCP
|
|
59
|
+
|
|
60
|
+
Add hmem to your `.mcp.json` (create it at your project root if it doesn't exist).
|
|
61
|
+
|
|
62
|
+
> **Important:** `.mcp.json` must be in the directory where you start your terminal
|
|
63
|
+
> or AI tool. Claude Code, Gemini CLI, and OpenCode discover it from the current
|
|
64
|
+
> working directory — if you open your project in `/home/alice/myproject`, that's
|
|
65
|
+
> where `.mcp.json` belongs. The `.hmem` memory files will be created in that same
|
|
66
|
+
> directory (under `Agents/YOUR_NAME/`) unless you point `HMEM_PROJECT_DIR`
|
|
67
|
+
> elsewhere.
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"mcpServers": {
|
|
72
|
+
"hmem": {
|
|
73
|
+
"type": "stdio",
|
|
74
|
+
"command": "node",
|
|
75
|
+
"args": ["/absolute/path/to/hmem/dist/mcp-server.js"],
|
|
76
|
+
"env": {
|
|
77
|
+
"HMEM_PROJECT_DIR": "/absolute/path/to/your/project",
|
|
78
|
+
"HMEM_AGENT_ID": "YOUR_NAME",
|
|
79
|
+
"HMEM_AGENT_ROLE": "worker"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**All paths must be absolute** — relative paths will fail silently.
|
|
87
|
+
|
|
88
|
+
| Variable | Description |
|
|
89
|
+
|----------|-------------|
|
|
90
|
+
| `HMEM_PROJECT_DIR` | Root directory where `.hmem` files are stored |
|
|
91
|
+
| `HMEM_AGENT_ID` | Unique identifier for this agent (e.g. `ALICE`, `DEVELOPER`) |
|
|
92
|
+
| `HMEM_AGENT_ROLE` | Permission level: `worker` · `al` · `pl` · `ceo` |
|
|
93
|
+
|
|
94
|
+
Roles control what entries in the shared `FIRMENWISSEN` store are visible.
|
|
95
|
+
`worker` sees everything marked `min_role: worker`. Higher roles unlock more.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Step 4 — Install Skill Files
|
|
100
|
+
|
|
101
|
+
Skill files teach your AI tool how to use `read_memory`, `write_memory`, and `/save`.
|
|
102
|
+
Copy them to the global skills directory for your tool:
|
|
103
|
+
|
|
104
|
+
**Claude Code:**
|
|
105
|
+
```bash
|
|
106
|
+
mkdir -p ~/.claude/skills/hmem-read ~/.claude/skills/hmem-write ~/.claude/skills/save ~/.claude/skills/memory-curate
|
|
107
|
+
cp /path/to/hmem/skills/hmem-read/SKILL.md ~/.claude/skills/hmem-read/SKILL.md
|
|
108
|
+
cp /path/to/hmem/skills/hmem-write/SKILL.md ~/.claude/skills/hmem-write/SKILL.md
|
|
109
|
+
cp /path/to/hmem/skills/save/SKILL.md ~/.claude/skills/save/SKILL.md
|
|
110
|
+
cp /path/to/hmem/skills/memory-curate/SKILL.md ~/.claude/skills/memory-curate/SKILL.md
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Gemini CLI:**
|
|
114
|
+
```bash
|
|
115
|
+
mkdir -p ~/.gemini/skills/hmem-read ~/.gemini/skills/hmem-write ~/.gemini/skills/save ~/.gemini/skills/memory-curate
|
|
116
|
+
cp /path/to/hmem/skills/hmem-read/SKILL.md ~/.gemini/skills/hmem-read/SKILL.md
|
|
117
|
+
cp /path/to/hmem/skills/hmem-write/SKILL.md ~/.gemini/skills/hmem-write/SKILL.md
|
|
118
|
+
cp /path/to/hmem/skills/save/SKILL.md ~/.gemini/skills/save/SKILL.md
|
|
119
|
+
cp /path/to/hmem/skills/memory-curate/SKILL.md ~/.gemini/skills/memory-curate/SKILL.md
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**OpenCode:**
|
|
123
|
+
```bash
|
|
124
|
+
mkdir -p ~/.config/opencode/skills/hmem-read ~/.config/opencode/skills/hmem-write ~/.config/opencode/skills/save ~/.config/opencode/skills/memory-curate
|
|
125
|
+
cp /path/to/hmem/skills/hmem-read/SKILL.md ~/.config/opencode/skills/hmem-read/SKILL.md
|
|
126
|
+
cp /path/to/hmem/skills/hmem-write/SKILL.md ~/.config/opencode/skills/hmem-write/SKILL.md
|
|
127
|
+
cp /path/to/hmem/skills/save/SKILL.md ~/.config/opencode/skills/save/SKILL.md
|
|
128
|
+
cp /path/to/hmem/skills/memory-curate/SKILL.md ~/.config/opencode/skills/memory-curate/SKILL.md
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Step 5 — Optional: hmem.config.json
|
|
134
|
+
|
|
135
|
+
Place `hmem.config.json` in your `HMEM_PROJECT_DIR` to customize behavior. All keys are optional.
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"maxL1Chars": 500,
|
|
140
|
+
"maxLnChars": 50000,
|
|
141
|
+
"maxDepth": 5,
|
|
142
|
+
"defaultReadLimit": 100,
|
|
143
|
+
"recentDepthTiers": [
|
|
144
|
+
{ "count": 10, "depth": 2 },
|
|
145
|
+
{ "count": 3, "depth": 3 }
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Character limits** — two options:
|
|
151
|
+
- `"maxL1Chars"` + `"maxLnChars"`: set endpoints only, intermediate levels interpolated linearly
|
|
152
|
+
- `"maxCharsPerLevel"`: explicit array `[L1, L2, L3, L4, L5]`
|
|
153
|
+
|
|
154
|
+
**Recency gradient** (`recentDepthTiers`): controls how deeply children are inlined for recent entries in a default `read_memory()` call.
|
|
155
|
+
|
|
156
|
+
Each tier is `{ "count": N, "depth": D }` — the N most recent entries get children inlined up to depth D. The highest applicable depth wins.
|
|
157
|
+
|
|
158
|
+
Default behavior:
|
|
159
|
+
| Entry position | What you see |
|
|
160
|
+
|---|---|
|
|
161
|
+
| 0–2 (most recent) | L1 + L2 + L3 |
|
|
162
|
+
| 3–9 | L1 + L2 |
|
|
163
|
+
| 10+ | L1 only |
|
|
164
|
+
|
|
165
|
+
Set to `[]` to disable (L1-only for all entries).
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Step 6 — Verify
|
|
170
|
+
|
|
171
|
+
**Fully restart** your AI tool (exit and reopen — `/clear` is not enough).
|
|
172
|
+
Then call:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
read_memory()
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Expected: `Memory is empty` (or your existing memories if any).
|
|
179
|
+
|
|
180
|
+
**Troubleshooting:**
|
|
181
|
+
|
|
182
|
+
| Symptom | Likely cause |
|
|
183
|
+
|---------|-------------|
|
|
184
|
+
| `HMEM_PROJECT_DIR not set` | Path missing or wrong env var name in `.mcp.json` |
|
|
185
|
+
| `No such tool: read_memory` | Tool not restarted after adding `.mcp.json` |
|
|
186
|
+
| `npm install` fails | Missing build tools (see Step 0) |
|
|
187
|
+
| `read_memory` returns empty after writing | MCP server process is stale — restart tool |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Quick Reference — After Setup
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
read_memory() # see all your Level 1 memories
|
|
195
|
+
read_memory(id="L0001") # drill into one entry
|
|
196
|
+
write_memory(prefix="L", content="…") # save a lesson learned
|
|
197
|
+
search_memory(query="error node.js") # search across all memories
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
See `skills/hmem-read/SKILL.md` and `skills/hmem-write/SKILL.md` for full usage.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hmem-write
|
|
3
|
+
description: How to write long-term memories. Follow these rules whenever you call write_memory.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# How to use write_memory
|
|
7
|
+
|
|
8
|
+
When you need to save a lesson, error, decision, or project insight to long-term memory,
|
|
9
|
+
call the MCP tool `write_memory` following these rules.
|
|
10
|
+
|
|
11
|
+
If the tool `write_memory` is not available:
|
|
12
|
+
1. Tell the user: "write_memory tool not found. Please reconnect the MCP server (in Claude Code: `/mcp`, in other tools: restart the tool)."
|
|
13
|
+
2. **NEVER write directly to the .hmem SQLite file via shell commands.** The database has WAL journaling, integrity checks, and tree-structure logic that raw SQL INSERT will bypass — causing corruption or data loss.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Syntax
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
write_memory(
|
|
21
|
+
prefix: "E",
|
|
22
|
+
content: "L1 sentence — concise, understandable without context\n\tL2 detail (1 tab)\n\t\tL3 detail (2 tabs)\n\t\t\tL4 raw data (3 tabs — rarely needed)"
|
|
23
|
+
)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Indentation:** 1 tab = 1 level. Alternatively: 2 or 4 spaces per level (auto-detected).
|
|
27
|
+
**IDs and timestamps** are assigned automatically — never write them yourself.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Prefixes
|
|
32
|
+
|
|
33
|
+
| Prefix | Category | When to use |
|
|
34
|
+
|--------|----------|-------------|
|
|
35
|
+
| **P** | Project | Project experiences, summaries |
|
|
36
|
+
| **L** | Lesson | Lessons learned, best practices |
|
|
37
|
+
| **E** | Error | Bugs, errors + their fix |
|
|
38
|
+
| **D** | Decision | Architecture decisions with reasoning |
|
|
39
|
+
| **T** | Task | Task notes, work progress |
|
|
40
|
+
| **M** | Milestone | Key milestones, releases |
|
|
41
|
+
| **S** | Skill | Skills, processes, how-to guides |
|
|
42
|
+
| **F** | Favorite | Frequently needed reference info (always loaded with L2 detail) |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## L1 Quality Rule
|
|
47
|
+
|
|
48
|
+
- **One complete, informative sentence** — ~15–20 tokens
|
|
49
|
+
- Must be understandable without any context
|
|
50
|
+
- Not "Fixed a bug" — instead "SQLite connection failed due to wrong path in .mcp.json"
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Company Knowledge (requires AL+ role)
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
write_memory(
|
|
58
|
+
prefix: "S",
|
|
59
|
+
store: "company",
|
|
60
|
+
min_role: "worker",
|
|
61
|
+
content: "..."
|
|
62
|
+
)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## When to save?
|
|
68
|
+
|
|
69
|
+
**Mandatory before terminating.** Only save what is still valuable in 6 months.
|
|
70
|
+
|
|
71
|
+
| Save | Don't save |
|
|
72
|
+
|------|-----------|
|
|
73
|
+
| New root cause + fix | Routine actions without learning value |
|
|
74
|
+
| Insight that changes future work | What's already in the codebase |
|
|
75
|
+
| Architecture decision + reasoning | Temporary debugging notes |
|
|
76
|
+
| Unexpected tool/API behavior | What's in the documentation |
|
|
77
|
+
|
|
78
|
+
One `write_memory` call per category — entire hierarchy in one `content` string.
|
|
79
|
+
|
|
80
|
+
**Custom prefixes:** Additional prefixes can be added in `hmem.config.json` under the `"prefixes"` key (e.g. `"R": "Research"`).
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Anti-Patterns
|
|
85
|
+
|
|
86
|
+
| Wrong | Right |
|
|
87
|
+
|-------|-------|
|
|
88
|
+
| L1 too short: "Fixed bug" | Full sentence with root cause |
|
|
89
|
+
| Mixed spaces and tabs | Stay consistent — either tabs or spaces |
|
|
90
|
+
| Everything flat, no indentation | Use hierarchy — L2/L3 for details |
|
|
91
|
+
| Save trivial things | Quality over quantity |
|
|
92
|
+
| Forget to write_memory | Always call BEFORE setting Status: Completed |
|
|
93
|
+
| Write to .hmem via sqlite3/SQL | ONLY use `write_memory` MCP tool — never raw SQL |
|
|
94
|
+
| MCP unavailable → skip saving | Reconnect MCP first (`/mcp` or restart tool) |
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memory-curate
|
|
3
|
+
description: >
|
|
4
|
+
Memory curation workflow. Use when asked to curate, audit, or clean up agent memories.
|
|
5
|
+
Processes one agent at a time — read, fix, mark audited, summarize, terminate.
|
|
6
|
+
Requires role: ceo.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# /memory-curate — hmem Curation Workflow
|
|
10
|
+
|
|
11
|
+
You are the memory curator. Process **one agent per run**, then terminate.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Step-by-Step
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
1. get_audit_queue()
|
|
19
|
+
→ Empty → write a short summary to a LAST_CURATION.md file and terminate
|
|
20
|
+
→ Not empty → take the FIRST agent from the list
|
|
21
|
+
|
|
22
|
+
2. read_agent_memory(agent_name, depth=3)
|
|
23
|
+
→ Study all entries carefully
|
|
24
|
+
|
|
25
|
+
3. Fix every issue found:
|
|
26
|
+
- L1 too long (>2 sentences) → fix_agent_memory(agent_name, entry_id, level_1="shorter")
|
|
27
|
+
- Duplicate entry → delete_agent_memory(agent_name, weaker_entry_id)
|
|
28
|
+
- Factually wrong → delete_agent_memory, optionally write correct entry
|
|
29
|
+
- Vague/useless content → delete_agent_memory
|
|
30
|
+
|
|
31
|
+
4. mark_audited(agent_name)
|
|
32
|
+
|
|
33
|
+
5. Append one line to LAST_CURATION.md:
|
|
34
|
+
"- **AGENTNAME**: N entries — [OK | fixed L0003 L1 | deleted E0002 (dup of E0001)]"
|
|
35
|
+
|
|
36
|
+
6. Terminate.
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Quality Criteria
|
|
42
|
+
|
|
43
|
+
| Check | Rule |
|
|
44
|
+
|-------|------|
|
|
45
|
+
| L1 length | Single concise sentence, ~15–20 tokens |
|
|
46
|
+
| L2 | Adds context, does not repeat L1 |
|
|
47
|
+
| Duplicates | Keep the better entry, delete the weaker |
|
|
48
|
+
| Prefix | P=Project L=Lesson E=Error T=Task D=Decision M=Milestone F=Favorite S=Skill (+ custom prefixes from hmem.config.json) |
|
|
49
|
+
| Personal limit | 300 entries max |
|
|
50
|
+
| Company limit | 200 entries max |
|
|
51
|
+
|
|
52
|
+
**Over limit → triage order:**
|
|
53
|
+
1. Delete duplicates and vague entries
|
|
54
|
+
2. Merge similar lessons (fix keeper, delete rest)
|
|
55
|
+
3. Apply access curve: delete entries that are old (>3 months) + rarely accessed (count 0–1) + generic
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Company Store
|
|
60
|
+
|
|
61
|
+
After processing all personal queues:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
read_memory(store="company")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
→ Remove outdated company entries, update clearance levels if needed.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Rules
|
|
72
|
+
|
|
73
|
+
- Never invent or fabricate memories.
|
|
74
|
+
- Skip yourself (the curator agent) if you appear in the queue.
|
|
75
|
+
- One agent per run — be called again for the next agent.
|
|
76
|
+
- Always write to LAST_CURATION.md, even for clean runs ("OK — nothing to fix").
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: save
|
|
3
|
+
description: >
|
|
4
|
+
End-of-session save routine. Use when the user types /save or asks to
|
|
5
|
+
"save", "save session", or "save progress".
|
|
6
|
+
Saves session learnings to memory via write_memory, commits git changes,
|
|
7
|
+
then compacts the conversation context.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Save Session
|
|
11
|
+
|
|
12
|
+
Execute these steps in order. Report results after all complete.
|
|
13
|
+
|
|
14
|
+
## Step 1 — Write Memory
|
|
15
|
+
|
|
16
|
+
**IMPORTANT:** You MUST use the `write_memory` MCP tool. NEVER write directly to `.hmem` files via sqlite3 or shell commands — this bypasses WAL journaling, integrity checks, and tree logic, causing corruption or data loss.
|
|
17
|
+
|
|
18
|
+
If `write_memory` is not available, **STOP and tell the user** to reconnect the MCP server first (Claude Code: `/mcp` → reconnect; other tools: restart the tool). Do NOT proceed without a working MCP connection.
|
|
19
|
+
|
|
20
|
+
Your L1 memory summaries are already in your context (injected at session start).
|
|
21
|
+
**Check them first** — do not re-write anything that already exists.
|
|
22
|
+
|
|
23
|
+
Only write what is **new since the last `/save` or session start**:
|
|
24
|
+
|
|
25
|
+
| Prefix | When to use |
|
|
26
|
+
|--------|-------------|
|
|
27
|
+
| `P` | What was worked on this session — decisions made, outcome |
|
|
28
|
+
| `L` | Lessons learned applicable beyond this session |
|
|
29
|
+
| `E` | Error patterns — root cause + fix |
|
|
30
|
+
| `D` | Architectural or design decisions |
|
|
31
|
+
|
|
32
|
+
Quality over quantity. Skip trivial things and anything already captured.
|
|
33
|
+
|
|
34
|
+
**Example calls:**
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
write_memory(prefix="P", content="Implemented auth flow with JWT
|
|
38
|
+
Chose short-lived access tokens + refresh token rotation
|
|
39
|
+
Decision: store refresh tokens in httpOnly cookie, not localStorage")
|
|
40
|
+
|
|
41
|
+
write_memory(prefix="L", content="Always restart MCP server after recompiling TypeScript
|
|
42
|
+
Running process holds the old dist — tool calls return stale results otherwise")
|
|
43
|
+
|
|
44
|
+
write_memory(prefix="E", content="write_memory returned HMEM_PROJECT_DIR not set
|
|
45
|
+
Cause: relative path in .mcp.json env — must be absolute
|
|
46
|
+
Fix: replace with full absolute path, restart AI tool")
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Step 2 — Commit & Push
|
|
50
|
+
|
|
51
|
+
If in a git repository:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
git add -A
|
|
55
|
+
git commit -m "concise imperative summary of this session's changes"
|
|
56
|
+
git push
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Skip if there are no changes or no git repo.
|
|
60
|
+
|
|
61
|
+
## Step 3 — Compact (Claude only)
|
|
62
|
+
|
|
63
|
+
If you are running on **Claude** (Claude Code, claude.ai): run `/compact` to compress the conversation context. The next interaction starts fresh with your updated memories already loaded.
|
|
64
|
+
|
|
65
|
+
If you are running on **Gemini CLI, OpenCode, or another tool**: skip this step — `/compact` is a Claude-specific command.
|