# Send Gateway Auto-Rollback to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "gateway-auto-rollback",
    "name": "Gateway Auto-Rollback",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/halfmoon82/gateway-auto-rollback",
    "canonicalUrl": "https://clawhub.ai/halfmoon82/gateway-auto-rollback",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/gateway-auto-rollback",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=gateway-auto-rollback",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "SKILL.md",
      "_meta.json",
      "gateway-auto-rollback.py",
      "test-rollback-mechanism.sh"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "gateway-auto-rollback",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-01T15:46:04.067Z",
      "expiresAt": "2026-05-08T15:46:04.067Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=gateway-auto-rollback",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=gateway-auto-rollback",
        "contentDisposition": "attachment; filename=\"gateway-auto-rollback-1.1.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "gateway-auto-rollback"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/gateway-auto-rollback"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/gateway-auto-rollback",
    "downloadUrl": "https://openagent3.xyz/downloads/gateway-auto-rollback",
    "agentUrl": "https://openagent3.xyz/skills/gateway-auto-rollback/agent",
    "manifestUrl": "https://openagent3.xyz/skills/gateway-auto-rollback/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/gateway-auto-rollback/agent.md"
  }
}
```
## Documentation

### Gateway Auto-Rollback

Three-layer configuration protection for OpenClaw Gateway — never break your config again.

### What It Does

Automatically protects your OpenClaw configuration files with:

Pre-modification backup — SHA256 content-addressed snapshots before any change
Post-modification validation — JSON syntax check + Gateway health probe
Automatic rollback — instant restore if validation fails

### When to Use

Before modifying openclaw.json, exec-approvals.json, or skills.json
When running automated config changes (cron jobs, scripts)
As a background safety net during development
When you want peace of mind that a bad config won't take down your agent

### One-shot check (before manual edits)

python3 gateway-auto-rollback.py

This initializes the backup directory, validates current config, and logs status.

### Watch mode (background daemon)

python3 gateway-auto-rollback.py --watch &

Monitors critical config files every 3 minutes. Auto-exits after 3 consecutive healthy checks (config is stable).

### How It Works

Before Modification        During              After Modification
       ↓                    ↓                        ↓
  Backup + Hash  ───→  Execute Change  ───→  JSON Validate + Health Check
       │                                          │
       └──────────────────────────────────────→ Auto-rollback on failure

### Protected Files

FileDescriptionopenclaw.jsonMain Gateway configurationexec-approvals.jsonCommand execution approvalsskills.jsonSkills registry

### Backup Naming

Backups are stored in ~/.openclaw/backup/ with content-addressed names:

openclaw.json.20260301_053612.a1b2c3d4.bak
                 ↑ timestamp    ↑ SHA256 prefix (dedup)

### Python Functions

from gateway_auto_rollback import (
    pre_modification_check,   # Call before modifying config
    post_modification_verify, # Call after modifying config
    create_backup,            # Manual backup creation
    validate_json,            # JSON syntax validation
    check_gateway_health,     # Gateway health probe
    rollback_to_backup,       # Manual rollback
    watch_config_files,       # Start watch daemon
)

### Pre-modification flow

from pathlib import Path

config = Path.home() / ".openclaw" / "openclaw.json"

# Returns backup path on success, False on failure
backup = pre_modification_check(config)

# ... make your changes ...

# Validates and auto-rolls back if needed
success = post_modification_verify(config, backup)

### Watch mode details

The watcher:

Polls every 3 minutes (gives Gateway time to restart)
Detects changes via SHA256 hash comparison
Auto-creates backup when change detected
Validates JSON + health check after each change
Auto-exits after 3 consecutive healthy checks (config stabilized)
Logs all events to ~/.openclaw/logs/config-modification.log

### Integration with Cron

Set up periodic health checks:

# Cron job example: check every hour
0 * * * * python3 /path/to/gateway-auto-rollback.py

Or use OpenClaw's built-in cron:

{
  "name": "Gateway-Auto-Rollback",
  "schedule": { "kind": "cron", "expr": "0 */6 * * *", "tz": "Asia/Shanghai" },
  "payload": {
    "kind": "agentTurn",
    "message": "Run gateway health check. If unhealthy, rollback to latest backup."
  },
  "sessionTarget": "isolated"
}

### Manual Rollback

If you need to manually restore a config:

# List available backups (newest first)
ls -lt ~/.openclaw/backup/ | head -10

# Restore a specific backup
cp ~/.openclaw/backup/openclaw.json.20260301_053612.a1b2c3d4.bak \\
   ~/.openclaw/openclaw.json

# Restart Gateway
openclaw gateway restart

# Verify
curl -s http://127.0.0.1:18789/api/health

### Testing

Run the included test suite to verify the mechanism works:

bash test-rollback-mechanism.sh

Tests cover:

Backup directory existence
JSON validation
SHA256 hash computation
Backup creation and restore
Watch daemon status
Log file integrity
Script permissions

### Logs

All events are logged to ~/.openclaw/logs/config-modification.log:

[2026-03-01 05:37:00] INFO: ✅ 备份创建: openclaw.json.20260301_053612.a1b2c3d4.bak
[2026-03-01 05:37:01] INFO: ✅ 修改验证通过
[2026-03-01 05:40:00] WARN: ⚠️ 检测到修改: openclaw.json
[2026-03-01 05:40:01] ERROR: JSON 验证失败 — 触发回滚

### Requirements

Python 3.8+
OpenClaw Gateway running (for health checks)
No additional pip packages needed (stdlib only)

### File Structure

gateway-auto-rollback/
├── SKILL.md                      # This file
├── _meta.json                    # ClawHub metadata
├── gateway-auto-rollback.py      # Main script (backup/validate/rollback/watch)
└── test-rollback-mechanism.sh    # Test suite
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: halfmoon82
- Version: 1.1.0
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-05-01T15:46:04.067Z
- Expires at: 2026-05-08T15:46:04.067Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/gateway-auto-rollback)
- [Send to Agent page](https://openagent3.xyz/skills/gateway-auto-rollback/agent)
- [JSON manifest](https://openagent3.xyz/skills/gateway-auto-rollback/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/gateway-auto-rollback/agent.md)
- [Download page](https://openagent3.xyz/downloads/gateway-auto-rollback)