skills$openclaw/clawbrain
clawcolab5.1kā˜…

by clawcolab

clawbrain – OpenClaw Skill

clawbrain is an OpenClaw Skills integration for coding workflows. Claw Brain - Personal AI Memory System for ClawDBot. Provides memory, personality, bonding, and learning capabilities.

5.1k stars1.1k forksSecurity L1
Updated Feb 7, 2026Created Feb 7, 2026coding

Skill Snapshot

nameclawbrain
descriptionClaw Brain - Personal AI Memory System for ClawDBot. Provides memory, personality, bonding, and learning capabilities. OpenClaw Skills integration.
ownerclawcolab
repositoryclawcolab/clawbrain
languageMarkdown
licenseMIT
topics
securityL1
installopenclaw add @clawcolab/clawbrain
last updatedFeb 7, 2026

Maintainer

clawcolab

clawcolab

Maintains clawbrain in the OpenClaw Skills directory.

View GitHub profile
File Explorer
11 files
.
brain
__init__.py
497 B
clawbrain.py
28.9 KB
README.md
1.2 KB
__init__.py
434 B
_meta.json
273 B
clawbrain.py
28.9 KB
pyproject.toml
475 B
README.md
4.4 KB
skill.json
646 B
SKILL.md
7.3 KB
SKILL.md

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

Option 1: Git Clone (Recommended for ClawDBot)

# Clone into ClawDBot workspace
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

# Clone to your ClawDBot workspace
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

# Initialize the brain
brain = Brain()

# Make it available globally or pass to handlers
app.brain = brain

3. Use in Message Handlers

def handle_message(message, channel="telegram"):
    # Get user context
    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
    )
    
    # Generate personalized response
    response = generate_response(context)
    
    # Store conversation
    app.brain.remember(
        agent_id="jarvis",
        memory_type="conversation",
        content=message.text,
        key=f"last_message_{message.chat.id}"
    )
    
    return response

Configuration

Environment Variables

# PostgreSQL (optional - auto-detected)
export POSTGRES_HOST=192.168.4.176
export POSTGRES_PORT=5432
export POSTGRES_DB=clawcolab
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=postgres

# Redis (optional - auto-detected)
export REDIS_HOST=192.168.4.175
export REDIS_PORT=6379

Force Storage Backend

# Force SQLite (zero setup)
brain = Brain({"storage_backend": "sqlite"})

# Force PostgreSQL
brain = Brain({"storage_backend": "postgresql"})

# Auto-detect (default)
brain = Brain()

API Reference

Brain Class

from clawbrain import Brain

brain = Brain()
Methods
MethodDescriptionReturns
get_full_context()Get all context for personalized responsesdict
remember()Store a memoryNone
recall()Retrieve memoriesList[Memory]
learn_user_preference()Learn user preferencesNone
get_user_profile()Get user profileUserProfile
detect_user_mood()Detect current mooddict
detect_user_intent()Detect message intentstr
generate_personality_prompt()Generate personality guidancestr
health_check()Check backend connectionsdict
close()Close connectionsNone

get_full_context()

context = brain.get_full_context(
    session_key="telegram_12345",  # Unique session ID
    user_id="username",              # User identifier
    agent_id="jarvis",             # 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
}

detect_user_mood()

mood = brain.detect_user_mood("I'm so excited about this!")
# Returns: {"mood": "happy", "confidence": 0.9, "emotions": ["joy", "anticipation"]}

detect_user_intent()

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"

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):
        # Get context
        context = self.brain.get_full_context(
            session_key=f"telegram_{chat_id}",
            user_id=str(chat_id),
            agent_id="jarvis",
            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()

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()  # Auto-detects

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'

# Ensure ClawBrain folder is in your path
sys.path.insert(0, "ClawBrain")

PostgreSQL connection failed

# Check environment variables
echo $POSTGRES_HOST
echo $POSTGRES_PORT

# Verify PostgreSQL is running
pg_isready -h $POSTGRES_HOST -p $POSTGRES_PORT

Redis connection failed

# Check Redis is running
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

README.md

Claw Brain 🧠

Personal AI Memory System for AI Agents

A sophisticated memory and learning system that enables truly personalized AI-human communication.

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

Quick Start

pip install git+https://github.com/clawcolab/clawbrain.git
from clawbrain import Brain

brain = Brain()
context = brain.get_full_context(
    session_key="chat_123",
    user_id="pranab",
    agent_id="jarvis",
    message="Hey, how's it going?"
)

Option 1: SQLite (Zero Setup) āœ… Recommended for development

from clawbrain import Brain

# Automatically uses SQLite
brain = Brain({"storage_backend": "sqlite"})

Requirements: Python 3.10+, no external dependencies

Best for:

  • Development and testing
  • Single-user deployments
  • Quick prototyping

Option 2: PostgreSQL + Redis (Production) šŸš€

from clawbrain import Brain

# Auto-detects PostgreSQL and Redis
brain = Brain()

Requirements:

  • PostgreSQL 14+ (port 5432)
  • Redis 6+ (port 6379)
  • Python packages: psycopg2-binary, redis

Install dependencies:

pip install psycopg2-binary redis

Environment variables (optional):

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

Best for:

  • Production deployments
  • High-concurrency environments
  • Distributed AI agents
  • Multi-user platforms

Auto-Detection Order

  1. PostgreSQL (if available)
  2. Redis (if available, used as cache)
  3. SQLite (fallback)

You can also force a specific backend:

brain = Brain({"storage_backend": "postgresql"})  # Force PostgreSQL
brain = Brain({"storage_backend": "sqlite"})      # Force SQLite

Installation Methods

From GitHub (Recommended)

pip install git+https://github.com/clawcolab/clawbrain.git

From Local Development

cd /root/clawd/brain/public_package
pip install -e .

For ClawDBot

# Install as skill
git clone https://github.com/clawcolab/clawbrain.git ClawBrain

Then in your bot:

import sys
sys.path.insert(0, "ClawBrain")
from clawbrain import Brain

brain = Brain()

API Reference

Core Class

from clawbrain import Brain

brain = Brain()

Methods:

MethodDescription
get_full_context()Get all context for personalized responses
remember()Store a memory
recall()Retrieve memories
learn_user_preference()Learn user preferences
get_user_profile()Get user profile
detect_user_mood()Detect current mood
detect_user_intent()Detect message intent
generate_personality_prompt()Generate personality guidance
health_check()Check backend connections
close()Close connections

Data Classes

from clawbrain import Memory, UserProfile

# Memory
memory = Memory(
    id="...",
    agent_id="jarvis",
    memory_type="fact",
    key="job",
    content="User works at Walmart",
    importance=0.8
)

# User Profile
profile = UserProfile(
    user_id="pranab",
    name="Pranab",
    interests=["AI", "crypto"],
    communication_preferences={"style": "casual"}
)

Repository Structure

clawbrain/
ā”œā”€ā”€ clawbrain.py      ← Main module
ā”œā”€ā”€ __init__.py       ← Exports
ā”œā”€ā”€ SKILL.md          ← ClawDBot skill docs
ā”œā”€ā”€ skill.json        ← ClawdHub metadata
└── README.md         ← This file

For ClawDBot

Install as a skill via ClawdHub or manually:

git clone https://github.com/clawcolab/clawbrain.git ClawBrain

Usage in your bot:

import sys
sys.path.insert(0, "ClawBrain")
from clawbrain import Brain

brain = Brain()

# Get context for responses
context = brain.get_full_context(
    session_key=session_id,
    user_id=user_id,
    agent_id=agent_id,
    message=user_message
)

License

MIT

Permissions & Security

Security level L1: Low-risk skills with minimal permissions. Review inputs and outputs before running in production.

Requirements

  • OpenClaw CLI installed and configured.
  • Language: Markdown
  • License: MIT
  • Topics:

Configuration

### Environment Variables ```bash

FAQ

How do I install clawbrain?

Run openclaw add @clawcolab/clawbrain in your terminal. This installs clawbrain into your OpenClaw Skills catalog.

Does this skill run locally or in the cloud?

OpenClaw Skills execute locally by default. Review the SKILL.md and permissions before running any skill.

Where can I verify the source code?

The source repository is available at https://github.com/openclaw/skills/tree/main/skills/clawcolab/clawbrain. Review commits and README documentation before installing.