$npx -y skills add prompt-security/clawsec --skill soul-guardianDrift detection + baseline integrity guard for agent workspace files with automatic alerting support
| 1 | # soul-guardian 👻 |
| 2 | |
| 3 | Protects your agent's core files (SOUL.md, AGENTS.md, etc.) from unauthorized changes with automatic detection, restoration, and **user alerting**. |
| 4 | |
| 5 | ## Vercel Skills Installation |
| 6 | |
| 7 | Install with the Vercel Skills CLI for this harness: |
| 8 | |
| 9 | ```bash |
| 10 | npx skills add prompt-security/clawsec --skill soul-guardian -a openclaw -y |
| 11 | ``` |
| 12 | |
| 13 | ## Operational Notes |
| 14 | |
| 15 | - Required runtime: `python3` |
| 16 | - Optional runtime: `openclaw` for cron integration, `launchctl` for macOS scheduling, `bash` for the demo helper |
| 17 | - Side effects: can auto-restore protected files to their approved baseline and writes audit/quarantine state locally |
| 18 | - Network behavior: none by default |
| 19 | - Trust model: any scheduling is opt-in, but restore mode intentionally overwrites drifted files |
| 20 | |
| 21 | ## Release Artifact Verification |
| 22 | |
| 23 | For standalone installs, verify the signed release manifest before trusting `SKILL.md`, `skill.json`, or the archive. The `skill.json` file is the package metadata/SBOM source, and the release pipeline signs `checksums.json` with the ClawSec release key. |
| 24 | |
| 25 | ```bash |
| 26 | set -euo pipefail |
| 27 | |
| 28 | SKILL_NAME="soul-guardian" |
| 29 | VERSION="0.0.9" |
| 30 | REPO="prompt-security/clawsec" |
| 31 | TAG="${SKILL_NAME}-v${VERSION}" |
| 32 | BASE="https://github.com/${REPO}/releases/download/${TAG}" |
| 33 | ZIP_NAME="${SKILL_NAME}-v${VERSION}.zip" |
| 34 | TMP_DIR="$(mktemp -d)" |
| 35 | trap 'rm -rf "$TMP_DIR"' EXIT |
| 36 | |
| 37 | RELEASE_PUBKEY_SHA256="711424e4535f84093fefb024cd1ca4ec87439e53907b305b79a631d5befba9c8" |
| 38 | |
| 39 | curl -fsSL "$BASE/checksums.json" -o "$TMP_DIR/checksums.json" |
| 40 | curl -fsSL "$BASE/checksums.sig" -o "$TMP_DIR/checksums.sig" |
| 41 | curl -fsSL "$BASE/signing-public.pem" -o "$TMP_DIR/signing-public.pem" |
| 42 | curl -fsSL "$BASE/$ZIP_NAME" -o "$TMP_DIR/$ZIP_NAME" |
| 43 | curl -fsSL "$BASE/SKILL.md" -o "$TMP_DIR/SKILL.md" |
| 44 | curl -fsSL "$BASE/skill.json" -o "$TMP_DIR/skill.json" |
| 45 | |
| 46 | ACTUAL_PUBKEY_SHA256="$(openssl pkey -pubin -in "$TMP_DIR/signing-public.pem" -outform DER | shasum -a 256 | awk '{print $1}')" |
| 47 | if [ "$ACTUAL_PUBKEY_SHA256" != "$RELEASE_PUBKEY_SHA256" ]; then |
| 48 | echo "ERROR: signing-public.pem fingerprint mismatch" >&2 |
| 49 | exit 1 |
| 50 | fi |
| 51 | |
| 52 | openssl base64 -d -A -in "$TMP_DIR/checksums.sig" -out "$TMP_DIR/checksums.sig.bin" |
| 53 | openssl pkeyutl -verify -rawin -pubin \ |
| 54 | -inkey "$TMP_DIR/signing-public.pem" \ |
| 55 | -sigfile "$TMP_DIR/checksums.sig.bin" \ |
| 56 | -in "$TMP_DIR/checksums.json" >/dev/null |
| 57 | |
| 58 | hash_file() { |
| 59 | if command -v shasum >/dev/null 2>&1; then |
| 60 | shasum -a 256 "$1" | awk '{print $1}' |
| 61 | else |
| 62 | sha256sum "$1" | awk '{print $1}' |
| 63 | fi |
| 64 | } |
| 65 | |
| 66 | verify_manifest_file() { |
| 67 | asset="$1" |
| 68 | path="$2" |
| 69 | expected="$(jq -r --arg asset "$asset" '.files[$asset].sha256 // empty' "$TMP_DIR/checksums.json")" |
| 70 | if [ -z "$expected" ]; then |
| 71 | echo "ERROR: checksums.json missing $asset" >&2 |
| 72 | exit 1 |
| 73 | fi |
| 74 | actual="$(hash_file "$path")" |
| 75 | if [ "$actual" != "$expected" ]; then |
| 76 | echo "ERROR: checksum mismatch for $asset" >&2 |
| 77 | exit 1 |
| 78 | fi |
| 79 | } |
| 80 | |
| 81 | expected_archive="$(jq -r '.archive.sha256 // empty' "$TMP_DIR/checksums.json")" |
| 82 | if [ -z "$expected_archive" ]; then |
| 83 | echo "ERROR: checksums.json missing archive.sha256" >&2 |
| 84 | exit 1 |
| 85 | fi |
| 86 | actual_archive="$(hash_file "$TMP_DIR/$ZIP_NAME")" |
| 87 | if [ "$actual_archive" != "$expected_archive" ]; then |
| 88 | echo "ERROR: archive checksum mismatch" >&2 |
| 89 | exit 1 |
| 90 | fi |
| 91 | |
| 92 | verify_manifest_file "SKILL.md" "$TMP_DIR/SKILL.md" |
| 93 | verify_manifest_file "skill.json" "$TMP_DIR/skill.json" |
| 94 | |
| 95 | echo "Signed release manifest, archive, SKILL.md, and skill.json verified." |
| 96 | ``` |
| 97 | |
| 98 | Only install or extract the archive after this verification succeeds. |
| 99 | |
| 100 | ## Quick Start (3 Steps) |
| 101 | |
| 102 | ### Step 1: Initialize baselines |
| 103 | ```bash |
| 104 | cd ~/.openclaw/workspace |
| 105 | python3 skills/soul-guardian/scripts/soul_guardian.py init --actor setup --note "initial baseline" |
| 106 | ``` |
| 107 | |
| 108 | ### Step 2: Enable monitoring |
| 109 | ```bash |
| 110 | python3 skills/soul-guardian/scripts/soul_guardian.py enable-monitoring |
| 111 | ``` |
| 112 | This shows you how to add monitoring to your workflow. |
| 113 | |
| 114 | ### Step 3: Add to HEARTBEAT.md (Recommended) |
| 115 | |
| 116 | Add this to your HEARTBEAT.md for automatic monitoring: |
| 117 | |
| 118 | ```markdown |
| 119 | ## Soul Guardian Check |
| 120 | - Run `python3 skills/soul-guardian/scripts/soul_guardian.py check --actor heartbeat --output-format alert` |
| 121 | - If any output is produced, relay it to the user immediately as a security alert |
| 122 | ``` |
| 123 | |
| 124 | That's it! Soul Guardian will now: |
| 125 | - ✅ Detect unauthorized changes to protected files |
| 126 | - ✅ Auto-restore SOUL.md and AGENTS.md to approved baseline |
| 127 | - ✅ Alert you when drift is detected and handled |
| 128 | |
| 129 | --- |
| 130 | |
| 131 | ## What it protects (default policy) |
| 132 | |
| 133 | | File | Mode | Action on drift | |
| 134 | |------|------|-----------------| |
| 135 | | SOUL.md | restore | Auto-restore + alert | |
| 136 | | AGENTS.md | restore | Auto-restore + alert | |
| 137 | | USER.md | alert | Alert only | |
| 138 | | TOOLS.md | alert | Alert only | |
| 139 | | IDENTITY.md | alert | Alert only | |
| 140 | | HEARTBEAT.md | alert | |