Claw Brain
Claw Brain - Personal AI Memory System for OpenClaw/ClawDBot. Provides memory, personality, bonding, and learning capabilities with encrypted secrets support...
Claw Brain - Personal AI Memory System for OpenClaw/ClawDBot. Provides memory, personality, bonding, and learning capabilities with encrypted secrets support...
Real data. Real impact.
Emerging
Developers
Per week
Open source
Skills give you superpowers. Install in 30 seconds.
Personal AI Memory System with Soul, Bonding, and Learning for OpenClaw/ClawDBot.
Auto-Refresh on Restart: ClawBrain automatically refreshes memory when the service restarts.
Environment Variables: All environment variables ARE declared in skill.json under
environment.optional (lines 30-55). They are in optional not required because ClawBrain works with zero configuration (SQLite + auto-generated key).
Install Specification: skill.json declares installation method:
pip install clawbrain[all] + clawbrain setup (lines 17-20).
Sudo Requirements: Core installation never needs sudo. Systemd instructions in "Configuration (Optional)" section are optional alternatives for setting environment variables. Core: pip + clawbrain setup (no sudo).
Source Code: Fully auditable at https://github.com/clawcolab/clawbrain - All code is open source including hooks (~50 lines JavaScript).
See SECURITY.md for complete security documentation.
ClawBrain handles sensitive data and requires certain permissions. Before installing, please understand:
~/.openclaw/hooks or ~/.clawdbot/hooks~/.config/clawbrain/.brain_key⚠️ Important: The CLI command
clawbrain show-key --full displays your complete encryption key for backup purposes. Treat this key like a password!
📖 Full Security Documentation: See SECURITY.md for:
Security Note: We recommend reviewing SECURITY.md before installation, especially for production use.
# Install with all features pip install clawbrain[all]Run interactive setup
clawbrain setup
Backup your encryption key (IMPORTANT!)
clawbrain backup-key --all
Restart your service
sudo systemctl restart clawdbot # or openclaw
The setup command will:
# Clone to your skills directory cd ~/.openclaw/skills # or ~/clawd/skills or ~/.clawdbot/skills git clone https://github.com/clawcolab/clawbrain.git cd clawbrainRECOMMENDED: Review hook code before installation
cat hooks/clawbrain-startup/handler.js
Install in development mode
pip install -e .[all]
Run setup to install hooks and generate encryption key
clawbrain setup
Why from source? Full transparency - you can review all code before installation.
Note: Configuration is completely optional. ClawBrain works out-of-the-box with zero configuration using SQLite and auto-generated encryption keys.
If you want to customize agent ID or use PostgreSQL/Redis, you have two options:
Set environment variables in your shell profile:
# Add to ~/.bashrc or ~/.zshrc (no sudo required) export BRAIN_AGENT_ID="your-agent-name" # export BRAIN_POSTGRES_HOST="localhost" # Optional # export BRAIN_REDIS_HOST="localhost" # Optional
⚠️ Only if you use systemd services:
# Create systemd drop-in config (requires sudo) sudo mkdir -p /etc/systemd/system/clawdbot.service.dsudo tee /etc/systemd/system/clawdbot.service.d/brain.conf << EOF [Service] Environment="BRAIN_AGENT_ID=your-agent-name" EOF
sudo systemctl daemon-reload sudo systemctl restart clawdbot
| Variable | Description | Default |
|---|---|---|
| Unique ID for this agent's memories | |
| Fernet key for encrypting sensitive data (auto-generated if not set) | - |
| PostgreSQL host | |
| PostgreSQL password | - |
| PostgreSQL port | |
| PostgreSQL database | |
| PostgreSQL user | |
| Redis host | |
| Redis port | |
| Force storage: , , | |
gateway:startup eventBRAIN_AGENT_ID/new Commandcommand:new eventClawBrain supports encrypting sensitive data like API keys and credentials using Fernet (symmetric encryption).
Security Model:
~/.config/clawbrain/.brain_key (chmod 600)memory_type='secret' are encryptedSetup:
# Run setup to generate encryption key clawbrain setupBackup your key (IMPORTANT!)
clawbrain backup-key --all
Usage:
# Store encrypted secret brain.remember( agent_id="assistant", memory_type="secret", # Memory type 'secret' triggers encryption content="sk-1234567890abcdef", key="openai_api_key" )Retrieve and automatically decrypt
secrets = brain.recall(agent_id="assistant", memory_type="secret") api_key = secrets[0].content # Automatically decrypted
Key Management CLI:
clawbrain show-key # View key info (masked) clawbrain show-key --full # View full key clawbrain backup-key --all # Backup with all methods clawbrain generate-key # Generate new key
⚠️ Important: Backup your encryption key! Lost keys = lost encrypted data.
ClawBrain includes a command-line interface:
| Command | Description |
|---|---|
| Set up ClawBrain, generate key, install hooks |
| Generate new encryption key |
| Display current encryption key |
| Backup key (file, QR, clipboard) |
| Check health status |
| Show installation info |
| Event | Action |
|---|---|
| Initialize brain, refresh memories |
| Save session to memory |
For development or manual installation:
# Clone to your skills directory cd ~/.openclaw/skills # or ~/clawd/skills or ~/.clawdbot/skills git clone https://github.com/clawcolab/clawbrain.git cd clawbrainInstall in development mode
pip install -e .[all]
Run setup
clawbrain setup
For direct Python usage (outside ClawdBot/OpenClaw):
from clawbrain import Brainbrain = Brain()
| Method | Description | Returns |
|---|---|---|
| Get all context for personalized responses | dict |
| Store a memory | None |
| Retrieve memories | List[Memory] |
| Learn user preferences | None |
| Get user profile | UserProfile |
| Detect current mood | dict |
| Detect message intent | str |
| Generate personality guidance | str |
| Check backend connections | dict |
| Close connections | None |
context = brain.get_full_context( session_key="telegram_12345", # Unique session ID user_id="username", # User identifier agent_id="assistant", # Bot identifier message="Hey, how's it going?" # Current message )
Returns:
{ "user_profile": {...}, # User preferences, interests "mood": {"mood": "happy", ...}, # Current mood "intent": "question", # Detected intent "memories": [...], # Relevant memories "personality": "...", # Personality guidance "suggested_responses": [...] # Response suggestions }
mood = brain.detect_user_mood("I'm so excited about this!") # Returns: {"mood": "happy", "confidence": 0.9, "emotions": ["joy", "anticipation"]}
intent = brain.detect_user_intent("How does AI work?") # Returns: "question"intent = brain.detect_user_intent("Set a reminder for 3pm")
Returns: "command"
intent = brain.detect_user_intent("I had a great day today")
Returns: "casual"
import sys sys.path.insert(0, "ClawBrain")from clawbrain import Brain
class AssistantBot: def init(self): self.brain = Brain()
def handle_message(self, message, chat_id): # Get context context = self.brain.get_full_context( session_key=f"telegram_{chat_id}", user_id=str(chat_id), agent_id="assistant", message=message ) # Generate response using context response = self.generate_response(context) # Learn from interaction self.brain.learn_user_preference( user_id=str(chat_id), pref_type="interest", value="AI" ) return response def generate_response(self, context): # Use user preferences name = context["user_profile"].name or "there" mood = context["mood"]["mood"] # Personalized response if mood == "frustrated": return f"Hey {name}, I'm here to help. Let me assist you." else: return f"Hi {name}! How can I help you today?" def shutdown(self): self.brain.close()
No configuration needed. Data stored in local SQLite database.
brain = Brain({"storage_backend": "sqlite"})
Best for: Development, testing, single-user deployments
Requires PostgreSQL and Redis servers.
brain = Brain() # Auto-detects
Requirements:
psycopg2-binary, redispip install psycopg2-binary redis
Best for: Production, multi-user, high-concurrency
clawbrain.py - Main Brain class with all features__init__.py - Module exportsSKILL.md - This documentationskill.json - ClawdHub metadataREADME.md - Quick start guide# Ensure ClawBrain folder is in your path sys.path.insert(0, "ClawBrain")
# Check environment variables echo $POSTGRES_HOST echo $POSTGRES_PORTVerify PostgreSQL is running
pg_isready -h $POSTGRES_HOST -p $POSTGRES_PORT
# Check Redis is running redis-cli ping
If PostgreSQL/Redis are unavailable, Claw Brain automatically falls back to SQLite:
brain = Brain({"storage_backend": "sqlite"})
No automatic installation available. Please visit the source repository for installation instructions.
View Installation Instructions1,500+ AI skills, agents & workflows. Install in 30 seconds. Part of the Torly.ai family.
© 2026 Torly.ai. All rights reserved.