dbwatch
by kanchingyg
README.md
# dbwatch
[](https://github.com/kanchingyg/dbwatch/actions/workflows/ci.yml)
[](https://www.npmjs.com/package/dbwatch)
[](https://jsr.io/@kanchingyg/dbwatch)
[](https://github.com/kanchingyg/dbwatch)
[](https://github.com/kanchingyg/dbwatch/blob/HEAD/LICENSE)
**One line:** `npx dbwatch sqlite:./app.db -- npm test` (or `bunx dbwatch sqlite:./app.db -- bun test`): git-style SQLite/D1 row diff around any command with instant `--revert`.
## Install
[Bun](https://bun.sh) / [npm](https://www.npmjs.com/package/dbwatch):
```bash
bunx dbwatch sqlite:./local.db -- npm test
npx dbwatch sqlite:./local.db -- npm test
# or install in your project / globally
bun add -d dbwatch
npm i -D dbwatch
```
[JSR](https://jsr.io/@kanchingyg/dbwatch):
```bash
bunx jsr add @kanchingyg/dbwatch
npx jsr add @kanchingyg/dbwatch
```
## Quick start
```bash
npx dbwatch sqlite:./local.db -- npm test
bunx dbwatch sqlite:./local.db -- bun test
npx dbwatch sqlite:./local.db --revert --allow-write -- npm test
npx dbwatch --mcp
```
## MCP tools
| Tool | Purpose |
| --- | --- |
| `run_with_db_diff` | Wrap a command; returns exit code + compact row diff (`--allow-write`; `--dry-run` simulates) |
| `revert_last_diff` | Apply inverse SQL (`--allow-write`; `--dry-run` previews SQL) |
| `explain_side_effects` | Two-line local summary via Ollama / OpenAI-compatible API |
Add to Cursor or Claude Code:
```json
{
"mcpServers": {
"dbwatch": {
"command": "npx",
"args": ["-y", "dbwatch", "--mcp"]
}
}
}
```
## Local models
```bash
npx dbwatch sqlite:./app.db --explain --model ollama/qwen2.5-coder:7b
```
Point `baseUrl` in MCP `explain_side_effects` to LM Studio or vLLM (`http://127.0.0.1:1234`).
## Supported DSNs
- `sqlite:./path/to.db` or `file:./path/to.db`
- `d1:./local-d1.sqlite` (local Cloudflare D1 SQLite file)
- Postgres DSN parsing is reserved; use SQLite/D1 for zero-config local diffs today.
## License
[MIT](./LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues