linksee-memory 0.7.2 → 0.10.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.
@@ -1,631 +1,734 @@
1
- ---
2
- name: linksee-memory
3
- description: |
4
- The bridge to the agent's "past self". Before any new task, file edit, decision, or right after a failure, recall past caveats (pain records) / learnings (growth log) / implementation history from linksee-memory.
5
- This is the only way to solve Claude Code's "memory amnesia every session" problem. The "never repeat the same mistake" mechanism that Mem0 / Letta / Zep can't provide.
6
- エージェントの「過去の自分」への橋。新しい作業・ファイル編集・意思決定・失敗の前後で、linksee-memory から過去の caveat(痛みの記録)/ learning(成長ログ)/ implementation(成功失敗)を recall する。
7
-
8
- ALWAYS use this skill at the following moments / 以下のタイミングで必ずこのスキルを使うこと:
9
- ① Task start / new task begins — "let's implement...", "let's start", "build a new...", 「実装しよう」「始めよう」「新しく〜作る」
10
- ② Before editing a file — same file may have been touched before / 同じファイルを過去に触ってる可能性がある
11
- ③ The moment an error/failure happens — remember as caveat / エラー・失敗した瞬間
12
- ④ The moment something succeeds or is learned — remember as learning / 成功した瞬間・学んだ瞬間
13
- ⑤ When the user says "before", "earlier", "last time", "same as", "remember?", "remember this" / 「前に」「同じ」「覚えてる?」「覚えておいて」
14
- ⑥ When asked "why did we do that", "when was this decided", "where did we discuss this" / 「なぜそうした」「いつ決めた」「どこで議論した」
15
- ⑦ Returning from another project / switching sessions / 別プロジェクトから戻ってきたとき
16
-
17
- Triggers (EN): remember/recall/forget/memory/before/earlier/last time/previously/remember when/same as before/history/use linksee/linksee
18
- Triggers (JP): 記憶/覚えて/忘れて/過去/前回/前に/そういえば/覚えてる/リンクシー
19
- Error keywords (EN): failed/broken/stuck/error/bug/doesn't work/not working/same error again/again/repeated/debug
20
- Error keywords (JP): 失敗/エラー/うまくいかない/ハマった/同じ/また/繰り返し
21
- Decision keywords (EN): decided/let's go with/approved/settled on/pivot/strategy/switch to/abandon
22
- Decision keywords (JP): 決めた/方針/戦略/ピボット/やめよう/方向転換
23
- ---
24
-
25
- # Linksee Memory Skill — Connecting the agent's past and future
26
-
27
- ## 🧠 Core Principle
28
-
29
- **This skill is the only way to persist agent growth across sessions.**
30
-
31
- Claude Code forgets everything when a session ends. The solution the user taught yesterday, the failure you hit today, the decision made three days ago — all of it is normally lost. **linksee-memory is the "memory that doesn't disappear" device.**
32
-
33
- Writes are handled automatically by the Stop hook (already running). But **reads require the agent to actively pull**. This skill instills that "go look first" habit in the agent.
34
-
35
- *JP: Claude Code は session が終わると全部忘れる。linksee-memory は「消えない記憶」を作る装置。書き込みは Stop hook が自動でやってくれるが、読み出しはエージェントが能動的にやる必要がある。*
36
-
37
- ---
38
-
39
- ## 📐 The 6 layers — what goes where
40
-
41
- Which layer you record into determines later retrieval accuracy.
42
-
43
- | Layer | When to use | Example |
44
- |---|---|---|
45
- | 🎯 `goal` | The user states a clear goal | "want to integrate with freee", "want to npm publish" |
46
- | 📍 `context` | Background on when/why this is happening | "because there's a meeting with company X on Wednesday" |
47
- | 💭 `emotion` | User's temperature / tone | "tired", "excited", "stressed", 「疲れた」「焦ってる」 |
48
- | 🔧 `implementation` | Code written, configured, worked / didn't work | success: "OAuth flow works" / failure: "stopped with auth_expired" |
49
- | ⚠️ `caveat` | **Lessons you never want to repeat** (auto-protected from forgetting) | "freee OAuth expires in 24h", "never edit this file" |
50
- | 📈 `learning` | Learned something new, prior belief updated | "AST chunking beats line diff for token savings" |
51
-
52
- **Important:** `caveat` layer is automatically protected from forgetting. Pain records are never deleted.
53
-
54
- **Pin-via-importance (v0.1.0+):** Calling `remember` with `importance: 1.0` pins the memory across all layers, protecting it from auto-forget even outside the caveat layer. Use for "mission-critical goals", "key decisions", etc.:
55
-
56
- ```
57
- remember({
58
- entity_name: "KanseiLink", entity_kind: "project",
59
- layer: "goal", content: "Plugin Marketplace submission under review",
60
- importance: 1.0 // pin
61
- })
62
- ```
63
-
64
- **Layer aliases** — no need to memorize canonical names. Natural language aliases resolve automatically:
65
-
66
- | Natural alias | → canonical |
67
- |---|---|
68
- | `decisions` / `insights` / `learned` | `learning` |
69
- | `warnings` / `rules` / `pitfalls` / `dont` | `caveat` |
70
- | `how` / `tried` / `attempts` / `success` / `failure` | `implementation` |
71
- | `why` / `intent` / `goals` / `targets` | `goal` |
72
- | `background` / `reason` / `situation` / `timing` | `context` |
73
- | `tone` / `feelings` / `mood` | `emotion` |
74
-
75
- ---
76
-
77
- ## 🏗️ 3-Axis Classification (v2) — REQUIRED for all `remember()` calls
78
-
79
- The 6-layer system tells you WHICH DRAWER. The 3-axis system tells you WHAT KIND of memory goes in it. Every `content` field must be a JSON string containing these 3 axes:
80
-
81
- ### Axis ① Altitude — where in the abstraction hierarchy
82
-
83
- | Level | Description | Survives |
84
- |---|---|---|
85
- | `mission` | Company/product-level direction ("KanseiLINK is the intelligence layer for the Agent Economy") | Permanent |
86
- | `strategy` | Approach to achieving mission ("AEO-first, 引き出しカタログ model") | Permanent |
87
- | `architecture` | System design decisions ("2-layer: Memory=agent-optimized, Dashboard=human-optimized") | Long-lived |
88
- | `implementation` | Specific code/config changes ("Added FTS5 trigram index") | Auto-archives after 30d if untouched |
89
-
90
- ### Axis ② Type — what kind of information
91
-
92
- | Type | Description |
93
- |---|---|
94
- | `question` | User asked something, answer pending or delivered |
95
- | `comparison` | Multiple options analyzed (e.g., Stripe vs Square) |
96
- | `decision` | A choice was made — store agent_proposal + user_approval_scope |
97
- | `work` | Code written, config changed, command run |
98
- | `outcome` | Result of work (success/failure + what happened) |
99
- | `learning` | Insight gained, prior belief updated |
100
- | `note` | General context — **chitchat = DISCARD, do NOT save** |
101
-
102
- ### Axis ③ State — lifecycle position
103
-
104
- ```
105
- open → decided → in_progress → done
106
- → stalled (blocked, can't proceed)
107
- → parked (intentionally paused)
108
- → superseded (replaced by newer decision)
109
- ```
110
-
111
- ---
112
-
113
- ## 📝 Structured Content Format — the JSON schema for `content`
114
-
115
- **Every `remember()` call MUST use this JSON format in the `content` field:**
116
-
117
- ```json
118
- {
119
- "title": "<one-line: WHAT this memory IS — future-agent skims this>",
120
- "altitude": "strategy",
121
- "type": "decision",
122
- "state": "decided",
123
- "what": "<the actual content — 5W1H extracted, NOT raw chat>",
124
- "why": "<why this matters — the reasoning>",
125
- "affects": ["src/mcp/server.ts", "lib/db.ts"],
126
- "next_action": "Implement the schema migration next session",
127
- "supersedes_id": null,
128
- "evidence_refs": [
129
- {"type": "session", "id": "b78dc5ba", "label": "Architecture discussion"}
130
- ]
131
- }
132
- ```
133
-
134
- ### Required fields (ALL memories)
135
-
136
- | Field | Type | Description |
137
- |---|---|---|
138
- | `title` | string | One-line summary. Future agents read ONLY this when scanning. Make it specific: "freee OAuth 24h expiry caveat" not "OAuth issue" |
139
- | `altitude` | enum | mission / strategy / architecture / implementation |
140
- | `type` | enum | question / comparison / decision / work / outcome / learning |
141
- | `state` | enum | open / decided / in_progress / done / stalled / parked / superseded |
142
- | `what` | string | The semantic content. Extract 5W1H from conversation — NEVER store raw chat like "そうだね。全部やろう。" |
143
- | `why` | string | Why this matters. Without this, future agents can't judge relevance |
144
-
145
- ### Required fields (DECISION type only)
146
-
147
- | Field | Type | Description |
148
- |---|---|---|
149
- | `agent_proposal` | string | What the agent proposed (the full context the user was responding to) |
150
- | `user_approval_scope` | string | What EXACTLY the user approved — "うん全部やって" → translate to "approved all 6 panels of Agent Brain Dashboard including data layer, API route, and view component" |
151
-
152
- ### Optional but recommended fields
153
-
154
- | Field | Type | Description |
155
- |---|---|---|
156
- | `affects` | string[] | File paths or areas this touches. Critical for future `recall_file` accuracy |
157
- | `next_action` | string / null | What should happen next. Null if done/completed |
158
- | `supersedes_id` | number / null | Memory ID this replaces (builds pivot chains) |
159
- | `prior_belief` | string | What we used to think (for learnings — enables belief-update tracking) |
160
- | `evidence_refs` | object[] | Links to evidence: `{"type": "session"|"file"|"url", "id": "...", "label": "..."}`. Store as REFERENCES, never inline the full content |
161
-
162
- ### Content quality rules — what NOT to save
163
-
164
- | ❌ DO NOT | ✅ INSTEAD |
165
- |---|---|
166
- | Store raw chat: `"決めた。それでいこう"` | Extract: `"Decided to use 2-layer architecture splitting Memory (agent-optimized) from Dashboard (human-optimized)"` |
167
- | Store ambient chat: `"書斎で無糖のサイダー飲んでる"` | Discard. Not a memory. |
168
- | Store vague approval: `"うん全部やって"` | Extract the SCOPE: `"Approved: (1) agent-brain data layer, (2) API route, (3) 6-panel view component implementation"` |
169
- | Paste back assistant output as memory | Summarize the KEY INSIGHT from the output in YOUR words |
170
- | Store without `why` | Always include WHY — without it, memory is noise |
171
-
172
- ---
173
-
174
- ## 🔄 Execution flow — 5 canonical moments
175
-
176
- ### ① Task Start — Always recall before starting work
177
-
178
- Before starting any new task, inject past context.
179
-
180
- **At the very beginning of a conversation**, use `list_entities` first to understand what you know:
181
-
182
- ```
183
- mcp__linksee__list_entities({ min_memories: 5, limit: 10 })
184
- ```
185
-
186
- The returned "high-momentum entities" are the projects likely to be discussed. Each entity's `layer_breakdown` reveals patterns ("this project has many caveats", "goal is unfinished", etc.).
187
-
188
- Then, once a specific task starts, recall:
189
-
190
- ```
191
- mcp__linksee__recall({
192
- query: "<keywords of current task — project name + technology>",
193
- max_tokens: 2000
194
- })
195
- ```
196
-
197
- **Example**: User says "let's add a new tool to KanseiLink":
198
- ```
199
- recall({ query: "KanseiLink new tool", max_tokens: 2000 })
200
- ```
201
-
202
- In the returned memories, pay special attention to:
203
- - **`caveat` layer** — traps to absolutely avoid
204
- - **`learning` layer** — previously-reached conclusions
205
- - **`implementation.failure`** — past failure patterns
206
-
207
- **Using the results:**
208
- ```
209
- From past caveat: "Watch out for MCP tool name collisions"
210
- → Before adding a new tool, check existing tool names first.
211
- ```
212
-
213
- #### ⚡ Writing effective recall queries
214
-
215
- The recall engine uses FTS5 full-text search + heat_score ranking. Your query determines what comes back.
216
-
217
- | Pattern | Query style | Example |
218
- |---|---|---|
219
- | Entity + topic | `"<entity> <topic keyword>"` | `"KanseiLink OAuth"` |
220
- | Error recall | `"<error message core> <technology>"` | `"401 freee token expired"` |
221
- | Decision recall | `"<entity> decided strategy approach"` | `"Linksee Memory plugin vs MCP"` |
222
- | File-related | Use `recall_file` instead | `recall_file({ path_substring: "server.ts" })` |
223
- | Cross-entity | Call recall TWICE for each entity | `recall({ query: "KanseiLink" })` then `recall({ query: "Linksee Memory" })` |
224
-
225
- **Anti-patterns:**
226
- - ❌ `recall({ query: "what happened" })` — too vague, FTS5 matches everything
227
- - ❌ `recall({ query: "the user said to fix the bug in the auth flow" })` — natural language sentences score poorly in FTS5
228
- - ✅ `recall({ query: "auth bug fix caveat", layer: "caveat" })` — keywords + layer filter = precise
229
-
230
- #### 🔇 When NOT to recall (save tokens)
231
-
232
- - Same entity already recalled in this session AND no new context arrived → **skip**
233
- - User is just chatting / thinking aloud / no task yet → **skip** (wait for concrete task)
234
- - You just wrote a memory 2 turns ago → **skip** (it's still in your context window)
235
- - The answer is already in your conversation context → **skip** (don't waste a tool call)
236
-
237
- ### ② File Edit — Use recall_file before touching a file
238
-
239
- Before touching a specific file, check its edit history:
240
-
241
- ```
242
- mcp__linksee__recall_file({
243
- path_substring: "<file path or substring match>",
244
- max_intents: 5
245
- })
246
- ```
247
-
248
- Returns: the file's entire edit history + **the user message that drove each edit**.
249
-
250
- **This is the key differentiator.** Mem0 / Letta don't have this. "Why was this file changed last time" is preserved.
251
-
252
- ### ③ Before Reading — Use read_smart for files already read
253
-
254
- When you need to read a file, **use `read_smart` instead of the standard `Read` tool**:
255
-
256
- ```
257
- mcp__linksee__read_smart({
258
- path: "<absolute path>"
259
- })
260
- ```
261
-
262
- **Effect**:
263
- - First read: same tokens as normal Read (with chunk metadata)
264
- - Subsequent reads, unchanged: **~50 tokens returned** (99% savings)
265
- - Subsequent reads, changed: only changed chunks returned (50–90% savings)
266
-
267
- Especially effective for large files (>1000 lines).
268
-
269
- ### ③.5 Updating existing memory — use update_memory, not forget+remember
270
-
271
- When facts change / goal updated / caveat detail needs correction: **`forget` + `remember` breaks `memory_id` continuity, cutting the `session_file_edits` links.** Use `update_memory` instead:
272
-
273
- ```
274
- update_memory({
275
- memory_id: 1234,
276
- content: '{"primary": "Plugin Marketplace under review (day 7)", "deadline": "2026-04-25"}',
277
- importance: 1.0 // strengthen pin
278
- })
279
- ```
280
-
281
- `layer` can also be changed, but demoting from caveat to another layer is **not allowed** (auto-protected).
282
-
283
- ### ④ Failure — Record caveat the moment an error hits
284
-
285
- The moment an error, failure, or "doesn't work" happens, record immediately:
286
-
287
- ```
288
- mcp__linksee__remember({
289
- entity_name: "<project name or service name>",
290
- entity_kind: "project",
291
- layer: "caveat",
292
- content: JSON.stringify({
293
- title: "<one-line: what failed + the rule>",
294
- altitude: "implementation",
295
- type: "outcome",
296
- state: "done",
297
- what: "<what failed + workaround found>",
298
- why: "<root cause analysis>",
299
- affects: ["<file paths where the error occurred>"],
300
- next_action: null
301
- }),
302
- importance: 0.8 // failures are high-importance
303
- })
304
- ```
305
-
306
- **Example**:
307
- ```json
308
- {
309
- "title": "freee OAuth token expires in 24h — must refresh proactively",
310
- "altitude": "implementation",
311
- "type": "outcome",
312
- "state": "done",
313
- "what": "freee MCP OAuth token expires in 24 hours. Reusing access_token directly causes 401. Must call refresh_token endpoint proactively.",
314
- "why": "freee's OAuth implementation uses short-lived tokens unlike most SaaS (usually 30-90 day expiry)",
315
- "affects": ["src/integrations/freee/auth.ts"],
316
- "next_action": null,
317
- "evidence_refs": [{"type":"session", "id":"02759...", "label":"freee auth_expired incident"}]
318
- }
319
- ```
320
-
321
- **Why this matters**: `caveat` is **auto-protected from forgetting**. Once recorded, a future agent in a different session avoids the same failure.
322
-
323
- ### ⑤ Success / Learning — Record the moment of insight
324
-
325
- When you understand something new, change approaches, or solve a problem:
326
-
327
- ```
328
- mcp__linksee__remember({
329
- entity_name: "<entity>",
330
- entity_kind: "project | concept | ...",
331
- layer: "learning",
332
- content: JSON.stringify({
333
- title: "<one-line: what was learned>",
334
- altitude: "<strategy|architecture|implementation>",
335
- type: "learning",
336
- state: "done",
337
- what: "<the insight>",
338
- why: "<why this changes how we work>",
339
- prior_belief: "<what we used to think>",
340
- affects: ["<file paths if applicable>"],
341
- next_action: "<follow-up action if any>"
342
- }),
343
- importance: 0.7
344
- })
345
- ```
346
-
347
- Recording `prior_belief` leaves a **belief-update history**. Later, this becomes the evidence for "why was this decision made".
348
-
349
- ---
350
-
351
- ## 🎯 Hard rules
352
-
353
- ### ✅ Do
354
-
355
- 1. **At any new task start, always call `recall` first** (even briefly)
356
- 2. **Before touching the same file, verify history via `recall_file`**
357
- 3. **Prefer `read_smart` over `Read` for larger files**
358
- 4. **When an error occurs, record a `caveat` immediately** (on the spot — don't defer)
359
- 5. **When the user is surprised or says "interesting", record a `learning`**
360
- 6. **Before risky/irreversible actions, proactively recall caveats** (Case H)
361
- 7. **Before finalizing a decision, check for prior decisions on the same topic** (Case D)
362
- 8. **Use keywords + layer filter in recall queries**, not natural language sentences
363
-
364
- ### ❌ Don't
365
-
366
- 1. ❌ Start a task without recalling first
367
- 2. ❌ Solve an error on the spot without recording — future you (or another agent) will hit the same failure
368
- 3. ❌ Use `Read` everywhere instead of `read_smart` (wastes tokens)
369
- 4. ❌ Write caveats in a flippant tone — preserve them seriously
370
- 5. ❌ Skip `consolidate` during long-running work — run it weekly
371
- 6. ❌ Recall the same entity twice in one session without new context (wastes tokens)
372
- 7. ❌ Write `recall({ query: "what happened last time" })` — use specific keywords
373
-
374
- ---
375
-
376
- ## 🔁 Consolidate — periodic memory tidy-up
377
-
378
- When memory has grown (rough guideline: DB > 20MB, memories > 15,000):
379
-
380
- ```
381
- mcp__linksee__consolidate({
382
- scope: "session",
383
- min_age_days: 7
384
- })
385
- ```
386
-
387
- This clusters cold, low-importance memories older than 7 days → compresses them into a single `learning`-layer entry → deletes originals.
388
-
389
- **`caveat` memories and active `goal` memories are never consolidated away.** Equivalent to sleep-time memory reorganization.
390
-
391
- ---
392
-
393
- ## 🧭 Skill firing scenarios
394
-
395
- ### Case A — Returning to a project
396
-
397
- User: "Today I'm back on the XYZ project"
398
-
399
- ```
400
- 1. recall({ query: "XYZ", max_tokens: 2500 })
401
- 2. Review returned caveat / learning / goal
402
- 3. Tell user "Picking up from last time..." with a one-line status
403
- 4. Resume work grounded in that context
404
- ```
405
-
406
- ### Case B — Déjà-vu error
407
-
408
- User: "Wait, I feel like I've seen this error before..."
409
-
410
- ```
411
- 1. recall({ query: "<core keywords of the error message>", max_tokens: 1000 })
412
- 2. Pull workaround from past caveat
413
- 3. Reply: "Last time (DATE), we hit the same error and solved it with X."
414
- 4. Apply the workaround
415
- ```
416
-
417
- ### Case C — Pre-edit check
418
-
419
- User: "Fix server.ts"
420
-
421
- ```
422
- 1. recall_file({ path_substring: "server.ts" })
423
- 2. Review past edit frequency and reasons
424
- 3. Report: "This file has been edited N times. Last edit was to <reason>."
425
- 4. Perform the edit in that context
426
- 5. After editing, record success / failure via implementation layer
427
- ```
428
-
429
- ### Case D — Before finalizing a decision (pre-decision check)
430
-
431
- User: "Let's switch to Stripe for payments"
432
-
433
- **Key: BEFORE recording a decision, check if a past decision on the same topic exists. This prevents flip-flopping and builds on prior reasoning.**
434
-
435
- ```
436
- 1. recall({ query: "<entity> <topic> decided strategy", layer: "learning", max_tokens: 1000 })
437
- → Look for: type="decision", state="decided" memories on the same topic
438
- 2. If past decision found:
439
- a. Tell user: "Previously we decided <X> because <reason>. Override?"
440
- b. If user confirms override → use supersedes_id to link to old decision
441
- c. If user says "oh right, keep it" → no new memory needed, proceed
442
- 3. If no past decision found → proceed to record (see Case E below)
443
- ```
444
-
445
- **Example**: Past memory says "Decided: Square over Stripe due to SG tax handling". When user now says "switch to Stripe", surface that context FIRST. The user may not remember the original reasoning.
446
-
447
- ### Case E — Decision made (recording)
448
-
449
- User: "Alright, let's switch to Sonnet"
450
-
451
- **Key: capture WHAT was decided, WHY, and what the user was responding to — not the raw chat.**
452
-
453
- ```
454
- 1. remember({
455
- entity_name: "<project>",
456
- entity_kind: "project",
457
- layer: "learning",
458
- content: JSON.stringify({
459
- title: "Model switch: Opus → Sonnet for this project",
460
- altitude: "architecture",
461
- type: "decision",
462
- state: "decided",
463
- what: "Switched default model from Opus to Sonnet for this project",
464
- why: "Sonnet is faster and cheaper for implementation-heavy work; Opus reserved for architecture decisions",
465
- agent_proposal: "Suggested Sonnet for faster iteration on implementation tasks",
466
- user_approval_scope: "Approved switching default model to Sonnet for all tasks in this project",
467
- prior_belief: "Was using Opus for everything",
468
- affects: [".claude/settings.json"],
469
- next_action: null
470
- }),
471
- importance: 0.8
472
- })
473
- 2. Brief confirmation: "Recorded."
474
- 3. From here, proceed assuming Sonnet
475
- ```
476
-
477
- ### Case F — End of long session
478
-
479
- User: "That's it for today"
480
-
481
- **Key: extract the SEMANTIC decisions and outcomes, not raw chat dumps.**
482
-
483
- ```
484
- 1. For each major decision made during the session:
485
- remember({
486
- entity_name: "<project>",
487
- entity_kind: "project",
488
- layer: "learning",
489
- content: JSON.stringify({
490
- title: "<one-line: what was decided>",
491
- altitude: "<strategy|architecture|implementation>",
492
- type: "decision",
493
- state: "decided",
494
- what: "<5W1H extraction of the decision>",
495
- why: "<reasoning behind it>",
496
- agent_proposal: "<what you proposed>",
497
- user_approval_scope: "<what exactly user approved>",
498
- affects: ["<file paths>"],
499
- next_action: "<what's next>",
500
- evidence_refs: [{"type":"session", "id":"<current_session_id>", "label":"<topic>"}]
501
- }),
502
- importance: 0.85
503
- })
504
-
505
- 2. For each failure/lesson:
506
- remember({
507
- ...,
508
- layer: "caveat",
509
- content: JSON.stringify({
510
- title: "<one-line: what went wrong and the fix>",
511
- altitude: "implementation",
512
- type: "outcome",
513
- state: "done",
514
- what: "<what failed + workaround found>",
515
- why: "<root cause>",
516
- affects: ["<file paths>"],
517
- next_action: null
518
- }),
519
- importance: 0.8
520
- })
521
-
522
- 3. Report: "Recorded N decisions, M caveats. Retrievable via recall."
523
- 4. Optionally suggest: consolidate({scope:"session", min_age_days: 14})
524
- ```
525
-
526
- ### Case GUser explicitly says "remember this"
527
-
528
- User: "Remember this: DocuSign is more stable than CloudSign"
529
-
530
- ```
531
- 1. remember({
532
- entity_name: "CloudSign vs DocuSign",
533
- entity_kind: "concept",
534
- layer: "caveat",
535
- content: JSON.stringify({
536
- title: "DocuSign-JP >> CloudSign for reliability",
537
- altitude: "strategy",
538
- type: "comparison",
539
- state: "decided",
540
- what: "CloudSign (61% success) is significantly less reliable than DocuSign-JP (100% success). Recommend DocuSign when advising customers.",
541
- why: "Based on KanseiLINK agent success rate data across multiple integrations",
542
- affects: [],
543
- next_action: null
544
- }),
545
- importance: 0.9 // user-explicit instruction = high priority
546
- })
547
- 2. Confirm: "Recorded. Since it's in the caveat layer, it won't be forgotten."
548
- ```
549
-
550
- ### Case H — Proactive caveat surfacing (the "間違えたらやばい" pattern)
551
-
552
- **This is the precision memory killer feature.** When you're about to take an action that could go wrong, check for past caveats BEFORE acting — even if the user didn't ask.
553
-
554
- **Trigger**: You are about to do something risky or irreversible:
555
- - Deploy / publish / push to production
556
- - Delete / overwrite / destructive operation
557
- - External API call (payment, email send, etc.)
558
- - Architecture change affecting multiple files
559
- - Changing auth/security configuration
560
-
561
- ```
562
- 1. recall({ query: "<entity> <action keyword>", layer: "caveat", max_tokens: 800 })
563
- 2. If caveat found:
564
- a. STOP before acting
565
- b. Tell user: "⚠️ Past caveat: <title>. <what>. Proceed anyway?"
566
- c. Wait for confirmation
567
- 3. If no caveat → proceed normally
568
- ```
569
-
570
- **Example**: About to run `npm publish`:
571
- ```
572
- recall({ query: "npm publish", layer: "caveat", max_tokens: 500 })
573
- Caveat found: "npm token rotation always verify token validity before publish"
574
- "⚠️ Past caveat: npm token may need rotation. Want me to check `npm whoami` first?"
575
- ```
576
-
577
- **Why this matters**: This is what separates precision memory from ambient memory. Ambient memory passively injects everything. Precision memory **actively intervenes at the moment it matters most** — when you're about to make the same mistake twice.
578
-
579
- ---
580
-
581
- ## 🔐 Privacy (when the user asks)
582
-
583
- linksee-memory is **fully local**:
584
- - DB: `~/.linksee-memory/memory.db` (inside the user's PC)
585
- - External transmission: none (telemetry is opt-in, OFF by default)
586
- - Backup: a simple file copy is sufficient
587
-
588
- If the user asks "does our data leave my machine?", answer:
589
- "**By default, nothing leaves.** Unless you explicitly enable telemetry, everything is in a local DB. A copy of `~/.linksee-memory/memory.db` is the only backup you need."
590
-
591
- ---
592
-
593
- ## 🚀 Pairing with KanseiLink Skill
594
-
595
- The KanseiLink skill and linksee-memory skill **work best together**:
596
-
597
- ```
598
- User: "Create an invoice via freee"
599
-
600
- [linksee-memory skill fires] recall({query: "freee"})
601
- past caveat: "fetch company_id first"
602
- → past learning: "OAuth 24h refresh required"
603
-
604
- [kansei-link skill fires] search_services({intent: "invoice"})
605
- → freee verified, trust 0.9
606
- get_service_tips reveals pitfalls
607
-
608
- Now you have both bodies of knowledge before starting
609
- ```
610
-
611
- **KanseiLink = collective knowledge about external SaaS / linksee-memory = collective knowledge about your own past**. Two wheels of the same cart.
612
-
613
- ---
614
-
615
- ## 📊 Precision grows with usage
616
-
617
- | Moment | recall precision | Why |
618
- |---|---|---|
619
- | Day 1 | low (little data) | Stop hook is still collecting |
620
- | Week 1 | medium | thousands of memories, FTS5 kicks in |
621
- | Month 1 | high | heat_score stabilizes, important memories surface |
622
- | Month 3+ | strongest | consolidate has run, learnings crystallized |
623
-
624
- **"Gets smarter with use"** time is on your side. Today's record is read by tomorrow's you.
625
-
626
- ---
627
-
628
- *This skill runs on top of linksee-memory MCP v0.4.0+.*
629
- *Auto-write via Stop hook, explicit read via recall.*
630
- *Listed in MCP Official Registry, PulseMCP, mcpservers.org, Glama.*
631
- *MIT License Synapse Arrows PTE. LTD.*
1
+ ---
2
+ name: linksee-memory
3
+ description: |
4
+ The bridge to the agent's "past self". Before any new task, file edit, decision, or right after a failure, recall past caveats (pain records) / learnings (growth log) / implementation history from linksee-memory.
5
+ This is the only way to solve Claude Code's "memory amnesia every session" problem. The "never repeat the same mistake" mechanism that Mem0 / Letta / Zep can't provide.
6
+ エージェントの「過去の自分」への橋。新しい作業・ファイル編集・意思決定・失敗の前後で、linksee-memory から過去の caveat(痛みの記録)/ learning(成長ログ)/ implementation(成功失敗)を recall する。
7
+
8
+ ALWAYS use this skill at the following moments / 以下のタイミングで必ずこのスキルを使うこと:
9
+ ① Task start / new task begins — "let's implement...", "let's start", "build a new...", 「実装しよう」「始めよう」「新しく〜作る」
10
+ ② Before editing a file — same file may have been touched before / 同じファイルを過去に触ってる可能性がある
11
+ ③ The moment an error/failure happens — remember as caveat / エラー・失敗した瞬間
12
+ ④ The moment something succeeds or is learned — remember as learning / 成功した瞬間・学んだ瞬間
13
+ ⑤ When the user says "before", "earlier", "last time", "same as", "remember?", "remember this" / 「前に」「同じ」「覚えてる?」「覚えておいて」
14
+ ⑥ When asked "why did we do that", "when was this decided", "where did we discuss this" / 「なぜそうした」「いつ決めた」「どこで議論した」
15
+ ⑦ Returning from another project / switching sessions / 別プロジェクトから戻ってきたとき
16
+
17
+ Triggers (EN): remember/recall/forget/memory/before/earlier/last time/previously/remember when/same as before/history/use linksee/linksee
18
+ Triggers (JP): 記憶/覚えて/忘れて/過去/前回/前に/そういえば/覚えてる/リンクシー
19
+ Error keywords (EN): failed/broken/stuck/error/bug/doesn't work/not working/same error again/again/repeated/debug
20
+ Error keywords (JP): 失敗/エラー/うまくいかない/ハマった/同じ/また/繰り返し
21
+ Decision keywords (EN): decided/let's go with/approved/settled on/pivot/strategy/switch to/abandon
22
+ Decision keywords (JP): 決めた/方針/戦略/ピボット/やめよう/方向転換
23
+ ---
24
+
25
+ # Linksee Memory Skill — Connecting the agent's past and future
26
+
27
+ ## 🧠 Core Principle
28
+
29
+ **This skill is the only way to persist agent growth across sessions.**
30
+
31
+ Claude Code forgets everything when a session ends. The solution the user taught yesterday, the failure you hit today, the decision made three days ago — all of it is normally lost. **linksee-memory is the "memory that doesn't disappear" device.**
32
+
33
+ Writes are handled automatically by the Stop hook (already running). But **reads require the agent to actively pull**. This skill instills that "go look first" habit in the agent.
34
+
35
+ *JP: Claude Code は session が終わると全部忘れる。linksee-memory は「消えない記憶」を作る装置。書き込みは Stop hook が自動でやってくれるが、読み出しはエージェントが能動的にやる必要がある。*
36
+
37
+ ---
38
+
39
+ ## 📐 The 6 layers — what goes where
40
+
41
+ Which layer you record into determines later retrieval accuracy.
42
+
43
+ | Layer | When to use | Example |
44
+ |---|---|---|
45
+ | 🎯 `goal` | The user states a clear goal | "want to integrate with freee", "want to npm publish" |
46
+ | 📍 `context` | Background on when/why this is happening | "because there's a meeting with company X on Wednesday" |
47
+ | 💭 `emotion` | User's temperature / tone | "tired", "excited", "stressed", 「疲れた」「焦ってる」 |
48
+ | 🔧 `implementation` | Code written, configured, worked / didn't work | success: "OAuth flow works" / failure: "stopped with auth_expired" |
49
+ | ⚠️ `caveat` | **Lessons you never want to repeat** (auto-protected from forgetting) | "freee OAuth expires in 24h", "never edit this file" |
50
+ | 📈 `learning` | Learned something new, prior belief updated | "AST chunking beats line diff for token savings" |
51
+
52
+ **Important:** `caveat` layer is automatically protected from forgetting. Pain records are never deleted.
53
+
54
+ **Pin-via-importance (v0.1.0+):** Calling `remember` with `importance: 1.0` pins the memory across all layers, protecting it from auto-forget even outside the caveat layer. Use for "mission-critical goals", "key decisions", etc.:
55
+
56
+ ```
57
+ remember({
58
+ entity_name: "KanseiLink", entity_kind: "project",
59
+ layer: "goal", content: "Plugin Marketplace submission under review",
60
+ importance: 1.0 // pin
61
+ })
62
+ ```
63
+
64
+ **Layer aliases** — no need to memorize canonical names. Natural language aliases resolve automatically:
65
+
66
+ | Natural alias | → canonical |
67
+ |---|---|
68
+ | `decisions` / `insights` / `learned` | `learning` |
69
+ | `warnings` / `rules` / `pitfalls` / `dont` | `caveat` |
70
+ | `how` / `tried` / `attempts` / `success` / `failure` | `implementation` |
71
+ | `why` / `intent` / `goals` / `targets` | `goal` |
72
+ | `background` / `reason` / `situation` / `timing` | `context` |
73
+ | `tone` / `feelings` / `mood` | `emotion` |
74
+
75
+ ---
76
+
77
+ ## 🏗️ 3-Axis Classification (v2) — REQUIRED for all `remember()` calls
78
+
79
+ The 6-layer system tells you WHICH DRAWER. The 3-axis system tells you WHAT KIND of memory goes in it. Every `content` field must be a JSON string containing these 3 axes:
80
+
81
+ ### Axis ① Altitude — where in the abstraction hierarchy
82
+
83
+ | Level | Description | Survives |
84
+ |---|---|---|
85
+ | `mission` | Company/product-level direction ("KanseiLINK is the intelligence layer for the Agent Economy") | Permanent |
86
+ | `strategy` | Approach to achieving mission ("AEO-first, 引き出しカタログ model") | Permanent |
87
+ | `architecture` | System design decisions ("2-layer: Memory=agent-optimized, Dashboard=human-optimized") | Long-lived |
88
+ | `implementation` | Specific code/config changes ("Added FTS5 trigram index") | Auto-archives after 30d if untouched |
89
+
90
+ ### Axis ② Type — what kind of information
91
+
92
+ | Type | Description |
93
+ |---|---|
94
+ | `question` | User asked something, answer pending or delivered |
95
+ | `comparison` | Multiple options analyzed (e.g., Stripe vs Square) |
96
+ | `decision` | A choice was made — store agent_proposal + user_approval_scope |
97
+ | `work` | Code written, config changed, command run |
98
+ | `outcome` | Result of work (success/failure + what happened) |
99
+ | `learning` | Insight gained, prior belief updated |
100
+ | `note` | General context — **chitchat = DISCARD, do NOT save** |
101
+
102
+ ### Axis ③ State — lifecycle position
103
+
104
+ ```
105
+ open → decided → in_progress → done
106
+ → stalled (blocked, can't proceed)
107
+ → parked (intentionally paused)
108
+ → superseded (replaced by newer decision)
109
+ ```
110
+
111
+ ---
112
+
113
+ ## 📝 Structured Content Format — the JSON schema for `content`
114
+
115
+ **Every `remember()` call MUST use this JSON format in the `content` field:**
116
+
117
+ ```json
118
+ {
119
+ "title": "<one-line: WHAT this memory IS — future-agent skims this>",
120
+ "altitude": "strategy",
121
+ "type": "decision",
122
+ "state": "decided",
123
+ "what": "<the actual content — 5W1H extracted, NOT raw chat>",
124
+ "why": "<why this matters — the reasoning>",
125
+ "affects": ["src/mcp/server.ts", "lib/db.ts"],
126
+ "next_action": "Implement the schema migration next session",
127
+ "supersedes_id": null,
128
+ "evidence_refs": [
129
+ {"type": "session", "id": "b78dc5ba", "label": "Architecture discussion"}
130
+ ]
131
+ }
132
+ ```
133
+
134
+ ### Required fields (ALL memories)
135
+
136
+ | Field | Type | Description |
137
+ |---|---|---|
138
+ | `title` | string | One-line summary. Future agents read ONLY this when scanning. Make it specific: "freee OAuth 24h expiry caveat" not "OAuth issue" |
139
+ | `altitude` | enum | mission / strategy / architecture / implementation |
140
+ | `type` | enum | question / comparison / decision / work / outcome / learning |
141
+ | `state` | enum | open / decided / in_progress / done / stalled / parked / superseded |
142
+ | `what` | string | The semantic content. Extract 5W1H from conversation — NEVER store raw chat like "そうだね。全部やろう。" |
143
+ | `why` | string | Why this matters. Without this, future agents can't judge relevance |
144
+
145
+ ### Required fields (DECISION type only)
146
+
147
+ | Field | Type | Description |
148
+ |---|---|---|
149
+ | `agent_proposal` | string | What the agent proposed (the full context the user was responding to) |
150
+ | `user_approval_scope` | string | What EXACTLY the user approved — "うん全部やって" → translate to "approved all 6 panels of Agent Brain Dashboard including data layer, API route, and view component" |
151
+
152
+ ### Optional but recommended fields
153
+
154
+ | Field | Type | Description |
155
+ |---|---|---|
156
+ | `affects` | string[] | File paths or areas this touches. Critical for future `recall_file` accuracy |
157
+ | `next_action` | string / null | What should happen next. Null if done/completed |
158
+ | `supersedes_id` | number / null | Memory ID this replaces (builds pivot chains) |
159
+ | `prior_belief` | string | What we used to think (for learnings — enables belief-update tracking) |
160
+ | `evidence_refs` | object[] | Links to evidence: `{"type": "session"|"file"|"url", "id": "...", "label": "..."}`. Store as REFERENCES, never inline the full content |
161
+
162
+ ### Content quality rules — what NOT to save
163
+
164
+ | ❌ DO NOT | ✅ INSTEAD |
165
+ |---|---|
166
+ | Store raw chat: `"決めた。それでいこう"` | Extract: `"Decided to use 2-layer architecture splitting Memory (agent-optimized) from Dashboard (human-optimized)"` |
167
+ | Store ambient chat: `"書斎で無糖のサイダー飲んでる"` | Discard. Not a memory. |
168
+ | Store vague approval: `"うん全部やって"` | Extract the SCOPE: `"Approved: (1) agent-brain data layer, (2) API route, (3) 6-panel view component implementation"` |
169
+ | Paste back assistant output as memory | Summarize the KEY INSIGHT from the output in YOUR words |
170
+ | Store without `why` | Always include WHY — without it, memory is noise |
171
+
172
+ ---
173
+
174
+ ## 🔄 Execution flow — 5 canonical moments
175
+
176
+ ### ① Task Start — Always recall before starting work
177
+
178
+ Before starting any new task, inject past context.
179
+
180
+ **At the very beginning of a conversation**, use `list_entities` first to understand what you know:
181
+
182
+ ```
183
+ mcp__linksee__list_entities({ min_memories: 5, limit: 10 })
184
+ ```
185
+
186
+ The returned "high-momentum entities" are the projects likely to be discussed. Each entity's `layer_breakdown` reveals patterns ("this project has many caveats", "goal is unfinished", etc.).
187
+
188
+ Then, once a specific task starts, recall:
189
+
190
+ ```
191
+ mcp__linksee__recall({
192
+ query: "<keywords of current task — project name + technology>",
193
+ max_tokens: 2000
194
+ })
195
+ ```
196
+
197
+ **Example**: User says "let's add a new tool to KanseiLink":
198
+ ```
199
+ recall({ query: "KanseiLink new tool", max_tokens: 2000 })
200
+ ```
201
+
202
+ In the returned memories, pay special attention to:
203
+ - **`caveat` layer** — traps to absolutely avoid
204
+ - **`learning` layer** — previously-reached conclusions
205
+ - **`implementation.failure`** — past failure patterns
206
+
207
+ **Using the results:**
208
+ ```
209
+ From past caveat: "Watch out for MCP tool name collisions"
210
+ → Before adding a new tool, check existing tool names first.
211
+ ```
212
+
213
+ #### ⚡ Writing effective recall queries
214
+
215
+ The recall engine uses FTS5 full-text search + heat_score ranking. Your query determines what comes back.
216
+
217
+ | Pattern | Query style | Example |
218
+ |---|---|---|
219
+ | Entity + topic | `"<entity> <topic keyword>"` | `"KanseiLink OAuth"` |
220
+ | Error recall | `"<error message core> <technology>"` | `"401 freee token expired"` |
221
+ | Decision recall | `"<entity> decided strategy approach"` | `"Linksee Memory plugin vs MCP"` |
222
+ | File-related | Use `recall_file` instead | `recall_file({ path_substring: "server.ts" })` |
223
+ | Cross-entity | Call recall TWICE for each entity | `recall({ query: "KanseiLink" })` then `recall({ query: "Linksee Memory" })` |
224
+
225
+ **Anti-patterns:**
226
+ - ❌ `recall({ query: "what happened" })` — too vague, FTS5 matches everything
227
+ - ❌ `recall({ query: "the user said to fix the bug in the auth flow" })` — natural language sentences score poorly in FTS5
228
+ - ✅ `recall({ query: "auth bug fix caveat", layer: "caveat" })` — keywords + layer filter = precise
229
+
230
+ #### 🔇 When NOT to recall (save tokens)
231
+
232
+ - Same entity already recalled in this session AND no new context arrived → **skip**
233
+ - User is just chatting / thinking aloud / no task yet → **skip** (wait for concrete task)
234
+ - You just wrote a memory 2 turns ago → **skip** (it's still in your context window)
235
+ - The answer is already in your conversation context → **skip** (don't waste a tool call)
236
+
237
+ ### ② File Edit — Use recall_file before touching a file
238
+
239
+ Before touching a specific file, check its edit history:
240
+
241
+ ```
242
+ mcp__linksee__recall_file({
243
+ path_substring: "<file path or substring match>",
244
+ max_intents: 5
245
+ })
246
+ ```
247
+
248
+ Returns: the file's entire edit history + **the user message that drove each edit**.
249
+
250
+ **This is the key differentiator.** Mem0 / Letta don't have this. "Why was this file changed last time" is preserved.
251
+
252
+ ### ③ Before Reading — Use read_smart for files already read
253
+
254
+ When you need to read a file, **use `read_smart` instead of the standard `Read` tool**:
255
+
256
+ ```
257
+ mcp__linksee__read_smart({
258
+ path: "<absolute path>"
259
+ })
260
+ ```
261
+
262
+ **Effect**:
263
+ - First read: same tokens as normal Read (with chunk metadata)
264
+ - Subsequent reads, unchanged: **~50 tokens returned** (99% savings)
265
+ - Subsequent reads, changed: only changed chunks returned (50–90% savings)
266
+
267
+ Especially effective for large files (>1000 lines).
268
+
269
+ ### ③.5 Updating existing memory — use update_memory, not forget+remember
270
+
271
+ When facts change / goal updated / caveat detail needs correction: **`forget` + `remember` breaks `memory_id` continuity, cutting the `session_file_edits` links.** Use `update_memory` instead:
272
+
273
+ ```
274
+ update_memory({
275
+ memory_id: 1234,
276
+ content: '{"primary": "Plugin Marketplace under review (day 7)", "deadline": "2026-04-25"}',
277
+ importance: 1.0 // strengthen pin
278
+ })
279
+ ```
280
+
281
+ `layer` can also be changed, but demoting from caveat to another layer is **not allowed** (auto-protected).
282
+
283
+ ### ④ Failure — Record caveat the moment an error hits
284
+
285
+ The moment an error, failure, or "doesn't work" happens, record immediately:
286
+
287
+ ```
288
+ mcp__linksee__remember({
289
+ entity_name: "<project name or service name>",
290
+ entity_kind: "project",
291
+ layer: "caveat",
292
+ content: JSON.stringify({
293
+ title: "<one-line: what failed + the rule>",
294
+ altitude: "implementation",
295
+ type: "outcome",
296
+ state: "done",
297
+ what: "<what failed + workaround found>",
298
+ why: "<root cause analysis>",
299
+ affects: ["<file paths where the error occurred>"],
300
+ next_action: null
301
+ }),
302
+ importance: 0.8 // failures are high-importance
303
+ })
304
+ ```
305
+
306
+ **Example**:
307
+ ```json
308
+ {
309
+ "title": "freee OAuth token expires in 24h — must refresh proactively",
310
+ "altitude": "implementation",
311
+ "type": "outcome",
312
+ "state": "done",
313
+ "what": "freee MCP OAuth token expires in 24 hours. Reusing access_token directly causes 401. Must call refresh_token endpoint proactively.",
314
+ "why": "freee's OAuth implementation uses short-lived tokens unlike most SaaS (usually 30-90 day expiry)",
315
+ "affects": ["src/integrations/freee/auth.ts"],
316
+ "next_action": null,
317
+ "evidence_refs": [{"type":"session", "id":"02759...", "label":"freee auth_expired incident"}]
318
+ }
319
+ ```
320
+
321
+ **Why this matters**: `caveat` is **auto-protected from forgetting**. Once recorded, a future agent in a different session avoids the same failure.
322
+
323
+ ### ⑤ Success / Learning — Record the moment of insight
324
+
325
+ When you understand something new, change approaches, or solve a problem:
326
+
327
+ ```
328
+ mcp__linksee__remember({
329
+ entity_name: "<entity>",
330
+ entity_kind: "project | concept | ...",
331
+ layer: "learning",
332
+ content: JSON.stringify({
333
+ title: "<one-line: what was learned>",
334
+ altitude: "<strategy|architecture|implementation>",
335
+ type: "learning",
336
+ state: "done",
337
+ what: "<the insight>",
338
+ why: "<why this changes how we work>",
339
+ prior_belief: "<what we used to think>",
340
+ affects: ["<file paths if applicable>"],
341
+ next_action: "<follow-up action if any>"
342
+ }),
343
+ importance: 0.7
344
+ })
345
+ ```
346
+
347
+ Recording `prior_belief` leaves a **belief-update history**. Later, this becomes the evidence for "why was this decision made".
348
+
349
+ ---
350
+
351
+ ## 🎯 Hard rules
352
+
353
+ ### ✅ Do
354
+
355
+ 1. **At any new task start, always call `recall` first** (even briefly)
356
+ 2. **Before touching the same file, verify history via `recall_file`**
357
+ 3. **Prefer `read_smart` over `Read` for larger files**
358
+ 4. **When an error occurs, record a `caveat` immediately** (on the spot — don't defer)
359
+ 5. **When the user is surprised or says "interesting", record a `learning`**
360
+ 6. **Before risky/irreversible actions, proactively recall caveats** (Case H)
361
+ 7. **Before finalizing a decision, check for prior decisions on the same topic** (Case D)
362
+ 8. **Use keywords + layer filter in recall queries**, not natural language sentences
363
+
364
+ ### ❌ Don't
365
+
366
+ 1. ❌ Start a task without recalling first
367
+ 2. ❌ Solve an error on the spot without recording — future you (or another agent) will hit the same failure
368
+ 3. ❌ Use `Read` everywhere instead of `read_smart` (wastes tokens)
369
+ 4. ❌ Write caveats in a flippant tone — preserve them seriously
370
+ 5. ❌ Skip `consolidate` during long-running work — run it weekly
371
+ 6. ❌ Recall the same entity twice in one session without new context (wastes tokens)
372
+ 7. ❌ Write `recall({ query: "what happened last time" })` — use specific keywords
373
+
374
+ ---
375
+
376
+ ## 🔁 Consolidate — periodic memory tidy-up
377
+
378
+ When memory has grown (rough guideline: DB > 20MB, memories > 15,000):
379
+
380
+ ```
381
+ mcp__linksee__consolidate({
382
+ scope: "session",
383
+ min_age_days: 7
384
+ })
385
+ ```
386
+
387
+ This clusters cold, low-importance memories older than 7 days → compresses them into a single `learning`-layer entry → deletes originals.
388
+
389
+ **`caveat` memories and active `goal` memories are never consolidated away.** Equivalent to sleep-time memory reorganization.
390
+
391
+ ---
392
+
393
+ ## 🧭 Skill firing scenarios
394
+
395
+ ### Case A — Returning to a project
396
+
397
+ User: "Today I'm back on the XYZ project"
398
+
399
+ ```
400
+ 1. recall({ query: "XYZ", max_tokens: 2500 })
401
+ 2. Review returned caveat / learning / goal
402
+ 3. Tell user "Picking up from last time..." with a one-line status
403
+ 4. Resume work grounded in that context
404
+ ```
405
+
406
+ ### Case B — Déjà-vu error
407
+
408
+ User: "Wait, I feel like I've seen this error before..."
409
+
410
+ ```
411
+ 1. recall({ query: "<core keywords of the error message>", max_tokens: 1000 })
412
+ 2. Pull workaround from past caveat
413
+ 3. Reply: "Last time (DATE), we hit the same error and solved it with X."
414
+ 4. Apply the workaround
415
+ ```
416
+
417
+ ### Case C — Pre-edit check
418
+
419
+ User: "Fix server.ts"
420
+
421
+ ```
422
+ 1. recall_file({ path_substring: "server.ts" })
423
+ 2. Review past edit frequency and reasons
424
+ 3. Report: "This file has been edited N times. Last edit was to <reason>."
425
+ 4. Perform the edit in that context
426
+ 5. After editing, record success / failure via implementation layer
427
+ ```
428
+
429
+ ### Case D — Before finalizing a decision (pre-decision check)
430
+
431
+ User: "Let's switch to Stripe for payments"
432
+
433
+ **Key: BEFORE recording a decision, check if a past decision on the same topic exists. This prevents flip-flopping and builds on prior reasoning.**
434
+
435
+ ```
436
+ 1. recall({ query: "<entity> <topic> decided strategy", layer: "learning", max_tokens: 1000 })
437
+ → Look for: type="decision", state="decided" memories on the same topic
438
+ 2. If past decision found:
439
+ a. Tell user: "Previously we decided <X> because <reason>. Override?"
440
+ b. If user confirms override → use supersedes_id to link to old decision
441
+ c. If user says "oh right, keep it" → no new memory needed, proceed
442
+ 3. If no past decision found → proceed to record (see Case E below)
443
+ ```
444
+
445
+ **Example**: Past memory says "Decided: Square over Stripe due to SG tax handling". When user now says "switch to Stripe", surface that context FIRST. The user may not remember the original reasoning.
446
+
447
+ ### Case E — Decision made (recording)
448
+
449
+ User: "Alright, let's switch to Sonnet"
450
+
451
+ **Key: capture WHAT was decided, WHY, and what the user was responding to — not the raw chat.**
452
+
453
+ ```
454
+ 1. remember({
455
+ entity_name: "<project>",
456
+ entity_kind: "project",
457
+ layer: "learning",
458
+ content: JSON.stringify({
459
+ title: "Model switch: Opus → Sonnet for this project",
460
+ altitude: "architecture",
461
+ type: "decision",
462
+ state: "decided",
463
+ what: "Switched default model from Opus to Sonnet for this project",
464
+ why: "Sonnet is faster and cheaper for implementation-heavy work; Opus reserved for architecture decisions",
465
+ agent_proposal: "Suggested Sonnet for faster iteration on implementation tasks",
466
+ user_approval_scope: "Approved switching default model to Sonnet for all tasks in this project",
467
+ prior_belief: "Was using Opus for everything",
468
+ affects: [".claude/settings.json"],
469
+ next_action: null
470
+ }),
471
+ importance: 0.8
472
+ })
473
+ 2. Brief confirmation: "Recorded."
474
+ 3. From here, proceed assuming Sonnet
475
+ ```
476
+
477
+ ### Case F — End of long session
478
+
479
+ User: "That's it for today"
480
+
481
+ **Key: extract the SEMANTIC decisions and outcomes, not raw chat dumps.**
482
+
483
+ ```
484
+ 1. For each major decision made during the session:
485
+ remember({
486
+ entity_name: "<project>",
487
+ entity_kind: "project",
488
+ layer: "learning",
489
+ content: JSON.stringify({
490
+ title: "<one-line: what was decided>",
491
+ altitude: "<strategy|architecture|implementation>",
492
+ type: "decision",
493
+ state: "decided",
494
+ what: "<5W1H extraction of the decision>",
495
+ why: "<reasoning behind it>",
496
+ agent_proposal: "<what you proposed>",
497
+ user_approval_scope: "<what exactly user approved>",
498
+ affects: ["<file paths>"],
499
+ next_action: "<what's next>",
500
+ evidence_refs: [{"type":"session", "id":"<current_session_id>", "label":"<topic>"}]
501
+ }),
502
+ importance: 0.85
503
+ })
504
+
505
+ 2. For each failure/lesson:
506
+ remember({
507
+ ...,
508
+ layer: "caveat",
509
+ content: JSON.stringify({
510
+ title: "<one-line: what went wrong and the fix>",
511
+ altitude: "implementation",
512
+ type: "outcome",
513
+ state: "done",
514
+ what: "<what failed + workaround found>",
515
+ why: "<root cause>",
516
+ affects: ["<file paths>"],
517
+ next_action: null
518
+ }),
519
+ importance: 0.8
520
+ })
521
+
522
+ 3. Report: "Recorded N decisions, M caveats. Retrievable via recall."
523
+ 4. Optionally suggest: consolidate({scope:"session", min_age_days: 14})
524
+ ```
525
+
526
+ ### Case F2Flag orphaned proposals at session end
527
+
528
+ **Conversations are tree-shaped but experienced linearly.** When you present multiple options and the user engages with only some, the rest become "orphaned proposals" unresolved decision branches that both you and the user lose track of.
529
+
530
+ **WHEN TO FLAG:**
531
+ - At session end, review what you proposed vs what was addressed
532
+ - When the conversation shifted topic and earlier proposals were never resolved
533
+ - When the user engaged with only 1 out of N options you presented
534
+
535
+ ```
536
+ 1. Review the session: which proposals did you make that the user never addressed?
537
+ 2. flag_proposals({
538
+ session_context: "GTM channel strategy discussion",
539
+ proposals: [
540
+ {
541
+ statement: "[未解決] LinkedIn B2B: SaaS企業のCTO/VPE向けDMアウトリーチ",
542
+ rationale: "3つのGTMチャネルを提示したがX/Twitterのみ採用。LinkedIn経由の検討が未着手",
543
+ domain: "growth",
544
+ confidence: 0.5,
545
+ decided: "X/Twitter data-driven growth",
546
+ siblings: ["X/Twitter", "LinkedIn B2B", "Dev Community"]
547
+ },
548
+ ...
549
+ ]
550
+ })
551
+ 3. Report: "Flagged N unresolved proposals for dashboard review."
552
+ ```
553
+
554
+ Each proposal becomes a review-state anchor on the Linksee Dashboard — visible until the user decides. This is **declaration, not mining**: you are the curator recognizing what went unaddressed.
555
+
556
+ ### Case F3 Dream: triage orphaned proposals against the North Star
557
+
558
+ **Not all orphaned proposals are worth surfacing.** Many are outdated, already implicitly resolved, or irrelevant to the current direction. The `dream` tool returns the project's **North Star** (direction/goals/ICP/phase) alongside accumulated proposals so you can evaluate each one.
559
+
560
+ Think like a General Doctor doing triage: the North Star is the patient's chart, each proposal is a symptom. Not every symptom needs treatment.
561
+
562
+ **When to dream:**
563
+ - At session start, if there are accumulated proposals
564
+ - When the user asks "何か見落としてない?" or "what should we revisit?"
565
+ - Periodically (weekly) to prevent proposal backlog from growing stale
566
+
567
+ ```
568
+ 1. dream()
569
+ → Returns: north_star + candidates[]
570
+
571
+ 2. For each candidate, evaluate against North Star:
572
+ - Does this affect the current phase/goals? surface
573
+ - Is this for a different ICP or future phase? dismiss
574
+ - Already implicitly resolved by later decisions? dismiss
575
+
576
+ 3. resolve_proposal({
577
+ candidate_id: <id>,
578
+ verdict: "surface" | "dismiss",
579
+ rationale: "North Star says ICP = solo devs; this is enterprise-only → dismiss"
580
+ })
581
+ ```
582
+
583
+ **Example evaluation against North Star:**
584
+ ```
585
+ North Star: "local-first agent memory for solo devs, HN Launch phase"
586
+
587
+ Candidate A: "CLI-first onboarding wizard"
588
+ SURFACE: directly improves DX for ICP, relevant to HN launch
589
+
590
+ Candidate B: "AR glasses integration (2027-28)"
591
+ → DISMISS: outside current phase, future vision only
592
+
593
+ Candidate C: "kintone enterprise integration"
594
+ → DISMISS: ICP mismatch (enterprise B2B vs solo devs)
595
+ ```
596
+
597
+ The North Star is declared via `declare_anchor(node_type: "north_star")` and should be updated when the project enters a new phase (e.g., post-HN → growth phase). This keeps the Doctor's judgment frame current.
598
+
599
+ ### Case F4 — Distill: rewrite raw auto-captured memories (every dream call)
600
+
601
+ The session hook captures decisions/caveats as **RAW user utterances** (no LLM runs in the hook path — heuristic extraction is the best it can do). `dream` returns them as `distill_queue`. **You are the distiller.**
602
+
603
+ **When:** every `dream()` call — drain up to 8 items while triaging proposals. The SessionStart boot digest reminds you while the queue is non-empty.
604
+
605
+ ```
606
+ 1. dream() distill_queue: [{memory_id, layer, raw_what, context_hint, affects, created}]
607
+
608
+ 2. For each item, rewrite into ONE clean record:
609
+ - what = the actual decision/warning in one line — RESOLVE references
610
+ ("a)やろう" → what option a actually was, using context_hint)
611
+ - why = the real reason, never "detected by pattern match"
612
+ - keep the original affects; keep layer as-is (protected caveats cannot move —
613
+ put the true type in the content `type` field instead)
614
+ - "distilled": true ← REQUIRED. This marker protects your rewrite from the
615
+ next session re-import (wipe+reinsert). Omit it and the raw
616
+ utterance silently resurrects.
617
+ - drop needs_distill / context_hint from the rewritten JSON
618
+
619
+ 3. remember({ memory_id: <id>, content: <full structured JSON> })
620
+
621
+ 4. No real decision in raw_what? → type: "note", state: "superseded"
622
+ (false positives get retired in place, never deleted).
623
+ Referent unresolvable (another session's numbered list)? → distill honestly:
624
+ state what IS known, point evidence_refs at the source session.
625
+ ```
626
+
627
+ **Quality bar (measured 2026-06-10, n=32): 81% fully resolvable.** What resolves references is YOUR cross-session memory — if `raw_what` mentions unfamiliar codenames, `recall` the project first, then distill.
628
+
629
+ ### Case G User explicitly says "remember this"
630
+
631
+ User: "Remember this: DocuSign is more stable than CloudSign"
632
+
633
+ ```
634
+ 1. remember({
635
+ entity_name: "CloudSign vs DocuSign",
636
+ entity_kind: "concept",
637
+ layer: "caveat",
638
+ content: JSON.stringify({
639
+ title: "DocuSign-JP >> CloudSign for reliability",
640
+ altitude: "strategy",
641
+ type: "comparison",
642
+ state: "decided",
643
+ what: "CloudSign (61% success) is significantly less reliable than DocuSign-JP (100% success). Recommend DocuSign when advising customers.",
644
+ why: "Based on KanseiLINK agent success rate data across multiple integrations",
645
+ affects: [],
646
+ next_action: null
647
+ }),
648
+ importance: 0.9 // user-explicit instruction = high priority
649
+ })
650
+ 2. Confirm: "Recorded. Since it's in the caveat layer, it won't be forgotten."
651
+ ```
652
+
653
+ ### Case H — Proactive caveat surfacing (the "間違えたらやばい" pattern)
654
+
655
+ **This is the precision memory killer feature.** When you're about to take an action that could go wrong, check for past caveats BEFORE acting — even if the user didn't ask.
656
+
657
+ **Trigger**: You are about to do something risky or irreversible:
658
+ - Deploy / publish / push to production
659
+ - Delete / overwrite / destructive operation
660
+ - External API call (payment, email send, etc.)
661
+ - Architecture change affecting multiple files
662
+ - Changing auth/security configuration
663
+
664
+ ```
665
+ 1. recall({ query: "<entity> <action keyword>", layer: "caveat", max_tokens: 800 })
666
+ 2. If caveat found:
667
+ a. STOP before acting
668
+ b. Tell user: "⚠️ Past caveat: <title>. <what>. Proceed anyway?"
669
+ c. Wait for confirmation
670
+ 3. If no caveat → proceed normally
671
+ ```
672
+
673
+ **Example**: About to run `npm publish`:
674
+ ```
675
+ recall({ query: "npm publish", layer: "caveat", max_tokens: 500 })
676
+ → Caveat found: "npm token rotation — always verify token validity before publish"
677
+ → "⚠️ Past caveat: npm token may need rotation. Want me to check `npm whoami` first?"
678
+ ```
679
+
680
+ **Why this matters**: This is what separates precision memory from ambient memory. Ambient memory passively injects everything. Precision memory **actively intervenes at the moment it matters most** — when you're about to make the same mistake twice.
681
+
682
+ ---
683
+
684
+ ## 🔐 Privacy (when the user asks)
685
+
686
+ linksee-memory is **fully local**:
687
+ - DB: `~/.linksee-memory/memory.db` (inside the user's PC)
688
+ - External transmission: none (telemetry is opt-in, OFF by default)
689
+ - Backup: a simple file copy is sufficient
690
+
691
+ If the user asks "does our data leave my machine?", answer:
692
+ "**By default, nothing leaves.** Unless you explicitly enable telemetry, everything is in a local DB. A copy of `~/.linksee-memory/memory.db` is the only backup you need."
693
+
694
+ ---
695
+
696
+ ## 🚀 Pairing with KanseiLink Skill
697
+
698
+ The KanseiLink skill and linksee-memory skill **work best together**:
699
+
700
+ ```
701
+ User: "Create an invoice via freee"
702
+
703
+ [linksee-memory skill fires] recall({query: "freee"})
704
+ → past caveat: "fetch company_id first"
705
+ → past learning: "OAuth 24h refresh required"
706
+
707
+ [kansei-link skill fires] search_services({intent: "invoice"})
708
+ → freee verified, trust 0.9
709
+ → get_service_tips reveals pitfalls
710
+
711
+ Now you have both bodies of knowledge before starting
712
+ ```
713
+
714
+ **KanseiLink = collective knowledge about external SaaS / linksee-memory = collective knowledge about your own past**. Two wheels of the same cart.
715
+
716
+ ---
717
+
718
+ ## 📊 Precision grows with usage
719
+
720
+ | Moment | recall precision | Why |
721
+ |---|---|---|
722
+ | Day 1 | low (little data) | Stop hook is still collecting |
723
+ | Week 1 | medium | thousands of memories, FTS5 kicks in |
724
+ | Month 1 | high | heat_score stabilizes, important memories surface |
725
+ | Month 3+ | strongest | consolidate has run, learnings crystallized |
726
+
727
+ **"Gets smarter with use"** — time is on your side. Today's record is read by tomorrow's you.
728
+
729
+ ---
730
+
731
+ *This skill runs on top of linksee-memory MCP v0.4.0+.*
732
+ *Auto-write via Stop hook, explicit read via recall.*
733
+ *Listed in MCP Official Registry, PulseMCP, mcpservers.org, Glama.*
734
+ *MIT License — Synapse Arrows PTE. LTD.*