diff --git a/OPENCLAW_TRICKS.md b/OPENCLAW_TRICKS.md index dd820d4..f8fecb6 100644 --- a/OPENCLAW_TRICKS.md +++ b/OPENCLAW_TRICKS.md @@ -411,6 +411,46 @@ The key output rule: heartbeats should either be `HEARTBEAT_OK` (nothing to do) or a direct alert. Work narration goes to a designated status channel, never to the human's DM. +### The Workspace as a Git Repo (Disaster Recovery + Debugging) + +The entire workspace is itself a git repo, aggressively committed and pushed +after every change. A cron job runs every 6 hours as a safety net, but the agent +pushes promptly after any modification. + +This gives you three things: + +1. **Disaster recovery.** The git remote is on a different machine (ideally in a + different building/city/country from the OpenClaw host). If the host dies, + you clone the workspace onto a new machine and the agent picks up where it + left off — all memory files, daily context, logs, checklists intact. + +2. **State snapshots.** Every commit is a snapshot of the agent's complete state + at that moment. If the agent corrupts a file, overwrites something important, + or makes a bad edit, you can `git log` and `git checkout` to recover any + previous version. + +3. **Prompt debugging.** When the agent behaves unexpectedly, you can look at + the git history to see exactly what its state files contained at the time. + What did daily-context.json say? What was in MEMORY.md? What checklist + version was it using? This turns "why did it do that?" from guesswork into + forensics. + +The agent treats this repo differently from code repos — no PRs, no branches, +just direct commits to main. It's a state mirror, not a development workflow. + +```markdown +### State Repo (clawstate.git) + +- Commit and push workspace changes after any change to workspace files +- Push promptly — the remote repo should reflect the workspace in effectively + realtime +- Auto-sync cron runs every 6h as a safety net +``` + +**Important:** Code repos should be cloned OUTSIDE the workspace (e.g. +`~/repos/` or a fast external drive) to avoid embedding git repos inside the +workspace repo. The workspace repo tracks workspace files only. + ### Putting It All Together The system works as a loop: