| name | clawbrain |
| description | Claw Brain - Personal AI Memory System for ClawDBot. Provides memory, personality, bonding, and learning capabilities. |
| metadata | {"clawdbot":{"emoji":"🧠","requires":{"files":["clawbrain.py"]},"install":[{"id":"git","kind":"git","url":"https://github.com/clawcolab/clawbrain.git","label":"Install Claw Brain (git)"}]}} |
Claw Brain Skill 🧠
Personal AI Memory System with Soul, Bonding, and Learning for ClawDBot.
Features
- 🎭 Soul/Personality - 6 evolving traits (humor, empathy, curiosity, creativity, helpfulness, honesty)
- 👤 User Profile - Learns user preferences, interests, communication style
- 💭 Conversation State - Real-time mood detection and context tracking
- 📚 Learning Insights - Continuously learns from interactions and corrections
- 🧠 get_full_context() - Everything for personalized responses
Installation
Option 1: Git Clone (Recommended for ClawDBot)
git clone https://github.com/clawcolab/clawbrain.git ClawBrain
Option 2: pip install
pip install git+https://github.com/clawcolab/clawbrain.git
ClawDBot Setup
1. Install the Skill
cd /path/to/your/clawdbot
git clone https://github.com/clawcolab/clawbrain.git ClawBrain
2. Import in Your Bot
Add to your bot's main file (e.g., main.py):
import sys
sys.path.insert(0, "ClawBrain")
from clawbrain import Brain
brain = Brain()
app.brain = brain
3. Use in Message Handlers
def handle_message(message, channel="telegram"):
context = app.brain.get_full_context(
session_key=f"{channel}_{message.chat.id}",
user_id=str(message.chat.id),
agent_id="jarvis",
message=message.text
)
response = generate_response(context)
app.brain.remember(
agent_id="jarvis",
memory_type="conversation",
content=message.text,
key=f"last_message_{message.chat.id}"
)
return response
Configuration
Environment Variables
export POSTGRES_HOST=192.168.4.176
export POSTGRES_PORT=5432
export POSTGRES_DB=clawcolab
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=postgres
export REDIS_HOST=192.168.4.175
export REDIS_PORT=6379
Force Storage Backend
brain = Brain({"storage_backend": "sqlite"})
brain = Brain({"storage_backend": "postgresql"})
brain = Brain()
API Reference
Brain Class
from clawbrain import Brain
brain = Brain()
Methods
| Method | Description | Returns |
|---|
get_full_context() | Get all context for personalized responses | dict |
remember() | Store a memory | None |
recall() | Retrieve memories | List[Memory] |
learn_user_preference() | Learn user preferences | None |
get_user_profile() | Get user profile | UserProfile |
detect_user_mood() | Detect current mood | dict |
detect_user_intent() | Detect message intent | str |
generate_personality_prompt() | Generate personality guidance | str |
health_check() | Check backend connections | dict |
close() | Close connections | None |
get_full_context()
context = brain.get_full_context(
session_key="telegram_12345",
user_id="username",
agent_id="jarvis",
message="Hey, how's it going?"
)
Returns:
{
"user_profile": {...},
"mood": {"mood": "happy", ...},
"intent": "question",
"memories": [...],
"personality": "...",
"suggested_responses": [...]
}
detect_user_mood()
mood = brain.detect_user_mood("I'm so excited about this!")
detect_user_intent()
intent = brain.detect_user_intent("How does AI work?")
intent = brain.detect_user_intent("Set a reminder for 3pm")
intent = brain.detect_user_intent("I had a great day today")
Example: Full Integration
import sys
sys.path.insert(0, "ClawBrain")
from clawbrain import Brain
class JarvisBot:
def __init__(self):
self.brain = Brain()
def handle_message(self, message, chat_id):
context = self.brain.get_full_context(
session_key=f"telegram_{chat_id}",
user_id=str(chat_id),
agent_id="jarvis",
message=message
)
response = self.generate_response(context)
self.brain.learn_user_preference(
user_id=str(chat_id),
pref_type="interest",
value="AI"
)
return response
def generate_response(self, context):
name = context["user_profile"].name or "there"
mood = context["mood"]["mood"]
if mood == "frustrated":
return f"Hey {name}, I'm here to help. Let me assist you."
:
():
.brain.close()
Storage Backends
SQLite (Default - Zero Setup)
No configuration needed. Data stored in local SQLite database.
brain = Brain({"storage_backend": "sqlite"})
Best for: Development, testing, single-user deployments
PostgreSQL + Redis (Production)
Requires PostgreSQL and Redis servers.
brain = Brain()
Requirements:
- PostgreSQL 14+
- Redis 6+
- Python packages:
psycopg2-binary, redis
pip install psycopg2-binary redis
Best for: Production, multi-user, high-concurrency
Files
clawbrain.py - Main Brain class with all features
__init__.py - Module exports
SKILL.md - This documentation
skill.json - ClawdHub metadata
README.md - Quick start guide
Troubleshooting
ImportError: No module named 'clawbrain'
sys.path.insert(0, "ClawBrain")
PostgreSQL connection failed
echo $POSTGRES_HOST
echo $POSTGRES_PORT
pg_isready -h $POSTGRES_HOST -p $POSTGRES_PORT
Redis connection failed
redis-cli ping
Using SQLite (fallback)
If PostgreSQL/Redis are unavailable, Claw Brain automatically falls back to SQLite:
brain = Brain({"storage_backend": "sqlite"})
Learn More