@bennys001/claude-code-memory 0.9.7

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.
Files changed (3) hide show
  1. package/README.md +198 -0
  2. package/dist/index.js +1242 -0
  3. package/package.json +53 -0
package/README.md ADDED
@@ -0,0 +1,198 @@
1
+ # claude-code-memory (ccm)
2
+
3
+ MCP server that gives Claude Code persistent memory via an Obsidian-compatible knowledge vault. Notes you write — gotchas, decisions, patterns, references — become queryable context across sessions without manual copy-pasting.
4
+
5
+ ## Quick Start
6
+
7
+ Requires [Bun](https://bun.sh/) and [Claude Code](https://docs.anthropic.com/en/docs/claude-code).
8
+
9
+ ```bash
10
+ bunx @bennys001/claude-code-memory --init
11
+ ```
12
+
13
+ This scaffolds the vault at `~/.ccm/knowledge-base/`, registers it with Obsidian (if installed), and adds the MCP server to Claude Code.
14
+
15
+ ### Manual setup
16
+
17
+ If `--init` can't reach the `claude` CLI, register manually:
18
+
19
+ ```bash
20
+ claude mcp add --transport stdio --scope user ccm -- bunx @bennys001/claude-code-memory --stdio
21
+ ```
22
+
23
+ ## MCP Tools
24
+
25
+ ### `research`
26
+
27
+ Batched search+read in one call. Finds matching notes by keyword and returns the results table plus full note content.
28
+
29
+ | Param | Type | Required | Description |
30
+ |-------------|----------|----------|-----------------------------------------------------|
31
+ | `query` | string | Yes | Space-separated keywords |
32
+ | `types` | string[] | No | Filter by note type |
33
+ | `tags` | string[] | No | Filter by tag |
34
+ | `limit` | number | No | Max results (default 10) |
35
+ | `maxTokens` | number | No | Token budget — stops including bodies once exceeded |
36
+
37
+ ### `index`
38
+
39
+ Compressed markdown table of all vault notes (or filtered by project). Primary way Claude discovers available knowledge.
40
+
41
+ | Param | Type | Required | Description |
42
+ |-----------|--------|----------|------------------------------------------|
43
+ | `project` | string | No | Filter to notes tagged with this project |
44
+
45
+ ### `write`
46
+
47
+ Creates a new note with structured frontmatter. Create-only — rejects existing paths.
48
+
49
+ | Param | Type | Required | Description |
50
+ |------------|----------|----------|-------------------------------------------------|
51
+ | `path` | string | Yes | Relative path for new note |
52
+ | `type` | string | Yes | `gotcha`, `decision`, `pattern`, or `reference` |
53
+ | `title` | string | Yes | Note title (becomes H1) |
54
+ | `body` | string | Yes | Markdown body |
55
+ | `tags` | string[] | No | Searchable tags |
56
+ | `projects` | string[] | No | Project names |
57
+
58
+ ### `sync`
59
+
60
+ Generates/updates a `## Knowledge Index` section in a project's `CLAUDE.md`. Injects the index table so Claude sees relevant notes at conversation start without a tool call.
61
+
62
+ | Param | Type | Required | Description |
63
+ |-------------|--------|----------|-------------------------------------|
64
+ | `targetDir` | string | No | Project directory (defaults to CWD) |
65
+
66
+ ### `fetch-page`
67
+
68
+ Fetches a web page, extracts main content via Readability, converts to markdown. Returns a temp file path — read it, then `write` to vault.
69
+
70
+ | Param | Type | Required | Description |
71
+ |-------|--------|----------|--------------|
72
+ | `url` | string | Yes | URL to fetch |
73
+
74
+ ## Note Format
75
+
76
+ ```markdown
77
+ ---
78
+ type: gotcha
79
+ projects:
80
+ - my-next-app
81
+ tags:
82
+ - nextjs
83
+ - react
84
+ created: 2026-02-01
85
+ updated: 2026-02-15
86
+ ---
87
+
88
+ # Next.js fetch cache persists across requests
89
+
90
+ By default fetch() in Next.js App Router caches responses indefinitely.
91
+ Add { cache: 'no-store' } or use revalidate to avoid stale data...
92
+ ```
93
+
94
+ ### Note Types
95
+
96
+ | Type | Icon | Purpose |
97
+ |-------------|------|------------------------------------|
98
+ | `gotcha` | 🔴 | Pitfalls and common mistakes |
99
+ | `decision` | 🟤 | Architecture and tooling decisions |
100
+ | `pattern` | 🔵 | Reusable code patterns |
101
+ | `reference` | 🟢 | Cheatsheets and quick-reference |
102
+
103
+ ### Frontmatter Fields
104
+
105
+ | Field | Required | Description |
106
+ |------------|----------|---------------------------------------------------------|
107
+ | `type` | Yes | One of the 4 note types |
108
+ | `projects` | No | Project names (defaults to `[]`) |
109
+ | `tags` | No | Searchable tags (defaults to `[]`) |
110
+ | `created` | Yes | Creation date |
111
+ | `updated` | Yes | Last updated date |
112
+ | `title` | No | Overrides default title (first `#` heading or filename) |
113
+
114
+ ### Vault Structure
115
+
116
+ Organize however you like. The server finds all `.md` files recursively, ignoring hidden dirs and `node_modules`.
117
+
118
+ ```
119
+ ~/.ccm/knowledge-base/
120
+ gotchas/
121
+ nextjs-fetch-cache.md
122
+ decisions/
123
+ chose-app-router-over-pages.md
124
+ patterns/
125
+ react-compound-components.md
126
+ references/
127
+ tailwind-cheatsheet.md
128
+ ```
129
+
130
+ Invalid frontmatter notes are silently skipped.
131
+
132
+ ## Project Filtering
133
+
134
+ Drop a `.context.toml` in any project root:
135
+
136
+ ```toml
137
+ [project]
138
+ name = "my-next-app"
139
+
140
+ [filter]
141
+ tags = ["typescript", "react", "nextjs"]
142
+ types = ["gotcha", "pattern"]
143
+ exclude = ["drafts/*"]
144
+ ```
145
+
146
+ Applies to `index`, `research`, and `sync` automatically.
147
+
148
+ ## Use Cases
149
+
150
+ ### Capture mistakes as you hit them
151
+
152
+ > Write a gotcha note about Next.js fetch cache persisting across requests
153
+ > in production. Tag it with nextjs and react.
154
+
155
+ Next session, the gotcha surfaces via Knowledge Index — no re-explaining.
156
+
157
+ ### Preserve architecture decisions
158
+
159
+ > Write a decision note about why we chose App Router over Pages Router
160
+ > for my-next-app. Tag it with nextjs and architecture.
161
+
162
+ ### Build a personal reference library
163
+
164
+ > Write a reference note with common Tailwind responsive breakpoints
165
+ > and utility patterns.
166
+
167
+ ### Import web pages into vault
168
+
169
+ > Fetch https://nextjs.org/docs/app/api-reference/functions/revalidatePath
170
+ > and save it as a reference note
171
+
172
+ ### Scope notes to projects
173
+
174
+ Notes with no `projects` field are global — they sync to `~/.claude/CLAUDE.md`. Project-tagged notes sync to matching project `CLAUDE.md` files.
175
+
176
+ > Write a gotcha note about keeping CLAUDE.md under 200 lines.
177
+
178
+ > Write a pattern note about React Server Components data fetching,
179
+ > tag it with the my-next-app project.
180
+
181
+ ## Development
182
+
183
+ ```bash
184
+ git clone https://github.com/bennys001/claude-code-memory.git
185
+ cd claude-code-memory
186
+ bun install
187
+ bun test
188
+ ```
189
+
190
+ ## Tech Stack
191
+
192
+ - **Runtime:** Bun
193
+ - **Protocol:** [Model Context Protocol](https://modelcontextprotocol.io/) via `@modelcontextprotocol/sdk`
194
+ - **Frontmatter:** gray-matter
195
+ - **Tokens:** tiktoken (cl100k_base)
196
+ - **Validation:** Zod
197
+ - **Config:** smol-toml
198
+ - **Web extraction:** linkedom + Readability + Turndown