spec

Workspace Backup & Version Control

2026-04-03

Workspace Backup & Version Control

Exec Summary

Git-based version control for the entire ~/.openclaw/ directory with automated commits and a private GitHub remote. Three commit triggers: (1) cron every 30 minutes, (2) event-driven on task completion, (3) manual "commit workspace" chat command. All commits get descriptive messages, not just timestamps. David builds the scripts; Pete handles a short setup checklist (SSH key addition to GitHub). Private repo already created at https://github.com/Mauronic/firstascent-claw.

1. Problem Statement and Goal

The entire ~/.openclaw/ directory has no version control or off-machine backup. This has caused real pain:

Goal: Every meaningful change across the entire OpenClaw installation is version-controlled and recoverable. A private GitHub repo serves as the off-machine backup. Recovery from any bad write is a single git checkout or git revert.

2. Success Metric

3. Current State

4. Platform Capabilities

OpenClaw has no built-in workspace backup feature. This is entirely custom infrastructure.

OpenClaw does have:

Git and GitHub are standard tools available on macOS. gh CLI can be installed via Homebrew.

5. Community Patterns

Git-based workspace backup is the standard approach in the OpenClaw community. Most setups use:

No dedicated OpenClaw skill or plugin exists for this.

6. Options

Option A: Git + GitHub with Cron Auto-Commit

Pros: Simple, standard, uses tools Pete already knows. Full history. Off-machine backup. Cons: 30-minute granularity means up to 30 min of work could be lost between commits. Auto-commit messages aren't descriptive. Complexity: Low. ~2 hours to build. Maintenance: Near zero.

Option B: Git + GitHub with Event-Driven Commits

Same as A, but also commit after specific events:

Pros: Finer granularity, commits tied to meaningful events. Cons: More integration points, more complexity, commits on every minor change could be noisy. Complexity: Medium. Additional hooks in AGENTS.md workflows. Maintenance: Low-medium. New workflows need to remember to commit.

Option C: Git + GitHub with Cron + Manual Commit Commands

Option A plus a chat command: "commit workspace" or "save workspace" triggers an immediate commit with a descriptive message.

Pros: Best of both worlds. Auto-commit catches everything, manual commit lets Pete mark important states. Cons: Slightly more to build (chat command handler). Complexity: Low-medium. Maintenance: Near zero.

7. Recommendation

Option C + event-driven commits on task completion.

Three commit triggers, each with descriptive messages:

  1. Cron (every 30 min): Catches everything. Message format: auto: changed files summary (e.g. auto: tasks.json, memory/2026-04-03.md, artifacts/spec_workspace_backup.md). Lists the actual filenames that changed, not just a timestamp.
  2. Event-driven (task moved to Done): Commits immediately when any task reaches Done status. Message format: done: JAM-18 Workspace Backup & Version Control. Tied to the AGENTS.md lifecycle workflow so it fires automatically.
  3. Manual ("commit workspace: <message>"): Pete or Vinny triggers in chat with a descriptive message. Message format: whatever was typed (e.g. commit workspace: restored tasks.json after data wipe).

The auto-commit script is idempotent: if nothing changed, it does nothing. If the push fails (network issue), it logs the failure and retries next cycle.

Commit message strategy

Every commit gets a meaningful message. No bare timestamps.

TriggerMessage FormatExample
Cronauto: <changed files list>auto: tasks.json, memory/2026-04-03.md
Task donedone: <displayId> <title>done: JAM-18 Workspace Backup & Version Control
Manual<user message>restored tasks.json after data wipe
Memory flushmemory: flush to <filename>memory: flush to memory/2026-04-03.md

The cron script generates the file list by running git diff --name-only before committing. If more than 5 files changed, it lists the first 5 and appends (+N more).

8. Security Considerations

9. Pete's Setup Checklist

Most setup is already done or will be automated by David. Pete's remaining steps:

Step 1: Add SSH public key to GitHub ✅ ~3 min

Step 2: Review .gitignore before first commit ✅ ~2 min

Step 3: Approve first push ✅ ~2 min

Already done:

Total remaining Pete time: ~7 minutes.

10. Implementation Scope

David builds:

  1. .gitignore at ~/.openclaw/ root:

```

Ephemeral / large

agents/ media/ workspace/mission-control/node_modules/ workspace/mission-control/.next/ workspace/tmp/ workspace-builder/node_modules/ workspace-builder/.next/

Secrets

workspace/client_secret.json

OS / build

.DS_Store *.pyc __pycache__/ *.log .env .env.* ```

Note: openclaw.json is intentionally NOT excluded. It contains API keys but Pete accepts this risk for a private repo. The config is critical for disaster recovery.

  1. Git setup script (workspace/scripts/git-init.sh):
  1. Auto-commit script (workspace/scripts/workspace-commit.sh):
  1. OpenClaw cron job: Run workspace-commit.sh every 30 minutes
  1. AGENTS.md updates:

11. Validation Criteria

12. Test Plan

Run these tests in order after David completes the build. Each test has a pass/fail criterion.

Test 1: Initial state verification

Test 2: .gitignore validation

Test 3: Cron auto-commit

Test 4: Task-done event commit

Test 5: Manual commit command

Test 6: Recovery test (critical)

Test 7: Config recovery test

Test 8: Push failure resilience

12. Category

Tool - new infrastructure capability (version control + backup)

13. Context Loading

14. Guardrails

15. Handoff