Skip to content

Commit 52d75d0

Browse files
authored
docs(readme): reposition as Claude/OpenCode compatibility layer (#2)
1 parent 459f9b0 commit 52d75d0

1 file changed

Lines changed: 81 additions & 153 deletions

File tree

README.md

Lines changed: 81 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,29 @@
11
<div align="center">
22

3-
# 🧠 opencode-claude-memory
3+
# Claude Code-compatible memory for OpenCode
44

5-
**A 1:1 replica of [Claude Code's memory system](https://github.com/anthropics/claude-code) for OpenCode**
5+
**Make OpenCode and Claude Code share the same memory — zero config, local-first, and no migration required.**
66

7-
*Ported from the original source — same paths, same format, same tools, same prompts. Zero drift.*
8-
9-
Claude Code writes memories → OpenCode reads them. OpenCode writes memories → Claude Code reads them.
7+
Claude Code writes memory → OpenCode reads it. OpenCode writes memory → Claude Code reads it.
108

119
[![npm version](https://img.shields.io/npm/v/opencode-claude-memory.svg?style=flat-square)](https://www.npmjs.com/package/opencode-claude-memory)
1210
[![npm downloads](https://img.shields.io/npm/dm/opencode-claude-memory.svg?style=flat-square)](https://www.npmjs.com/package/opencode-claude-memory)
1311
[![License](https://img.shields.io/npm/l/opencode-claude-memory.svg?style=flat-square)](https://github.com/kuitos/opencode-claude-memory/blob/main/LICENSE)
1412

15-
[Features](#-features)[Quick Start](#-quick-start)[How It Works](#-how-it-works)[Configuration](#%EF%B8%8F-configuration)[Tools Reference](#-tools-reference)
13+
[Quick Start](#-quick-start)[Why this exists](#-why-this-exists)[What makes this different](#-what-makes-this-different)[How it works](#-how-it-works)[Who this is for](#-who-this-is-for)[FAQ](#-faq)
1614

1715
</div>
1816

1917
---
2018

21-
## ✨ Features
22-
23-
<table>
24-
<tr>
25-
<td width="50%">
26-
27-
### 🔄 Claude Code Compatible
28-
Shares the exact same `~/.claude/projects/<project>/memory/` directory — bidirectional sync out of the box
29-
30-
</td>
31-
<td width="50%">
32-
33-
### 🛠️ 5 Memory Tools
34-
`memory_save`, `memory_delete`, `memory_list`, `memory_search`, `memory_read`
35-
36-
</td>
37-
</tr>
38-
<tr>
39-
<td width="50%">
40-
41-
### ⚡ Auto-Extraction
42-
Drop-in `opencode` wrapper that extracts memories in the background after each session
43-
44-
</td>
45-
<td width="50%">
46-
47-
### 💉 System Prompt Injection
48-
Existing memories are automatically injected into every conversation
49-
50-
</td>
51-
</tr>
52-
<tr>
53-
<td width="50%">
54-
55-
### 📁 4 Memory Types
56-
`user`, `feedback`, `project`, `reference` — same taxonomy as Claude Code
19+
## ✨ At a glance
5720

58-
</td>
59-
<td width="50%">
60-
61-
### 🌳 Git Worktree Aware
62-
Worktrees of the same repo share the same memory directory
63-
64-
</td>
65-
</tr>
66-
</table>
21+
- **Claude Code-compatible memory**
22+
Uses Claude Code’s existing memory paths, file format, and taxonomy.
23+
- **Zero config**
24+
Install + enable plugin, then keep using `opencode` as usual.
25+
- **Local-first, no migration**
26+
Memory stays as local Markdown files in the same directory Claude Code already uses.
6727

6828
## 🚀 Quick Start
6929

@@ -74,8 +34,8 @@ npm install -g opencode-claude-memory
7434
```
7535

7636
This installs:
77-
- The **plugin** memory tools + system prompt injection
78-
- An `opencode` **wrapper** auto-extracts memories after each session
37+
- the **plugin** (memory tools + system prompt injection)
38+
- an `opencode` **wrapper** (auto-extracts memories after each session)
7939

8040
### 2. Configure
8141

@@ -89,84 +49,89 @@ This installs:
8949
### 3. Use
9050

9151
```bash
92-
opencode # just use it as usual
52+
opencode
9353
```
9454

95-
The AI agent can now use memory tools:
55+
That’s it. Memory extraction runs in the background after each session.
9656

97-
- **"Remember that I prefer terse responses"** → saves a `feedback` memory
98-
- **"What do you remember about me?"** → reads from memory
99-
- **"Forget the memory about my role"** → deletes a memory
57+
## 💡 Why this exists
10058

101-
When you exit, memories are extracted in the background — zero blocking.
59+
If you use both Claude Code and OpenCode on the same repository, memory often ends up in separate silos.
10260

103-
<details>
104-
<summary>🗑️ Uninstall</summary>
61+
This project solves that by making OpenCode read and write memory in Claude Code’s existing structure, so your context carries over naturally between both tools.
10562

106-
```bash
107-
npm uninstall -g opencode-claude-memory
108-
```
63+
## 🧩 What makes this different
10964

110-
This removes the wrapper and the plugin. Your saved memories in `~/.claude/projects/` are **not** deleted.
65+
Most memory plugins introduce a new storage model or migration step.
11166

112-
</details>
67+
This one is a **compatibility layer**, not a new memory system:
11368

114-
## 💡 How It Works
69+
- same memory directory conventions as Claude Code
70+
- same Markdown + frontmatter format
71+
- same memory taxonomy (`user`, `feedback`, `project`, `reference`)
72+
- same project/worktree resolution behavior
11573

116-
```mermaid
117-
graph LR
118-
A[You run opencode] --> B[Wrapper finds real binary]
119-
B --> C[Runs opencode normally]
120-
C --> D[You exit]
121-
D --> E[Get latest session ID]
122-
E --> F[Fork session + extract memories]
123-
F --> G[Memories saved to ~/.claude/projects/]
124-
```
74+
The outcome: **shared context across Claude Code and OpenCode without maintaining two memory systems.**
75+
76+
## ⚙️ How it works
77+
78+
1. You run `opencode` (wrapper).
79+
2. Wrapper finds and launches the real OpenCode binary.
80+
3. You use OpenCode normally.
81+
4. After exit, memory extraction runs in the background.
82+
5. Memories are saved to Claude-compatible paths under `~/.claude/projects/`.
83+
84+
### Compatibility details
85+
86+
The implementation ports core logic from Claude Code for path hashing, git-root/worktree handling, memory format, and memory prompting behavior, so both tools can operate on the same files safely.
87+
88+
## 👥 Who this is for
89+
90+
- You use **both Claude Code and OpenCode**.
91+
- You want **one shared memory context** across both tools.
92+
- You prefer **file-based, local-first memory** you can inspect in Git/worktrees.
93+
- You don’t want migration overhead or lock-in.
12594

126-
The wrapper is a drop-in replacement that:
95+
## ❓ FAQ
12796

128-
1. Scans `PATH` to find the real `opencode` binary (skipping itself)
129-
2. Runs it with all your arguments
130-
3. After you exit, forks the session with a memory extraction prompt
131-
4. Extraction runs **in the background** — you're never blocked
97+
### Is this a new memory system?
13298

133-
### What "1:1 Replica" Means
99+
No. It is a compatibility layer that lets OpenCode use Claude Code-compatible memory layout and conventions.
134100

135-
Every core component is ported directly from [Claude Code's source](https://github.com/anthropics/claude-code):
101+
### Do I need to migrate existing memory?
136102

137-
| Component | Source |
138-
|---|---|
139-
| `sanitizePath()` + `djb2Hash()` | `utils/sessionStoragePortable.ts` |
140-
| `findGitRoot()` + worktree resolution | `utils/git.ts` |
141-
| Memory types & frontmatter format | `commands/memory.ts` |
142-
| System prompt (types, when to save/skip) | `commands/memory.ts` |
143-
| Extraction prompt (post-session) | Claude Code's memory extraction agent |
103+
No migration required. If you already have Claude Code memory files, OpenCode can work with them directly.
144104

145-
This ensures:
146-
- `~/.claude/projects/<sanitized>/memory/` paths are **byte-identical** to Claude Code's output
147-
- Git worktrees resolve to the same canonical root
148-
- Memory files are interchangeable — no migration needed
105+
### Where is data stored?
149106

150-
## ⚙️ Configuration
107+
In local files under Claude-style project memory directories (for example, under `~/.claude/projects/<project>/memory/`).
151108

152-
### Environment Variables
109+
### Why file-based memory?
153110

154-
| Variable | Default | Description |
155-
|---|---|---|
156-
| `OPENCODE_MEMORY_EXTRACT` | `1` | Set to `0` to disable auto-extraction |
157-
| `OPENCODE_MEMORY_FOREGROUND` | `0` | Set to `1` to run extraction in foreground (debugging) |
158-
| `OPENCODE_MEMORY_MODEL` | *(default)* | Override model for extraction |
159-
| `OPENCODE_MEMORY_AGENT` | *(default)* | Override agent for extraction |
111+
File-based memory is transparent, local-first, easy to inspect/diff/back up, and works naturally with existing developer workflows.
112+
113+
### Can I disable auto extraction?
114+
115+
Yes. Set `OPENCODE_MEMORY_EXTRACT=0`.
116+
117+
## 🔧 Configuration
118+
119+
### Environment variables
120+
121+
- `OPENCODE_MEMORY_EXTRACT` (default `1`): set `0` to disable auto-extraction
122+
- `OPENCODE_MEMORY_FOREGROUND` (default `0`): set `1` to run extraction in foreground
123+
- `OPENCODE_MEMORY_MODEL`: override model used for extraction
124+
- `OPENCODE_MEMORY_AGENT`: override agent used for extraction
160125

161126
### Logs
162127

163128
Extraction logs are written to `$TMPDIR/opencode-memory-logs/extract-*.log`.
164129

165-
### Concurrency Safety
130+
### Concurrency safety
166131

167-
A file lock prevents multiple extractions from running simultaneously on the same project. Stale locks (from crashed processes) are automatically cleaned up.
132+
A file lock prevents multiple extractions from running simultaneously on the same project. Stale locks are cleaned up automatically.
168133

169-
## 📝 Memory Format
134+
## 📝 Memory format
170135

171136
Each memory is a Markdown file with YAML frontmatter:
172137

@@ -183,56 +148,19 @@ Skip post-action summaries. User reads diffs directly.
183148
**How to apply:** Don't summarize changes at the end of responses.
184149
```
185150

186-
### Memory Types
187-
188-
| Type | Description |
189-
|---|---|
190-
| `user` | User's role, expertise, preferences |
191-
| `feedback` | Guidance on how to work (corrections and confirmations) |
192-
| `project` | Ongoing work context not derivable from code |
193-
| `reference` | Pointers to external resources |
194-
195-
<details>
196-
<summary>📄 Index file (MEMORY.md)</summary>
197-
198-
`MEMORY.md` is an auto-managed index (not content storage). Each entry is one line:
199-
200-
```markdown
201-
- [User prefers terse responses](feedback_terse_responses.md) — Skip summaries, user reads diffs
202-
- [User is a data scientist](user_role.md) — Focus on observability/logging context
203-
```
204-
205-
</details>
206-
207-
## 🔧 Tools Reference
208-
209-
### `memory_save`
210-
211-
Save or update a memory.
212-
213-
| Parameter | Type | Required | Description |
214-
|---|---|---|---|
215-
| `file_name` | string || File name slug (e.g., `user_role`) |
216-
| `name` | string || Short title |
217-
| `description` | string || One-line description for relevance matching |
218-
| `type` | enum || `user`, `feedback`, `project`, or `reference` |
219-
| `content` | string || Memory content |
220-
221-
### `memory_delete`
222-
223-
Delete a memory by file name.
224-
225-
### `memory_list`
226-
227-
List all memories with their metadata.
228-
229-
### `memory_search`
230-
231-
Search memories by keyword across name, description, and content.
151+
Supported memory types:
152+
- `user`
153+
- `feedback`
154+
- `project`
155+
- `reference`
232156

233-
### `memory_read`
157+
## 🔧 Tools reference
234158

235-
Read the full content of a specific memory file.
159+
- `memory_save`: save/update a memory
160+
- `memory_delete`: delete a memory by filename
161+
- `memory_list`: list memory metadata
162+
- `memory_search`: search by keyword
163+
- `memory_read`: read full memory content
236164

237165
## 📄 License
238166

0 commit comments

Comments
 (0)