db-recovery

Restores CALM SQLite database from snapshots after detecting abnormal row count decreases.

3|1|Updated Dec 9, 2025
One-click install
npx skills add https://github.com/isizono/calm --skill db-recovery-isizono
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: db-recovery
Source: https://github.com/isizono/calm/tree/main/skills/db-recovery
Command: npx skills add https://github.com/isizono/calm --skill db-recovery-isizono

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When the CALM plugin's SessionStart hook warns of a sudden drop in database table row counts (topics, decisions, logs, activities, materials), or you notice missing records mid-session, this Skill guides a controlled recovery instead of leaving the warning unaddressed or attempting ad-hoc fixes. ## Core Features & Use Cases - Anomaly Verification: Parses the hook warning, queries current table counts, and distinguishes genuine data loss from explainable decreases caused by legitimate bulk retract or tag-cleanup operations. - Snapshot-Based Restore: Locates the nearest healthy snapshot via snapshot.py list, filters out entries failing quick_check, and presents full restore, partial restore, or skip options for explicit user approval. - Safe Execution Workflow: Records state before stopping the MCP server, runs snapshot.py restore, never self-applies --force/--yes safety overrides, and re-verifies data after restoration. - Use Case: A new session opens with a warning that decisions dropped from 1200 to 1050 rows. The Skill confirms the anomaly, identifies the last healthy snapshot, gets your approval, stops the server, restores, and validates the recovered row counts. ## Quick Start When a DB anomaly warning appears or data seems missing, ask the AI to run the db-recovery flow to verify the loss and restore from the latest healthy snapshot.

Frequently Asked Questions about db-recovery

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I restore the CALM database from a snapshot?▼

Run snapshot.py list to find a healthy snapshot, stop the MCP server on port 52837, then run snapshot.py restore --latest or specify a snapshot path. The restore command automatically backs up the current database as a prerestore snapshot before overwriting.

What does the CALM DB data abnormal decrease warning mean?▼

The SessionStart hook compares current table row counts against the previous snapshot and warns when topics, decisions, logs, activities, or materials dropped significantly. It may indicate real data loss or an explainable decrease from legitimate bulk retract or tag-cleanup operations.

Why does snapshot restore fail with a server running error?▼

restore_snapshot blocks execution while the MCP server is running to prevent database corruption. Stop the server first with lsof -ti :52837 -sTCP:LISTEN | xargs kill, keeping the -sTCP:LISTEN flag to avoid killing bridge processes, then retry the restore.

Can I restore only one table instead of the whole CALM database?▼

Partial restore is not automated by backup_service, so it requires manual SQL-level work to identify the missing range and reinsert rows. The Skill presents this as option B with explicit effort and risk disclosure before proceeding.

When should I skip database recovery after a warning?▼

Skip recovery when the decrease is explainable by recent legitimate operations like bulk retracts or tag cleanup, when no snapshots exist, or when all snapshots fail integrity checks. Record the skip reasoning in the logs for traceability.