Repository navigation
v0.3.0 — /clear safety: safe restart with auto context recovery
/clear safety — the brain makes /clear a safe restart button
For every other Claude Code user, /clear is destructive — it wipes context to free tokens and you lose continuity. With claude-brain, /clear now becomes a safe restart: the brain captures everything in real-time (already did), and on the first prompt after /clear it automatically restores context so Claude picks up where you left off.
Added
- session-end hook —
/cleartrigger detection. Reads thereasonfield from the SessionEnd stdin JSON. Onreason == "clear", writes aCLEAR_CHECKPOINTmarker to the ended session's notes instead of the generic fallback. Skips the auto-tag suggestion so Claude can write proper tags during post-/clear recovery. - user-prompt-submit hook — post-/clear detection + context recovery. On each prompt, checks if a session in the same project ended < 5 minutes ago with a
CLEAR_CHECKPOINTmarker and a different session_id from the current one. When matched, injects recovery context: the current project summary, the last 10 exchanges (user + assistant) from the ended session, and instructions to write proper notes for the ended session before responding to the user. - Works around upstream bug. Anthropic's
SessionStarthook does NOT fire on/clear(GitHub #34072, open). The UserPromptSubmit-based detection is a workaround that does not depend on the buggy SessionStart trigger, so it works today.
Fixed
- Stale script count in README.md, synced to actual count (25 Python scripts).
Upgrade: cd /your/install/path && git pull