Install
openclaw skills install @lucy6692/config-safe-edit安全修改配置文件的系统性流程。当需要修改 openclaw.json、models.json、或其他任何系统配置文件时激活。核心价值:改前备份 + 版本对比 + 确认差异后再操作。适合:(1)修改任何配置文件前;(2)升级后出现异常需要溯源;(3)无法确认某字段来源时;(4)用户要求验证配置变化时。避免因配置错误...
openclaw skills install @lucy6692/config-safe-editEdit config files without breaking things.
Configuration files are where agents cause the most irreversible damage. One wrong keystroke and your system won't start. This skill makes config changes predictable and reversible.
Backup → Edit → Diff → Commit or Recover
Never edit a config file without being able to undo it.
Before touching anything, answer these:
If any answer is unclear → stop and ask.
| Tool | When to use |
|---|---|
gateway config.patch | Safe, validates JSON, hot-reload when possible |
Direct file edit (edit tool) | Credentials, protected paths, or when patch fails |
Protected paths that always need direct edit: appId, clientSecret, appSecret, token, apiKey, apiKey*, password
Test if a field is protected by trying config.patch first. If it errors with "cannot change protected config paths" → use direct edit.
Use search to find exact line numbers, then edit precisely:
# Find field and surrounding context
grep -n "the_field_name" /path/to/config.json
# PowerShell equivalent
Select-String -Path "C:\path\to\config.json" -Pattern "the_field_name" -Context 0,2
Never do blind edits. Always confirm you know exactly which occurrence to change.
# Linux/Mac
cp /path/to/config.json /path/to/config.json.backup
# Windows
Copy-Item "C:\path\to\config.json" "C:\path\to\config.json.backup"
Always overwrite the same file — no date suffix. This keeps exactly one backup on disk. After diff confirms the change is correct, the backup is no longer needed and can be overwritten by the next edit.
# Linux/Mac
diff /path/to/config.json.backup.* /path/to/config.json
# PowerShell
diff (Get-Content "config.bak") (Get-Content "config.json")
Only proceed if diff shows exactly what you intended. Any unexpected lines = revert immediately.
Symptom: gateway config.patch errors with "cannot change protected config paths"
Fix: Use direct edit on the file instead
Symptom: Config appears correct but system behaves unexpectedly Fix: Always search first (Step 3), don't guess field names
Symptom: Gateway won't start, error about JSON parse failure
Fix: Before any edit, validate JSON: python3 -c "import json; json.load(open('config.json'))"
Symptom: Same as above — JSON malforms Fix: After any edit, always validate JSON before restarting
Problem: Backup is overwritten each time — no historical versions
Fix: If you need a dated snapshot before a risky edit, manually cp config.json config.json.backup.2026-05-07 first. The standard workflow uses a single overwrite-safe backup.
When something goes wrong:
diff current vs backup → identify the unexpected changecp backup.json config.jsonpython3 -c "import json; ..." or Get-Content x.json | ConvertFrom-JsonSCOPE: What file, what field, what's new value?
LOCATE: grep/Select-String before touching anything
BACKUP: cp config.json config.json.backup # overwrite-safe, no date suffix
EDIT: edit tool or config.patch
DIFF: diff backup vs new — only proceed if exact match
RECOVER: cp config.json.backup config.json → validate → restart
Always use this for: credentials, API keys, server addresses, port numbers, security settings, channel configurations.
Some edits can lock you out of your own system. Treat these with extra care.
Edits to these fields are high-risk — they can prevent OpenClaw from starting:
gateway.port, gateway.bind, gateway.authplugins, plugins.allow, plugins.entriesmeta.version, meta.lastTouchedVersionchannels (channel misconfiguration can crash the plugin loader)Before the edit: Manually create a dated snapshot backup:
# Windows
Copy-Item "openclaw.json" "openclaw.json.backup.$(Get-Date -Format 'yyyy-MM-dd')"
After the edit, before saying "OK to restart": Always validate JSON syntax:
# Windows PowerShell
python3 -c "import json; json.load(open('C:/path/to/openclaw.json'))"
If Python returns nothing → JSON is valid. If it throws an exception → syntax error, fix before continuing.
After restart: If Gateway won't come back:
.bak files on each config save — find the latest one in the same directory.bak fileIf the JSON is valid but the config is semantically wrong (e.g., wrong port number), Gateway will start but behave unexpectedly. There is no automated fix for this — it requires human diagnosis. The best defense is Step 1 (Scope): always know exactly what you're changing and why before you touch anything.