Tools
Sh4d0wDB
Kill your Markdown files. 11-byte agent memory system. PostgreSQL, SQLite, MySQL.
README
<div align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/banner-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="assets/banner-light.svg">
<img alt="ShadowDB" src="assets/banner-dark.svg" width="100%">
</picture>
<br/>
**Your agent's memory shouldn't be a markdown file.**
<br/>ShadowDB is an easy-to-install memory plugin for [OpenClaw](https://github.com/openclaw/openclaw) that replaces flat files with a real database โ semantic search, fuzzy matching, and a memory that gets smarter over time instead of bloating.
<br/><sub>Built by an agent, for agents.</sub>
[](#install)
[](LICENSE)
[](#install)
[](#install)
[](#install)
[](#contributing)
<br/>
[](#performance-shadowdb-vs-openclaw-builtin-vs-qmd)
[](#performance-shadowdb-vs-openclaw-builtin-vs-qmd)
[](#performance-shadowdb-vs-openclaw-builtin-vs-qmd)
[-10b981?style=flat-square)](#performance-shadowdb-vs-openclaw-builtin-vs-qmd)
[](#performance-shadowdb-vs-openclaw-builtin-vs-qmd)
</div>
---
## What does it do?
Gives your agent a persistent memory it can search, write, update, and delete โ instead of flat markdown files that get shoved into every prompt. Works with Postgres (recommended), SQLite, or MySQL.
**Why this matters:** Most agent frameworks inject your agent's entire identity โ personality, rules, preferences, everything โ into every single API call. That's ~9,000 bytes of static text the model already read, re-sent every turn, wasting tokens and pushing out conversation history. ShadowDB injects identity once on the first turn, then gets out of the way โ turns 2+ cost zero bytes. The agent searches for what it needs, when it needs it. Everything else stays in the database, not the prompt.
| Tool | Does |
|------|------|
| `memory_search` | Find relevant records (semantic + keyword + fuzzy) |
| `memory_get` | Read a full record |
| `memory_write` | Save something new |
| `memory_update` | Edit an existing record |
| `memory_delete` | Soft-delete (reversible for 30 days) |
| `memory_undelete` | Undo a delete |
---
## Install
```bash
curl -fsSL https://raw.githubusercontent.com/jamesdwilson/Sh4d0wDB/main/setup.sh | bash
```
That's it. The script downloads only the files you need, sets up the database, installs dependencies, wires the plugin into OpenClaw, and restarts the gateway. Run the same command again to update.
Or just tell your agent โ it can run the command itself. The script auto-detects non-interactive mode and defaults to SQLite with zero prompts. Pass `--backend postgres` or `--backend mysql` to override.
### Platform compatibility
ShadowDB runs everywhere OpenClaw runs. The install script is plain bash โ no exotic tooling.
| Platform | Works? | Notes |
|----------|--------|-------|
| **macOS** | โ
| Primary development platform. Just works. |
| **Linux** | โ
| Servers, Raspberry Pi, VPS โ all good. |
| **Windows (WSL2)** | โ
| OpenClaw requires WSL2 on Windows. Our bash script runs natively inside WSL. Same `~/.openclaw/` path as Linux. |
### What gets installed (and where)
ShadowDB is just TypeScript files dropped into your OpenClaw plugins directory. No global installs, no system-level changes. Here's exactly what happens:
1. **Plugin files** โ `~/.openclaw/plugins/memory-shadowdb/` โ the `.ts` source files, plugin manifest, and `package.json`.
2. **Core dependencies** โ `npm install` inside the plugin directory. Two packages: `@sinclair/typebox` (config schema) and `openai` (embedding API client). These live in the plugin's own `node_modules/`, not globally.
3. **Your database driver** โ only the one you picked:
- Postgres โ `pg`
- SQLite โ `better-sqlite3` + `sqlite-vec`
- MySQL โ `mysql2`
Also installed inside the plugin's `node_modules/`. Nothing global.
4. **System dependencies** โ the setup script checks for these and tells you if anything's missing:
- A database server (Postgres or MySQL) โ unless you chose SQLite, which runs in-process with no server.
- Ollama (optional) โ for local embeddings. Semantic search works without it if you configure an API-based embedding provider.
- Node.js โ but OpenClaw already requires this, so you have it.
Everything lives inside `~/.openclaw/plugins/memory-shadowdb/`. Nothing is installed globally. Nothing touches your system paths. Uninstall removes the directory and you're clean.
---
## Want to put it back the way it was?
Breathe. Nothing was lost.
ShadowDB doesn't delete, overwrite, or modify any of your original files. Here's exactly what the install touched โ and how to undo every bit of it:
<details>
<summary>What install changed (and what it didn't)</summary>
### What install did
| What | Where | Reversible? |
|------|-------|-------------|
| Downloaded plugin files | `~/.openclaw/plugins/memory-shadowdb/` | โ
Moved to trash on uninstall |
| Added a config entry | `plugins.entries.memory-shadowdb` in `openclaw.json` | โ
Removed on uninstall |
| Set the memory slot | `plugins.slots.memory` in `openclaw.json` | โ
Cleared on uninstall |
| **Backed up your config first** | `~/OpenClaw-Before-ShadowDB-[install date]/openclaw.json` | Your original config, untouched |
| Created a database | `shadow` (Postgres/MySQL) or `shadow.db` (SQLite) | โ
Kept on uninstall (your data is yours) |
| Imported workspace `.md` files as memories | Rows in the `memories` table | โ
Kept on uninstall โ originals untouched |
| Imported `PRIMER.md` / `ALWAYS.md` | Rows in the `primer` table | โ
Kept on uninstall โ originals untouched |
### What install did NOT do
- โ Did not delete or rename any `.md` files
- โ Did not modify `MEMORY.md`, `SOUL.md`, `IDENTITY.md`, or any other workspace file
- โ Did not change your agent's system prompt
- โ Did not touch any other plugin's config
Your original markdown files are still exactly where you left them.
</details>
### Uninstall
One command. Same script, different flag:
```bash
curl -fsSL https://raw.githubusercontent.com/jamesdwilson/Sh4d0wDB/main/setup.sh | bash -s -- --uninstall
```
This moves the plugin files to your system trash (macOS Trash, GNOME Trash, or a recovery folder if no trash is available), removes the config entry, restarts OpenClaw, and you're back to your original setup. Your database and all its records are kept. If you reinstall later, everything will still be there.
Your original `openclaw.json` is saved at `~/OpenClaw-Before-ShadowDB-[install date]/openclaw.json` โ easy to find, impossible to miss.
> **Design principle:** ShadowDB will never delete a file, drop a database, or remove anything that can't be put back. Not because we forgot โ because we specifically chose not to. Even uninstall moves files to your system trash โ not `rm -rf`. Your data stays unless *you* empty the trash.
Or tell your agent โ same as install, it knows what to do.
---
## What about old records?
Records don't expire. A phone number from 3 months ago is still a phone number. A project status from 3 months ago probably isn't current โ but that's a judgment call, not something the database should guess at.
ShadowDB gives the agent two pieces of information and lets it decide:
- **Age in snippets** โ search results show `[topic] | 5d ago` instead of a raw timestamp. The agent reads "5 days ago" the same way you would. This matters because models are bad at date math โ ask one to compute "how many days between Feb 10 and Feb 15" and it'll confidently say 3 or 6. Pre-computing the age removes that failure mode.
- **Recency as a tiebreaker** โ newer records get a small ranking boost (weight: `0.15`), but a relevant old record still beats a vaguely relevant new one.
Deletes are always reversible for 30 days. After that, automatic cleanup kicks in โ but even then, expired records are exported to a JSON file and moved to your system trash before being removed from the database. There is no hard-delete tool โ the agent can never permanently destroy data. Only time can, and even time leaves a receipt.
<details>
<summary>Why not something more complex?</summary>
| Idea | Why we skipped it |
|------|-------------------|
| Staleness markers | `created_at` already tells you how old it is |
| "Superseded by" pointers | Just delete the old one and write the new one |
| Access frequency tracking | Creates feedback loops; popular โ good |
| Auto-contradiction detection | Similarity โ contradiction; false positives everywhere |
| Dedup on write | Blocks legitimate updates and related-but-different facts |
The principle: if the guardrails are more complex than the feature, you've lost the trade.
</details>
---
## How search works
<details>
<summary>Hybrid ranking with multiple signals</summary>
Every search combines multiple signals to find the best matches. What's available depends on your backend:
| Signal | Postgres | SQLite | MySQL | What it measures |
|--------|----------|--------|-------|-----------------|
| V
... (truncated)
tools
Comments
Sign in to leave a comment