juliuss1907/knowledge-base/hermes-state-recovery
Claude Code and agent skill by juliuss1907/knowledge-base
- community
Checking that the SKILL.md file is still in the repository.
Recover Hermes state.db from snapshots when the database is corrupted or malformed.
Install
npx vskill@latest install juliuss1907/knowledge-base/hermes-state-recoverySKILL.md
Hermes State Recovery
Restore state.db from snapshots when the active database becomes corrupted (malformed, page-level errors, "database disk image is malformed").
Triggers
state.dbreports "database disk image is malformed"- User asks to restore state.db from a specific date
- Hermes sessions / memory stop working due to DB corruption
Snapshot location
Snapshots live under .hermes/state-snapshots/<timestamp>-<label>/. Each snapshot directory contains a full copy of the .hermes/ state at that point: state.db, config.yaml, auth.json, cron/, gateway_state.json, manifest.json.
Identify the right snapshot:
Recovery workflow
Phase 1: Assess corruption
If integrity_check returns errors about "btreeInitPage() returns error code 11", "never used" pages — the DB has page-level corruption. Python's built-in sqlite3 module will also fail with "database disk image is malformed".
Phase 2: Dump recoverable data
The .dump command wraps output in a transaction. If any table fails during dump, the entire transaction rolls back with ROLLBACK; -- due to errors. Solution: dump each table individually.
Phase 3: Clean and import
The .schema dump includes CREATE TABLE sqlite_sequence(name,seq) and INSERT INTO sqlite_sequence — these are reserved and will fail on import. Remove them:
Phase 4: Verify
Phase 5: Deploy
Pitfalls
- `.recover` needs `sqlite_dbpage` — this virtual table is rarely available. The
.recovercommand will fail with "no such table: sqlite_dbpage". Fall back to.dump.
- `.dump` can roll back silently — check the last line of the dump for
ROLLBACK; -- due to errors. If present, dump tables individually.
- Messages table is largest and most likely to crash —
sqlite3may segfault (exit code 11) during messages dump. The data dumped before the crash is still valid. Accept partial recovery.
- `grep` treats dump as binary — message content may contain null bytes. Use
grep -a(orgrep --text) to force text mode when filtering the dump SQL.
- `sqlite_sequence` is reserved — the
.schemadump includes it. Must filter out or import will fail with "object name reserved for internal use: sqlite_sequence".
- Python sqlite3 can't open malformed DBs — use the
sqlite3CLI tool. Install if missing:sudo apt-get install -y sqlite3.
- Expect data loss — corrupted pages mean some sessions/messages will be unrecoverable. The snapshot captures the DB state at a point in time; if it was already corrupted when the snapshot was taken, recovery is partial.
Reference
references/recovery-log-20260627.md— full session log from a real recovery: corruption pattern, approaches tried, exact exit codes, and outcome.
Verification checklist
After restore, confirm:
- [ ]
PRAGMA integrity_checkreturnsok - [ ] Session count matches expectations (within ~1-2 of snapshot)
- [ ] Message count is reasonable
- [ ]
SELECT COUNT(DISTINCT session_id) FROM messages≤ session count - [ ] Date range makes sense (no 1970-01-01 entries without reason)
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.hermes/skills/.archive/hermes-state-recovery/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/juliuss1907/knowledge-base/hermes-state-recovery)