Skip to main content

ClawSouls Plugin for Claude Code

The ClawSouls plugin brings Soul Spec v0.5 persona management to Claude Code. Load personas from the registry, verify safety, manage persistent memory, and connect via Telegram or Discord.

Installation

No marketplace registration needed:

# Clone the plugin
git clone https://github.com/clawsouls/clawsouls-claude-code-plugin.git ~/.claude/clawsouls-plugin

# Launch Claude Code with the plugin
claude --plugin-dir ~/.claude/clawsouls-plugin

Option B: CLAUDE.md Only (Simplest)

No plugin needed — just the persona:

# Export any soul from the registry
npx clawsouls install clawsouls/brad && npx clawsouls export claude-md > CLAUDE.md

# Or manually combine Soul Spec files
cat SOUL.md IDENTITY.md AGENTS.md > CLAUDE.md

# Claude Code auto-reads CLAUDE.md from project root
claude

Prerequisites

RequirementVersionNotes
Claude Codev2.1.80+Channels require v2.1.80+
Node.js18+For soul-spec-mcp server
Bun1.0+Required for Telegram/Discord channels

Installing Bun

Bun is required for Telegram and Discord channel support. Without it, --channels will appear to work but the bot will not receive messages (no pairing codes).

macOS / Linux:

curl -fsSL https://bun.sh/install | bash
source ~/.zshrc # or ~/.bashrc

Windows (PowerShell):

irm bun.sh/install.ps1 | iex
# Restart your terminal after installation

Verify:

bun --version  # Should show 1.x
Windows users

After installing Bun on Windows, you must restart your terminal (or open a new PowerShell/Git Bash window) before launching Claude Code with --channels. If Bun is not in PATH when Claude Code starts, the Telegram plugin will silently fail to receive messages.

Commands

CommandWhat it does
/clawsouls:load-soulDownload and install a soul from the registry
/clawsouls:activateApply the current soul to the session
/clawsouls:browseSearch personas by keyword or category
/clawsouls:scanSafety verification — 53 patterns, A+ to F grade
/clawsouls:exportPackage current persona as Soul Spec directory
/clawsouls:rollbackCompare current vs. baseline persona, detect drift
/clawsouls:memorySearch, read, write, and manage memory files
/clawsouls:migrateMigrate from OpenClaw — auto-scan, preview, confirm, execute

Quick Start

# Load a persona from the registry
/clawsouls:load-soul clawsouls/brad

# Activate the persona
/clawsouls:activate

# Verify safety
/clawsouls:scan

# Search memory
/clawsouls:memory search "SDK version fix"

# Browse the registry
/clawsouls:browse coding assistant

Telegram Integration

Connect Claude Code to Telegram for mobile access. Your agent responds from Telegram while Claude Code runs in the background.

Setup

  1. Create a Telegram bot: Open @BotFather/newbot → copy the token

  2. Install the Telegram channel plugin:

    /plugin install telegram@claude-plugins-official
    /telegram:configure <YOUR_BOT_TOKEN>
  3. Restart with both plugins:

    claude --plugin-dir ~/.claude/clawsouls-plugin \
    --channels plugin:telegram@claude-plugins-official
  4. Pair your account: Send any message to your bot → receive a pairing code → in Claude Code:

    /telegram:access pair <CODE>
    /telegram:access policy allowlist
  5. Activate your persona:

    /clawsouls:activate

Always-On (Background)

# Run in tmux for persistent sessions
tmux new-session -d -s agent \
'claude --plugin-dir ~/.claude/clawsouls-plugin \
--channels plugin:telegram@claude-plugins-official'

MCP Tools

The plugin connects soul-spec-mcp v0.5.0, providing 12 tools:

Persona Management

ToolDescription
search_soulsSearch personas by keyword, category, or tag
get_soulGet detailed info about a specific persona
install_soulDownload and save original Soul Spec files locally
preview_soulPreview before installing
apply_personaApply to current session (temporary, no file save)
list_categoriesList available persona categories

Safety & Integrity

ToolDescription
soul_scanSoulScan — verify against 53 safety patterns (A+ to F)
soul_rollback_checkCompare current vs. baseline files, detect drift

Memory

ToolDescription
memory_searchHybrid TF-IDF + semantic search (auto-detects Ollama for bge-m3 embeddings; enhanced + mode params)
memory_getFetch specific memory file content by line range
memory_statusFile inventory, sizes, last modified dates, git status
memory_syncMulti-agent Git sync (init / push / pull / status)

Memory System

The plugin maintains persistent context across sessions using an OpenClaw-compatible memory layout. Claude Code has direct filesystem access, so the agent reads and writes memory files like any other file — no special API required.

How It Works

Session Start                    During Session                    Session End
│ │ │
▼ ▼ ▼
Read MEMORY.md Write new knowledge to SessionEnd hook
+ memory/*.md memory/YYYY-MM-DD.md flushes unsaved
(via SessionStart hook) or memory/topic-*.md context to files

Key concept: In OpenClaw/SoulClaw, the framework manages memory automatically (passive memory extraction, auto-compaction). In Claude Code, memory is instruction-driven — the agent follows rules in CLAUDE.md to decide when and what to save, assisted by plugin hooks.

File Layout

project/
├── CLAUDE.md # Agent instructions (includes memory rules)
├── SOUL.md # Persona definition (personality, principles)
├── IDENTITY.md # Agent identity (name, creature type, vibe)
├── AGENTS.md # Workflow rules, work style, safety
├── MEMORY.md # Curated long-term knowledge (index)
├── memory/
│ ├── topic-*.md # Topic-specific context (Status/Decisions/History)
│ ├── topic-map.json # DAG: topic relationships (status/depends/related)
│ ├── YYYY-MM-DD.md # Daily session logs
│ └── archive/ # Compacted old session logs

Topic DAG (topic-map.json)

Track relationships between memory topics for faster navigation:

{
"topics": {
"my-project": {
"file": "topic-my-project.md",
"status": "active",
"depends": ["infrastructure"],
"related": ["marketing", "business"]
}
}
}
FieldDescription
statusactive or paused — controls Tier 2 loading
dependsTopics that must be read first for context
relatedTopics to check when working in this area

The agent uses this DAG during Tier 3 to find related context without scanning all files.

CLAUDE.md Configuration Template

Add these sections to your CLAUDE.md so the agent maintains memory autonomously. Without these rules, the agent won't know to persist knowledge across sessions.

4-Tier Session Bootstrap

## Session Start Protocol (4-Tier Bootstrap)

### Tier 1 — Always (every session)
1. Load persona: SOUL.md → IDENTITY.md → AGENTS.md
2. Read MEMORY.md (index)
3. Current date/time

### Tier 2 — First Response
4. Read most recent memory/YYYY-MM-DD.md (daily log)
5. Read active topic files (memory/topic-*.md)
6. `/clawsouls:memory search` — restore recent context

### Tier 3 — On Demand
7. Search related topic files (via topic-map.json)
8. Archive memory (memory/archive/) — only for old context
9. External docs — only when relevant

### Tier 4 — Background
10. Channel integrations (Slack, Telegram bridges)

This mirrors the Soul Memory 4-tier architecture (T0–T3) at the session level.

Memory Rules

## Memory Rules
- Follow 4-Tier Bootstrap Protocol above
- Important decisions/discoveries → memory/YYYY-MM-DD.md (daily log)
- Long-running project context → memory/topic-<project>.md
- Long-term knowledge → promote to MEMORY.md
- Topic files: History max 30 lines, Decisions max 50 lines
- Use `/clawsouls:memory search` for hybrid semantic search
- Search before answering questions about past context

### Auto-Promotion Rules
- 3+ times referenced → promote to MEMORY.md
- User says "remember this" → immediate promotion
- Cost/contract/legal decisions → always promote
- Project status changes → update topic-map.json

### Compact Mode (context pressure)
- Before compaction: save key facts to daily log
- Use PreCompact hook for automatic reminders
- Restore order: MEMORY.md → recent daily log → topic files

What Gets Saved and When

TriggerWhat the agent writesWhere
Important decision madeDecision record with rationalememory/topic-*.md
Bug fix or root cause foundProblem → cause → solutionmemory/YYYY-MM-DD.md
Session ending / context fullKey facts promotedMEMORY.md
User says "remember this"Exact instructionAppropriate file
New contact, credential location, or rulePermanent referenceMEMORY.md

Automatic Memory via Hooks

Plugin hooks provide automatic triggers at key moments:

HookTypeWhenAction
SessionStartpromptSession opensReads SOUL.md, injects memory context
PreCompactagentBefore compactionSaves unsaved context to memory files
PostCompactpromptAfter compactionReloads SOUL.md + memory
FileChangedpromptSOUL.md/IDENTITY.md modifiedAlerts persona drift
SessionEndagentSession closesFlushes remaining context to files
HeartbeatpromptPeriodic (configurable)Self-check: channels, tasks, memory save, blockers

Migrating Memory from OpenClaw

The file layout is identical — just copy:

cp ~/.openclaw/workspace/MEMORY.md ./
cp -r ~/.openclaw/workspace/memory/ ./memory/

All prior knowledge is immediately available. The agent picks up where it left off, and memory_search indexes the files automatically.

OpenClaw vs Claude Code Memory Comparison

AspectOpenClaw/SoulClawClaude Code + Plugin
Memory creationFramework auto-extracts (passive memory)Agent writes files per CLAUDE.md rules
CompactionAutomatic on context overflowPreCompact hook + agent judgment
Searchbge-m3 semantic + hybridTF-IDF/BM25 (hybrid with Ollama)
SyncSingle machineGit-based multi-device (memory_sync)
File formatMarkdown filesSame markdown files (100% compatible)
CostAPI pay-as-you-go$0 within Claude subscription

Memory Search (Hybrid)

The search engine auto-detects your environment:

ModeWhenHow
🧠 HybridOllama running with bge-m30.4× TF-IDF + 0.6× semantic (cosine similarity)
📝 FTSNo OllamaTF-IDF + BM25 (zero dependencies)

Both modes include:

  • BM25 term frequency saturation
  • Korean + English tokenization
  • Recency boost (7 days: 1.3×, 30 days: 1.1×)
/clawsouls:memory search "trademark filing"

To force a specific mode, use the mode parameter when calling the MCP tool:

ModeDescription
autoDefault — uses hybrid if Ollama available, FTS otherwise
ftsForce TF-IDF only (no embeddings)
hybridForce semantic + TF-IDF (requires Ollama + bge-m3)

Use enhanced=true for full snippets with score visualization (uses more tokens).

Ollama setup (optional, for hybrid mode):

# Install Ollama and pull bge-m3
ollama pull bge-m3
# soul-spec-mcp auto-detects at localhost:11434

Soul File Locations

The plugin checks these locations in priority order:

  1. ./SOUL.md — Project-local (highest priority)
  2. ~/.clawsouls/active/current/SOUL.md — Global active soul (symlink)

When you run /clawsouls:load-soul owner/name, files are saved to ~/.clawsouls/active/owner/name/ and current is updated to point there.

SoulScan

Analyzes persona files against 53 safety patterns:

  • Prompt injection detection
  • Safety boundary verification
  • Identity consistency checks
  • Permission escalation detection
/clawsouls:scan                      # Active soul
/clawsouls:scan clawsouls/brad # Registry soul
/clawsouls:scan ./my-agent/ # Local directory

Troubleshooting

Telegram bot doesn't respond

  1. Missing --channels flag: Must use claude --channels plugin:telegram@...
  2. Bun not in PATH: Run curl -fsSL https://bun.sh/install | bash, then source ~/.zshrc
  3. Token not configured: Run /telegram:configure <TOKEN> or save to ~/.claude/channels/telegram/.env
  4. Another process consuming updates: If you called getUpdates via curl, clear with:
    curl "https://api.telegram.org/bot<TOKEN>/getUpdates?offset=-1"

Plugin commands not showing

Ensure you're using --plugin-dir:

claude --plugin-dir ~/.claude/clawsouls-plugin

CLAUDE.md conflicts with loaded soul

If both CLAUDE.md and a loaded soul exist, Claude receives conflicting instructions. Choose one approach:

  • Remove CLAUDE.md and use /clawsouls:activate only
  • Or keep CLAUDE.md as the sole persona source

MCP server fails

# Test manually
npx soul-spec-mcp@latest

# Remote fallback (edit .mcp.json in plugin dir)
{
"mcpServers": {
"soul-spec": {
"type": "url",
"url": "https://soul-change-production.up.railway.app/mcp"
}
}
}

Cross-Platform

The same persona and MCP server work across platforms:

PlatformIntegration
Claude CodeThis plugin — /clawsouls:* commands
OpenClaw / SoulClawNative Soul Spec support
Cursor.cursor/rules/ + .mcp.json
Windsurf.windsurfrules + .mcp.json
Any MCP clientnpx soul-spec-mcp@latest