Guidance for recovering data from SQLite Write-Ahead Log (WAL) files that may be corrupted, encrypted, or inaccessible. This skill should be used when tasks involve database recovery, WAL file analysis, decrypting database files, or recovering missing/corrupted SQLite data. Helps avoid common pitfalls like fabricating data based on patterns instead of actual recovery.
This skill provides guidance for recovering data from SQLite Write-Ahead Log (WAL) files that appear corrupted, encrypted, or otherwise inaccessible.
Core Principle
Recovery means finding existing data, not generating new data. Never fabricate or guess data based on patterns. The goal is to locate and extract actual data from the source files.
Initial Assessment
Verify WAL Mode and File Presence
Check if the database is in WAL mode:
PRAGMA journal_mode;
Identify all database-related files (typically main.db, main.db-wal, main.db-shm)
Critical: If a file appears in one listing method but not another, this is a significant clue requiring investigation, not dismissal
Related Skills
Document Initial Observations
Record all file listings from different tools/methods. Discrepancies between tools often indicate:
Special characters in filenames
Permission issues
Different file encodings
Hidden or mounted files
Tool-specific behavior differences
Investigation Strategies
When Files Appear to Be Missing
If a WAL file is listed by one tool but inaccessible via another:
Investigate the discrepancy thoroughly - do not dismiss it
Check for special characters: ls -la | cat -A
Examine permissions: ls -la, stat <filename>
Try different access methods: direct path, glob patterns, hex representation
Check if file is a symlink: file <filename>, readlink <filename>
Examine parent directory permissions
Consider if the file might be in a different mount or namespace
When Files Appear Corrupted or Encrypted
Step 1: Examine Raw File Structure
xxd <filename> | head -50
hexdump -C <filename> | head -50
Valid SQLite WAL files start with specific magic bytes
Look for recognizable patterns vs random-looking data
Document what you observe before concluding encryption
Step 2: Systematic Decryption Attempts
If encryption is suspected:
Single-byte XOR: Try common keys (0x00-0xFF)
Multi-byte XOR: Try common patterns, repeating keys
Look for key hints: Check other files in the directory for encryption keys
Examine headers: WAL headers may contain encryption method clues
Try known SQLite encryption libraries: SQLCipher, SEE, etc.