decision-memory 0.1.0 → 0.1.1
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/README.md +174 -0
- package/package.json +6 -2
package/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# decision-memory
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/decision-memory)
|
|
4
|
+
|
|
5
|
+
**Automatic decision logging for Claude Code.** Every architectural choice your AI assistant makes gets stored in a compact, token-efficient [TOON](https://github.com/toon-format/toon) file — and retrieved automatically when context is lost.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
decisions[3]{id,ts,topic,decision,rationale,impact,tags}:
|
|
9
|
+
D001,2026-02-10T14:32Z,auth,"Use JWT RS256","HS256 needs shared secret across services",high,auth|security|jwt
|
|
10
|
+
D002,2026-02-11T09:15Z,database,"Use Postgres","Need concurrent writes; SQLite WAL insufficient",high,database|postgres
|
|
11
|
+
D003,2026-02-12T16:44Z,testing,"Use Vitest","ESM-native project; Jest ESM support is experimental",low,testing|vitest
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Why decision-memory?
|
|
15
|
+
|
|
16
|
+
- **Context loss is real.** Long sessions and session restarts mean Claude forgets why `JWT RS256` was chosen over `HS256` three days ago.
|
|
17
|
+
- **Re-discussing decided things wastes time.** Every re-debate costs tokens and slows development.
|
|
18
|
+
- **Decisions deserve a home.** Like `CHANGELOG.md` for architecture.
|
|
19
|
+
|
|
20
|
+
## How it works
|
|
21
|
+
|
|
22
|
+
1. **Auto-trigger**: A Claude Code hook fires after every `Write`/`Edit` operation, nudging Claude to log decisions automatically.
|
|
23
|
+
2. **Session start**: Claude calls `get_context_summary` to orient itself (~200 tokens).
|
|
24
|
+
3. **Before deciding**: Claude calls `search_decisions` to check prior decisions (~50-80 tokens/result).
|
|
25
|
+
4. **After deciding**: Claude calls `log_decision` to record the choice.
|
|
26
|
+
|
|
27
|
+
No manual intervention needed.
|
|
28
|
+
|
|
29
|
+
## Quickstart (Claude Code)
|
|
30
|
+
|
|
31
|
+
### 1. Copy integration files to your project
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx degit baadir/decisionmemo/integrations/claude-code . --force
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This pulls `.mcp.json`, `CLAUDE.md` and `.claude/` directly into your project root — no cloning, no manual copying.
|
|
38
|
+
|
|
39
|
+
### 2. Initialize DECISIONS.toon
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx decision-memory init
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 3. Start Claude Code
|
|
46
|
+
|
|
47
|
+
Claude will automatically:
|
|
48
|
+
- Call `get_context_summary` at session start
|
|
49
|
+
- Be nudged to call `log_decision` after file modifications
|
|
50
|
+
- Call `search_decisions` before making architectural choices
|
|
51
|
+
|
|
52
|
+
## MCP Server
|
|
53
|
+
|
|
54
|
+
The MCP server is the primary integration method. It exposes 4 tools:
|
|
55
|
+
|
|
56
|
+
| Tool | Description |
|
|
57
|
+
|---|---|
|
|
58
|
+
| `log_decision` | Log an architectural decision |
|
|
59
|
+
| `search_decisions` | Search past decisions by keyword/tag |
|
|
60
|
+
| `get_context_summary` | Get compact session-start summary |
|
|
61
|
+
| `update_decision` | Mark a prior decision as superseded |
|
|
62
|
+
|
|
63
|
+
## CLI
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Initialize
|
|
67
|
+
npx decision-memory init
|
|
68
|
+
|
|
69
|
+
# Log a decision
|
|
70
|
+
npx decision-memory log \
|
|
71
|
+
--topic auth \
|
|
72
|
+
--decision "Use JWT RS256" \
|
|
73
|
+
--rationale "HS256 requires shared secret across services" \
|
|
74
|
+
--impact high \
|
|
75
|
+
--tags auth,security,jwt
|
|
76
|
+
|
|
77
|
+
# Search
|
|
78
|
+
npx decision-memory search --keywords jwt
|
|
79
|
+
npx decision-memory search --tags auth,security
|
|
80
|
+
npx decision-memory search --impact high
|
|
81
|
+
|
|
82
|
+
# Summary
|
|
83
|
+
npx decision-memory summary
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Why TOON format?
|
|
87
|
+
|
|
88
|
+
TOON (Token-Oriented Object Notation) uses **39% fewer tokens than JSON** for the same structured data. For a project with 50 decisions:
|
|
89
|
+
|
|
90
|
+
- JSON: ~4,250 tokens
|
|
91
|
+
- TOON: ~2,600 tokens
|
|
92
|
+
- Savings: **1,650 tokens per search** that's not consumed
|
|
93
|
+
|
|
94
|
+
## DECISIONS.toon schema
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
# decision-memory v1
|
|
98
|
+
project: <name>
|
|
99
|
+
created: YYYY-MM-DD
|
|
100
|
+
updated: YYYY-MM-DD
|
|
101
|
+
|
|
102
|
+
decisions[N]{id,ts,topic,decision,rationale,impact,tags}:
|
|
103
|
+
D001,YYYY-MM-DDTHH:MMZ,topic,"Decision text","Rationale text",impact,tag1|tag2
|
|
104
|
+
|
|
105
|
+
summary{total,high_impact,last_updated,top_topics}:
|
|
106
|
+
N,N,YYYY-MM-DD,topic1|topic2
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Fields:**
|
|
110
|
+
- `impact`: `low` | `medium` | `high` | `critical`
|
|
111
|
+
- `tags`: pipe-delimited (`auth|jwt|security`)
|
|
112
|
+
- Fields with commas are quoted: `"Use JWT, not sessions"`
|
|
113
|
+
|
|
114
|
+
## File location
|
|
115
|
+
|
|
116
|
+
Priority order:
|
|
117
|
+
1. `DECISION_MEMORY_FILE` environment variable
|
|
118
|
+
2. `./DECISIONS.toon` in current working directory ← **recommended**
|
|
119
|
+
3. `~/.decision-memory/global.toon` (fallback)
|
|
120
|
+
|
|
121
|
+
Commit `DECISIONS.toon` to git — it's a project artifact like `README.md`.
|
|
122
|
+
|
|
123
|
+
## Package
|
|
124
|
+
|
|
125
|
+
Single npm package — CLI and MCP server in one:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
npm install -g decision-memory # CLI
|
|
129
|
+
npx decision-memory init # run without installing
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The MCP server binary (`decision-memory-mcp`) is included in the same package and started automatically via `.mcp.json`.
|
|
133
|
+
|
|
134
|
+
## How does this compare to Claude Code's MEMORY.md?
|
|
135
|
+
|
|
136
|
+
Claude Code has three places where context lives. They don't overlap — they complement each other:
|
|
137
|
+
|
|
138
|
+
| | `MEMORY.md` | `CLAUDE.md` | `DECISIONS.toon` |
|
|
139
|
+
|---|---|---|---|
|
|
140
|
+
| **Written by** | Claude (auto-generated) | You (human) | Claude (via MCP tool) |
|
|
141
|
+
| **Contains** | Discoveries, patterns, debugging notes | Behavioral rules & instructions | Architectural decisions with rationale |
|
|
142
|
+
| **Searchable** | No | No | Yes — keyword + tag search |
|
|
143
|
+
| **Location** | `~/.claude/projects/.../memory/` | Project root | Project root |
|
|
144
|
+
| **Format** | Markdown | Markdown | TOON (39% fewer tokens) |
|
|
145
|
+
|
|
146
|
+
**In plain terms:**
|
|
147
|
+
- MEMORY.md is Claude's personal notebook ("I noticed this codebase uses X pattern")
|
|
148
|
+
- CLAUDE.md is your instruction manual for Claude ("always call get_context_summary at start")
|
|
149
|
+
- DECISIONS.toon is the project's architecture log ("we chose Postgres over SQLite because...")
|
|
150
|
+
|
|
151
|
+
All three can be active at once. decision-memory adds the one thing neither MEMORY.md nor CLAUDE.md provides: **searchable, structured, rationale-rich decision history**.
|
|
152
|
+
|
|
153
|
+
## Compatibility
|
|
154
|
+
|
|
155
|
+
decision-memory is compatible with any other MCP server or Claude Code tool. It only reads and writes `DECISIONS.toon` — it does not interfere with other tools.
|
|
156
|
+
|
|
157
|
+
**Execution order when Claude Code starts:**
|
|
158
|
+
1. `.mcp.json` is read → all MCP servers start (including decision-memory)
|
|
159
|
+
2. `CLAUDE.md` is added to the system prompt
|
|
160
|
+
3. Session begins — Claude calls `get_context_summary` per instructions
|
|
161
|
+
|
|
162
|
+
Other MCP tools (context-mode, etc.) run in parallel with decision-memory. There is no conflict because each MCP server handles its own tools independently.
|
|
163
|
+
|
|
164
|
+
## Roadmap
|
|
165
|
+
|
|
166
|
+
- [x] Claude Code (MCP + hooks)
|
|
167
|
+
- [ ] Cursor (`.cursor/mcp.json`)
|
|
168
|
+
- [ ] VS Code + Cline (`.vscode/mcp.json`)
|
|
169
|
+
- [ ] Opencode (`opencode.json`)
|
|
170
|
+
- [ ] Semantic search (embeddings, opt-in)
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "decision-memory",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Claude Code için karar hafızası — CLI ve MCP server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"decision-memory": "./dist/index.js",
|
|
8
8
|
"decision-memory-mcp": "./dist/mcp.js"
|
|
9
9
|
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prepack": "node -e \"require('fs').copyFileSync('../../README.md', 'README.md')\""
|
|
12
|
+
},
|
|
10
13
|
"files": [
|
|
11
|
-
"dist"
|
|
14
|
+
"dist",
|
|
15
|
+
"README.md"
|
|
12
16
|
],
|
|
13
17
|
"engines": {
|
|
14
18
|
"node": ">=20.0.0"
|