Skip to content

Watch Mode

Watch mode runs a daemon that automatically backs up your memory file when changes are detected. Supports compression, logging, and automatic pruning of old backups.

Terminal window
# Default: backup every 5 minutes, keep 10 backups
npx toon-memory watch
# Custom interval (in minutes)
npx toon-memory watch 10
# Enable gzip compression
npx toon-memory watch -c
# Enable file logging
npx toon-memory watch -l
# Keep max 20 backups
npx toon-memory watch -m 20
# All options combined
npx toon-memory watch 15 -c -l -m 20
# Press Ctrl+C to stop
Option Description Default
[interval] Backup interval in minutes 5
-c, --compress Enable gzip compression off
-l, --log [path] Enable file logging off
-m, --max-backups <n> Max backups to keep (0=unlimited) 10
Terminal window
$ npx toon-memory watch 15 -c -l -m 20
🧠 toon-memory watch
Watching memory file every 15 minutes...
Max backups: 20
Compression: enabled
Logging: enabled (.opencode/memory/watch.log)
Press Ctrl+C to stop
📦 Backup #1 created: 2026-07-11T16-00-00-000Z
📦 Backup #2 created: 2026-07-11T16-15-00-000Z
🗑️ Pruned 1 old backup(s)
^C
Watch stopped. 2 backups created.
  1. Watches .opencode/memory/data.toon for changes
  2. When content changes, creates a timestamped backup
  3. Backups are stored in .opencode/memory/backups/
  4. Only creates backup when content actually changes
  5. If max-backups is exceeded, oldest backups are pruned
  6. Optional gzip compression reduces backup size by ~60-80%
  7. Optional logging writes events to a file
.opencode/memory/backups/
├── backup-2026-07-11T16-00-00-000Z.toon
├── backup-2026-07-11T16-15-00-00-000Z.toon.gz # compressed
└── backup-2026-07-11T16-30-00-000Z.toon
  • Long coding sessions — Auto-backup while you work
  • Pre-deployment — Run before important changes
  • CI/CD — Backup before automated changes
  • Low disk space — Use -c for compression
  • Debugging — Use -l to log backup events