mema-kit 1.0.1 → 1.0.2
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/docs/guide.md +328 -0
- package/package.json +2 -5
package/docs/guide.md
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
# mema-kit — Usage Guide
|
|
2
|
+
|
|
3
|
+
**A memory protocol kit for Claude Code skills.**
|
|
4
|
+
|
|
5
|
+
Install two skills. Get persistent, curated memory across every session. Build new skills that plug into the same memory system.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## How Memory Interacts with Claude Code's Context
|
|
10
|
+
|
|
11
|
+
Before diving in, it helps to understand **what's actually happening** when mema-kit "loads" and "saves" memory.
|
|
12
|
+
|
|
13
|
+
**There's no magic.** Claude Code has a **context window** — everything it "knows" during a conversation. mema-kit works **within** that context window, not outside it.
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
"Load memory" = Agent uses the Read tool to read .mema/ files
|
|
17
|
+
→ file contents enter the context window
|
|
18
|
+
|
|
19
|
+
"Save memory" = Agent uses the Write tool to write .mema/ files
|
|
20
|
+
→ knowledge persists on disk for the next session
|
|
21
|
+
|
|
22
|
+
"Decide what's = Agent reads the short index.md (~20 lines),
|
|
23
|
+
relevant" then chooses which files to Read based on your request
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Why This Matters
|
|
27
|
+
|
|
28
|
+
**Without mema-kit:** Every new session starts blank. The agent knows nothing about your project. You re-explain everything, or the agent explores your entire codebase (slow, expensive, loads irrelevant files into context).
|
|
29
|
+
|
|
30
|
+
**With mema-kit:** The agent reads `index.md` (small file), instantly knows your architecture, recent decisions, and active tasks. It reads only the 2-3 files relevant to your current task — then gets to work with the right context already loaded.
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
Without kit: With kit:
|
|
34
|
+
┌──────────────────────┐ ┌──────────────────────┐
|
|
35
|
+
│ Context Window │ │ Context Window │
|
|
36
|
+
│ │ │ │
|
|
37
|
+
│ CLAUDE.md │ │ CLAUDE.md │
|
|
38
|
+
│ Your message │ │ SKILL.md instructions │
|
|
39
|
+
│ ...nothing else. │ │ Your message │
|
|
40
|
+
│ │ │ index.md (auto-read) │
|
|
41
|
+
│ Agent must explore │ │ architecture.md │
|
|
42
|
+
│ entire codebase │ │ relevant decision.md │
|
|
43
|
+
│ from scratch. │ │ │
|
|
44
|
+
│ ❌ Slow, expensive │ │ Agent starts work │
|
|
45
|
+
│ ❌ Loads irrelevant │ │ with RIGHT context. │
|
|
46
|
+
│ files into context │ │ ✓ Fast, token-lean │
|
|
47
|
+
└──────────────────────┘ └──────────────────────┘
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Think of it like a developer's notebook.** The notebook doesn't give you a bigger brain — it gives you the right information faster. mema-kit doesn't expand Claude Code's context window. It **uses the context window more efficiently** by loading curated, relevant knowledge instead of raw codebase exploration.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Quick Setup
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# 1. Install mema-kit skills into your project
|
|
58
|
+
npx mema-kit
|
|
59
|
+
|
|
60
|
+
# 2. Open your project in Claude Code
|
|
61
|
+
cd your-project
|
|
62
|
+
claude
|
|
63
|
+
|
|
64
|
+
# 3. Bootstrap memory (scans project, creates .mema/, populates initial knowledge)
|
|
65
|
+
/onboard
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
After setup, your project looks like this:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
your-project/
|
|
72
|
+
├── .claude/skills/ # mema-kit skills (2 commands) — committed to git
|
|
73
|
+
│ ├── _memory-protocol.md # Shared curation rules
|
|
74
|
+
│ ├── onboard/SKILL.md # /onboard — bootstrap memory
|
|
75
|
+
│ └── create-skill/SKILL.md # /create-skill — generate new skills
|
|
76
|
+
├── .mema/ # Memory system (auto-managed) — gitignored
|
|
77
|
+
│ ├── _templates/ # Templates for memory files
|
|
78
|
+
│ ├── index.md # Memory map — agent reads this first
|
|
79
|
+
│ ├── project-memory/ # Tech stack, requirements, decisions
|
|
80
|
+
│ ├── task-memory/ # Per-task context, plans, decisions
|
|
81
|
+
│ ├── agent-memory/ # Lessons learned, reusable patterns
|
|
82
|
+
│ └── archive/ # Completed task memories
|
|
83
|
+
├── .gitignore # .mema/ gitignored by /onboard
|
|
84
|
+
└── CLAUDE.md # Memory system conventions
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Using /onboard
|
|
90
|
+
|
|
91
|
+
Run once per project. `/onboard` doesn't just create empty directories — it actively scans your project and populates memory with real content.
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
You: /onboard
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**What happens:**
|
|
98
|
+
1. Creates `.mema/` directory with all subdirectories and templates
|
|
99
|
+
2. Scans your project: reads package.json, README, directory structure, and representative source files
|
|
100
|
+
3. Populates `architecture.md` with your actual tech stack, project structure, and build commands
|
|
101
|
+
4. Populates `requirements.md` with discovered project purpose and constraints
|
|
102
|
+
5. Creates starter `lessons.md` and `patterns.md` (with any gotchas found during scanning)
|
|
103
|
+
6. Builds `index.md` pointing to all populated files
|
|
104
|
+
7. Adds memory system section to CLAUDE.md
|
|
105
|
+
8. Adds `.mema/` to `.gitignore`
|
|
106
|
+
|
|
107
|
+
**Example output:**
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
mema-kit initialized! Here's what was set up:
|
|
111
|
+
|
|
112
|
+
✓ .mema/ directory structure (memory system)
|
|
113
|
+
✓ Memory templates in .mema/_templates/
|
|
114
|
+
✓ CLAUDE.md updated with memory system conventions
|
|
115
|
+
✓ .gitignore updated to exclude .mema/
|
|
116
|
+
|
|
117
|
+
Project scan results:
|
|
118
|
+
- TypeScript 5.x + Fastify 4.x + PostgreSQL via Drizzle ORM
|
|
119
|
+
- REST API with controller → service → repository layers
|
|
120
|
+
- 4 source directories mapped (src/, tests/, drizzle/, config/)
|
|
121
|
+
- Vitest for testing, pnpm for package management
|
|
122
|
+
|
|
123
|
+
Memory populated:
|
|
124
|
+
- architecture.md — Node.js + Fastify + PostgreSQL + Drizzle stack
|
|
125
|
+
- requirements.md — Task management REST API with JWT auth
|
|
126
|
+
- lessons.md — 0 initial lessons
|
|
127
|
+
- patterns.md — 0 initial patterns
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Idempotent — safe to re-run. On subsequent runs, verifies and repairs rather than overwriting.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Using /create-skill
|
|
135
|
+
|
|
136
|
+
Generate a new memory-aware skill for your project.
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
You: /create-skill
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The agent asks 2-3 quick questions, then generates a complete SKILL.md with the right memory lifecycle.
|
|
143
|
+
|
|
144
|
+
### Worked Example: Creating a /review Skill
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
You: /create-skill
|
|
148
|
+
|
|
149
|
+
Agent: What should this skill be called?
|
|
150
|
+
You: review
|
|
151
|
+
|
|
152
|
+
Agent: What does /review do?
|
|
153
|
+
You: Reviews code changes for quality, consistency with project patterns, and potential issues.
|
|
154
|
+
|
|
155
|
+
Agent: Memory needs — should /review read memory, write memory, or both?
|
|
156
|
+
Default is both (read architecture + patterns, save new lessons).
|
|
157
|
+
You: both is good
|
|
158
|
+
|
|
159
|
+
Agent: Complexity level?
|
|
160
|
+
- Simple (3 phases) — read-only, no memory writes
|
|
161
|
+
- Standard (4 phases) — read + write memory [default]
|
|
162
|
+
- Advanced (4 phases + task management)
|
|
163
|
+
You: standard
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Result:** `.claude/skills/review/SKILL.md` is created with:
|
|
167
|
+
|
|
168
|
+
```markdown
|
|
169
|
+
---
|
|
170
|
+
description: Reviews code changes for quality, consistency with project patterns, and potential issues.
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
# /review — Code Review
|
|
174
|
+
|
|
175
|
+
You are executing the /review skill. Follow these steps carefully.
|
|
176
|
+
|
|
177
|
+
## Phase 1: AUTO-LOAD
|
|
178
|
+
1. Read `.mema/index.md` to understand current project state
|
|
179
|
+
2. If `index.md` is missing or empty, run the Rebuild Procedure from `_memory-protocol.md`
|
|
180
|
+
3. Based on the user's request, identify and read relevant memory files
|
|
181
|
+
4. Read only what's needed — don't load everything
|
|
182
|
+
|
|
183
|
+
**Relevant memory for this skill:**
|
|
184
|
+
- `project-memory/architecture.md` — for technical context
|
|
185
|
+
- `project-memory/decisions/` — for past decisions related to this work
|
|
186
|
+
- `agent-memory/lessons.md` — for mistakes to avoid
|
|
187
|
+
- `agent-memory/patterns.md` — for reusable approaches
|
|
188
|
+
|
|
189
|
+
## Phase 2: WORK
|
|
190
|
+
[Review logic — check code against architecture, patterns, lessons...]
|
|
191
|
+
|
|
192
|
+
## Phase 3: AUTO-SAVE & CURATE
|
|
193
|
+
[Save any new lessons or patterns discovered during review...]
|
|
194
|
+
|
|
195
|
+
## Phase 4: AUTO-INDEX
|
|
196
|
+
[Update index.md to reflect changes...]
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Now you can use it:
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
You: /review check the auth middleware changes
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
The agent loads your architecture, past decisions, and known patterns — then reviews the code with that full context.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## The Memory Protocol in Depth
|
|
210
|
+
|
|
211
|
+
Every memory-aware skill follows four phases. This is defined in `_memory-protocol.md` and shared across all skills.
|
|
212
|
+
|
|
213
|
+
### Phase 1: AUTO-LOAD
|
|
214
|
+
|
|
215
|
+
1. Read `.mema/index.md` — the pointer map to all memory files
|
|
216
|
+
2. Scan each entry's one-line summary for relevance to the current task
|
|
217
|
+
3. Read only the relevant files into context
|
|
218
|
+
4. If `index.md` is missing, rebuild it from the `.mema/` directory structure
|
|
219
|
+
|
|
220
|
+
**Rule:** When in doubt about relevance, load it. When clearly unrelated, skip it.
|
|
221
|
+
|
|
222
|
+
### Phase 2: WORK
|
|
223
|
+
|
|
224
|
+
Execute the skill's core purpose with loaded context. This phase varies per skill.
|
|
225
|
+
|
|
226
|
+
### Phase 3: AUTO-SAVE & CURATE
|
|
227
|
+
|
|
228
|
+
For every piece of knowledge produced, decide one of four actions:
|
|
229
|
+
|
|
230
|
+
| Action | When to Use |
|
|
231
|
+
|--------|------------|
|
|
232
|
+
| **ADD** | New knowledge that doesn't exist yet (new decision, finding, lesson, pattern) |
|
|
233
|
+
| **UPDATE** | Existing knowledge that has changed (refined reasoning, adjusted plan, new example) |
|
|
234
|
+
| **DELETE** | Knowledge that is wrong, superseded, or irrelevant (dead-end exploration, duplicate info) |
|
|
235
|
+
| **NOOP** | Still accurate and relevant — leave unchanged (most files, most of the time) |
|
|
236
|
+
|
|
237
|
+
#### Per-File Curation Rules
|
|
238
|
+
|
|
239
|
+
- **decision.md** — Conservative. Rarely delete. Even reversed decisions teach why something didn't work.
|
|
240
|
+
- **context.md** — Aggressive. Prune dead-end explorations. Consolidate overlapping findings.
|
|
241
|
+
- **plan.md** — Replace. Keep the final version only. Update during implementation.
|
|
242
|
+
- **lessons.md / patterns.md** — Consolidation. Merge similar entries. Add examples to existing ones.
|
|
243
|
+
|
|
244
|
+
### Phase 4: AUTO-INDEX
|
|
245
|
+
|
|
246
|
+
Update `.mema/index.md` to reflect all changes. This is mandatory — never skip it.
|
|
247
|
+
|
|
248
|
+
1. Add entries for new files
|
|
249
|
+
2. Update summaries for modified files
|
|
250
|
+
3. Remove entries for deleted files
|
|
251
|
+
4. Update the `**Updated:**` date
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Memory Structure Reference
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
.mema/
|
|
259
|
+
├── _templates/ # File templates (copied by /onboard)
|
|
260
|
+
│ ├── decision.md, context.md, plan.md, lessons.md, patterns.md, status.md
|
|
261
|
+
│
|
|
262
|
+
├── index.md # Pointer map — read this first
|
|
263
|
+
│
|
|
264
|
+
├── project-memory/ # Project-wide knowledge
|
|
265
|
+
│ ├── architecture.md # Tech stack, structure, patterns
|
|
266
|
+
│ ├── requirements.md # Purpose, constraints, requirements
|
|
267
|
+
│ └── decisions/ # Individual decision records
|
|
268
|
+
│ ├── 2026-02-23-tech-stack.md
|
|
269
|
+
│ └── 2026-02-23-auth-jwt.md
|
|
270
|
+
│
|
|
271
|
+
├── task-memory/ # Per-task working memory
|
|
272
|
+
│ └── api-setup/
|
|
273
|
+
│ ├── context.md # Research findings
|
|
274
|
+
│ ├── plan.md # Implementation plan
|
|
275
|
+
│ └── status.md # Progress tracking
|
|
276
|
+
│
|
|
277
|
+
├── agent-memory/ # Agent-learned knowledge
|
|
278
|
+
│ ├── lessons.md # Mistakes and surprises
|
|
279
|
+
│ └── patterns.md # Reusable approaches
|
|
280
|
+
│
|
|
281
|
+
└── archive/ # Completed tasks (preserved for reference)
|
|
282
|
+
└── api-setup/
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Metadata Format
|
|
286
|
+
|
|
287
|
+
Every memory file includes in-body metadata (not YAML frontmatter):
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
**Status:** active | **Updated:** 2026-02-23
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Status values: `active` (current), `complete` (finished but useful), `archived` (moved to archive/).
|
|
294
|
+
|
|
295
|
+
### Index Format
|
|
296
|
+
|
|
297
|
+
```markdown
|
|
298
|
+
# Memory Index
|
|
299
|
+
|
|
300
|
+
**Updated:** 2026-02-23
|
|
301
|
+
|
|
302
|
+
## Active Tasks
|
|
303
|
+
- `task-memory/api-setup/` — Setting up REST API with Fastify (plan ready, implementing)
|
|
304
|
+
|
|
305
|
+
## Project Knowledge
|
|
306
|
+
- `project-memory/architecture.md` — Node.js + Fastify + PostgreSQL + Drizzle stack
|
|
307
|
+
- `project-memory/requirements.md` — Core requirements and constraints
|
|
308
|
+
|
|
309
|
+
## Recent Decisions
|
|
310
|
+
- `project-memory/decisions/2026-02-23-tech-stack.md` — Chose Fastify + PostgreSQL + Drizzle
|
|
311
|
+
|
|
312
|
+
## Agent Lessons
|
|
313
|
+
- `agent-memory/lessons.md` — 3 lessons recorded
|
|
314
|
+
- `agent-memory/patterns.md` — 2 patterns recorded
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
The index is a **rebuildable cache** — convenient but never the only source of truth. The actual files in `.mema/` are the source of truth.
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## Tips
|
|
322
|
+
|
|
323
|
+
- **Memory is just markdown.** Open any `.mema/` file to see what the agent knows. Edit directly if something's wrong.
|
|
324
|
+
- **index.md is self-healing.** If it gets out of sync, the next skill will rebuild it from the `.mema/` directory structure.
|
|
325
|
+
- **Decisions include "why."** Every decision file explains the reasoning — so future-you (or future-agent) understands the context, not just the choice.
|
|
326
|
+
- **`.mema/` is gitignored by default.** It's your local agent workspace. To share project decisions with your team, uncomment `!.mema/project-memory/` in `.gitignore`.
|
|
327
|
+
- **Any skill can use the protocol.** The memory protocol isn't limited to the two built-in skills. Use `/create-skill` to generate new ones, or manually follow the 4-phase lifecycle in any SKILL.md.
|
|
328
|
+
- **Curate, don't hoard.** The value of memory is in its signal-to-noise ratio. Aggressive pruning of dead-end explorations and consolidation of similar lessons keeps memory useful.
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mema-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Memory protocol kit for Claude Code skills",
|
|
5
5
|
"bin": {
|
|
6
6
|
"mema-kit": "bin/cli.js"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
|
+
"docs/",
|
|
9
10
|
"bin/",
|
|
10
11
|
"skills/",
|
|
11
12
|
"templates/"
|
|
@@ -18,10 +19,6 @@
|
|
|
18
19
|
"agent-memory"
|
|
19
20
|
],
|
|
20
21
|
"license": "MIT",
|
|
21
|
-
"repository": {
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/simonv15/mema-kit.git"
|
|
24
|
-
},
|
|
25
22
|
"engines": {
|
|
26
23
|
"node": ">=16.7.0"
|
|
27
24
|
}
|