@kanchingyg/dbwatch
v0.1.1
Published
Git-style live row diff for SQLite/D1/Postgres around any command, with instant rollback
Downloads
73
Maintainers
Readme
dbwatch
One line: npx @kanchingyg/dbwatch sqlite:./app.db -- npm test (or bunx @kanchingyg/dbwatch sqlite:./app.db -- bun test): git-style SQLite/D1 row diff around any command with instant --revert.
Install
bunx @kanchingyg/dbwatch sqlite:./local.db -- npm test
npx @kanchingyg/dbwatch sqlite:./local.db -- npm test
# or install in your project / globally
bun add -d @kanchingyg/dbwatch
npm i -D @kanchingyg/dbwatchJSR:
bunx jsr add @kanchingyg/dbwatch
npx jsr add @kanchingyg/dbwatchQuick start
npx @kanchingyg/dbwatch sqlite:./local.db -- npm test
bunx @kanchingyg/dbwatch sqlite:./local.db -- bun test
npx @kanchingyg/dbwatch sqlite:./local.db --revert --allow-write -- npm test
npx @kanchingyg/dbwatch --mcpLocal models
npx @kanchingyg/dbwatch sqlite:./app.db --explain --model ollama/qwen2.5-coder:7bPoint baseUrl in MCP explain_side_effects to LM Studio or vLLM (http://127.0.0.1:1234).
Supported DSNs
sqlite:./path/to.dborfile:./path/to.dbd1:./local-d1.sqlite(local Cloudflare D1 SQLite file)- Postgres DSN parsing is reserved; use SQLite/D1 for zero-config local diffs today.
MCP Tools Reference
| Tool | Mutates | Description |
| --- | --- | --- |
| run_with_db_diff | true | Snapshot SQLite/D1 tables, execute a child command, and return exit status plus row-level INSERT/UPDATE/DELETE diffs (requires --allow-write). |
| revert_last_diff | true | Execute inverse SQL statements from the most recent captured diff to restore prior table state (requires --allow-write). |
| explain_side_effects | false | Summarize captured row mutations in two lines via a local Ollama or OpenAI-compatible model. |
Editor and Agent Integration
Cursor (.cursor/mcp.json)
{
"mcpServers": {
"dbwatch": {
"command": "npx",
"args": ["-y", "@kanchingyg/dbwatch", "--mcp"]
}
}
}Claude Code CLI
claude mcp add dbwatch -- npx -y @kanchingyg/dbwatch --mcpProgrammatic Usage (JSR / TypeScript)
import * as bridge from "jsr:@kanchingyg/dbwatch/bridge";Runtime Safety and Guardrails
- Stdio frame isolation:
--mcpkeeps JSON-RPC onstdoutclean. - Read-only default:
run_with_db_diff/revert_last_diffneed--allow-write;--dry-runsimulates. - Loop breaker: Identical MCP tool calls halt after three repeats.
- Revert SQL: Inverse statements use quoted identifiers and escaped literals (SQLite/D1 local files only today).
