anti-suicide
Safety guardrail that prevents OpenClaw from self-destructing via erroneous self-modification. ALWAYS use this skill before modifying any of OpenClaw's own critical files: openclaw.json, workspace prompt files (AGENTS.md, SOUL.md, TOOLS.md), installed skills, .env files, docker-compose.yml, or any file inside ~/.openclaw/ or the openclaw installation directory. Also trigger when the user says "update my config", "modify openclaw settings", "change the agent prompt", "edit my soul/agents/tools file", "reinstall", or any operation that touches OpenClaw's own runtime files. The goal is to enforce Backup → Snapshot → Modify → Verify for every self-modification, with automatic rollback if health degrades.
git clone https://github.com/shyrock/anti-suicide
git clone --depth=1 https://github.com/shyrock/anti-suicide ~/.claude/skills/shyrock-anti-suicide-anti-suicide
SKILL.mdAnti-Suicide Skill
OpenClaw is an always-on personal assistant. One bad write to
openclaw.json or a corrupted SOUL.md can take it offline or alter its behavior in subtle, hard-to-debug ways. This skill enforces a safe modification protocol using a supervisor script that automatically rolls back changes if the service degrades.
What Counts as "Self-Modification"
Any write, edit, or delete targeting:
| Path | Risk |
|---|---|
| Gateway fails to start; all channels go dark |
| Agent identity/capabilities silently corrupted |
| Personality and core behavior overwritten |
| Available tools list broken |
| Individual skill broken or lost |
| API keys or channel tokens lost |
| Container won't start |
/ | Dependency resolution broken |
See
references/critical_paths.md for field-level details.
Safe Modification Protocol
Every self-modification follows these five steps in strict order.
Step 1 — Start the Supervisor (Before Touching Anything)
The supervisor captures a health baseline and returns a session ID. Start it before making any changes:
SESSION=$(python ~/.openclaw/workspace/skills/anti-suicide/scripts/supervisor.py snapshot \ --files <file1> [file2 ...]) echo "Session: $SESSION"
The session ID is a path like
/tmp/anti-suicide-<timestamp>/. Save it — you'll need it in Step 4.
If the supervisor reports the service is already unhealthy at baseline, stop immediately. Do not make modifications on a service that is already degraded. Report the health output to the user and ask how to proceed.
Step 2 — Show the Diff
Before applying any change, show the user exactly what is changing:
FILE: <filepath> BEFORE: ─────────────────── <current content of the affected section> ─────────────────── AFTER: ─────────────────── <proposed content> ───────────────────
For JSON files, also validate the proposed content parses correctly before showing the diff:
python ~/.openclaw/workspace/skills/anti-suicide/scripts/supervisor.py validate-json \ --content '<proposed_json>'
If JSON is invalid, stop here and tell the user what needs fixing.
Step 3 — Confirm
Say exactly:
"About to modify
. Supervisor session<filepath>is active and will auto-rollback if the service degrades. The diff is shown above. Shall I proceed?"<SESSION>
Wait for explicit confirmation before writing anything.
Step 4 — Apply the Change
Make the modification using the Edit tool (never Write for existing files, to avoid accidental full overwrites).
Step 5 — Verify (Supervisor Monitors and Auto-Heals)
After applying, hand off to the supervisor to monitor the service:
python ~/.openclaw/workspace/skills/anti-suicide/scripts/supervisor.py verify \ --session $SESSION \ --timeout 60 \ --interval 5
The supervisor will:
- Poll
, gateway liveness, and channel status every 5 seconds for 60 secondsopenclaw doctor - If health is stable throughout → print
and exit 0HEALTHY - If health degrades → automatically rollback all backed-up files, restart the gateway, and print a report
Report the result to the user. If auto-rollback occurred, say what was rolled back and that the service has been restored.
Hard Blocks
The following are never safe without explicit user override:
- Deleting
,openclaw.json
,SOUL.md
, orAGENTS.md
entirelyTOOLS.md - Overwriting a prompt file with empty or near-empty content
- Killing the gateway process without first warning the user about downtime
- Running
ornpm install
insidepnpm install
without confirming no pinned versions will break~/.openclaw/ - Running
without warning that all channels will disconnectdocker-compose down
Manual Rollback
If you need to rollback outside of the supervisor flow:
python ~/.openclaw/workspace/skills/anti-suicide/scripts/rollback.py --session <SESSION> openclaw gateway restart
Or restore a specific file:
python ~/.openclaw/workspace/skills/anti-suicide/scripts/rollback.py --file <backup_file_path>
References
— full list of critical file paths with required structurereferences/critical_paths.md