walkpod1007

Lifeos Guardrails — Development skill for Claude Code

Development community

Six battle-tested Claude Code guardrail hooks: block destructive commands without confirmation, protect core config files, catch false-empty search results, prevent tmux socket fallback kills, scan fu.

How to install Lifeos Guardrails

This entry records only its repository, not the path inside it, so there is no exact command to give. Open walkpod1007/lifeos-guardrails and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Lifeos Guardrails does

Six battle-tested Claude Code guardrail hooks: block destructive commands without confirmation, protect core config files, catch false-empty search results, prevent tmux socket fallback kills, scan full-width variable traps, stop banned words. Tests + one-line installer.

Alternatives in Development

  • LifeOS — ⛰️ The Life Operating System — an intent engineering platform that moves you from your current state to your i 18.7k ★
  • Internet Court Skill — The trust layer for agent-to-agent commerce — natural-language mandates, ERC-7710 delegated permissions, x402 4.9k ★
  • Careful — Activate destructive command warnings for the session 2.8k ★

README

lifeos-guardrails

lifeos-guardrails is a collection of battle-tested safety hooks for Claude Code. It provides defense-in-depth protection against catastrophic shell commands, accidental overwrites of critical settings, silent tmux process massacres, misleading search timeouts, fullwidth syntax bugs, and conversational banned phrases. All hooks are modular, lightweight, and configurable via guardrails.conf.


專案簡介

`lifeos-guardrails` 是從真實生產環境中歷經兩個月實戰驗證與多輪紅隊演練提煉而成的 Claude Code 守衛系統。透過 PreToolUse、PostToolUse 與 Stop 鉤子,為 AI 輔助開發提供縱深防禦(Defense-in-Depth),防止破壞性誤操作與隱形故障。


前置需求

本專案各守衛與安裝腳本依賴以下基礎工具:

  • bash(4.0+ 建議,相容系統預設 bash 3.2+)
  • jq:用於解析 Claude Code 傳入的工具呼叫 JSON。請注意:core-file-write-guard.sh 缺 jq 會 fail-closed 鎖死所有編輯呼叫(這是刻意設計,防止無解析工具時漏防)。
  • python3(3.8+):用於設定檔讀取、多行 transcript 分析與全形吸變數掃描。

在安裝前請確保環境中已具備 `jq` 與 `python3`。`install.sh` 在開頭會檢查依賴(含 dry-run),若缺失則退出並提示。


三步快速安裝

步驟 1:Clone 本儲存庫

git clone https://github.com/walkpod1007/lifeos-guardrails.git
cd lifeos-guardrails

步驟 2:執行安裝腳本

# 可先使用 --dry-run 預覽變更(零寫入,不建立目錄或修改檔案)
bash install.sh --dry-run

# 正式安裝至 $HOME/.claude/
bash install.sh

安裝腳本會執行以下動作:

  1. 複製 6 支守衛腳本與 lib/$HOME/.claude/hooks/lifeos-guardrails/(自動排除 __pycache__)。
  2. 將守衛註冊合併至 $HOME/.claude/settings.json(自動展開為絕對路徑,採用 hooks[].hooks[].command 標準巢狀結構;已存在的同檔名守衛不重複寫入,既有其他設定與 permissions 完整保留)。
  3. 寫入前會自動備份舊設定檔至 $HOME/.claude/settings.json.bak-<時戳>

步驟 3:驗證安裝

# 執行測試套件驗證全部 7 支測試(含安裝測試與 6 支守衛)
bash tests/run-all.sh

解除安裝

如需完整移除守衛:

bash install.sh --uninstall

解除安裝會自動自 `settings.json` 移除指向 `lifeos-guardrails` 的守衛條目(若事件陣列或 `hooks` 物件變空會自動清理鍵值,其餘設定保留,寫入前備份至 `$HOME/.claude/settings.json.bak-<時戳>`),並移除 `$HOME/.claude/hooks/lifeos-guardrails/` 目錄。


設定檔說明(guardrails.conf)

若需調整保護路徑或禁詞清單,可將 `guardrails.conf.example` 複製至相應位置。守衛腳本會依以下定位順序尋找設定檔: `$GUARDRAILS_CONF` 環境變數 → `$HOME/.claude/guardrails.conf` → repo 上層 `../guardrails.conf` → hook 同目錄 `guardrails.conf`。