Skip to content

crisandrews/ClawCode

Repository files navigation

ClawCode

ClawCode mascot

Turn Claude Code into a persistent agent — memory, personality, voice, messaging, and more.

Release Stars Clones MIT License Node ≥ 18 Platform

Quick Setup · Why · Features · Skills · Going further · Troubleshooting · Issues

Listed on Anthropic's claude-plugins-community


ClawCode is a plugin for Claude Code. Install it and Claude Code remembers you between sessions: your name, the agent's own name and personality, the notes you and the agent wrote together last week. It adds memory with bilingual recall (Spanish ↔ English), messaging through WhatsApp, Telegram, Discord, iMessage and Slack, a browser chat, nightly memory consolidation, and a background service for 24/7 runs. Everything lives inside Claude Code's plugin system.

The agent remembers your dog's name, warns about allergies before suggesting food, and answers in 1 to 2 lines instead of paragraphs.

Claude Code is stateless by default. Open a new session and the agent starts from zero: no memory of what you were working on yesterday, no name, no feel for who it is. Good agents should not do that. That gap is what ClawCode fills.

There are roughly two ways to build persistence on top of Claude. One is a harness: a separate runtime that wraps Claude's API with its own session, memory, and tool layer. OpenClaw is one example. Harnesses run on Claude's API directly; as of April 2026 they can no longer draw from a Claude subscription, so users need to pay for API usage separately.

ClawCode takes the other route. It extends Claude Code from inside as a plugin, so there's no separate runtime and no separate billing. A ClawCode user is just a Claude Code user with an extra layer on top. ClawCode inherits what Claude Code already does well (its harness, tool system, skills, hooks, MCP plumbing) and adds only what a persistent agent needs.

Coming from OpenClaw? /agent:import brings your agent's personality, memory, skills, and crons across.

  • Persistent identity — name, personality, emoji. The agent wakes up as itself on every session via lifecycle hooks that inject SOUL.md + IDENTITY.md at startup.
  • Messaging channels — WhatsApp, Telegram, Discord, iMessage, Slack via MCP plugins. Same agent, every channel, no conflicts.
  • Active memory — bilingual recall (ES ↔ EN) at the start of every turn. Ask "cómo se llama mi perro?" and it finds "Cookie" from English notes. Warns about allergies before suggesting food.
  • Lifecycle hooks — SessionStart injects identity + auto-creates crons. PreCompact flushes memory before context compression. Stop writes session summaries. SessionEnd tracks dream events.
  • Dreaming — nightly 3-phase consolidation (Light → REM → Deep) with 6 weighted signals. Promotes important memories to long-term storage.
  • Language adaptation — detects the user's language and responds in kind. Switch mid-conversation and the agent switches too. Commands, status cards, and errors all adapt.
  • Voice — TTS via sag, ElevenLabs, OpenAI, macOS say. STT via local Whisper or OpenAI API.
  • WebChat — browser chat UI with SSE real-time delivery. Conversation logs in JSONL + Markdown (same format as WhatsApp).
  • Slash commands everywhere/status, /help, /whoami, /new, /compact work from CLI, WhatsApp, Telegram, Discord — same commands, formatting adapts per platform.
  • Smart import from OpenClaw — 3-tier classifier (GREEN/YELLOW/RED) for skills and crons. Step-by-step wizard with clickable options. Skipped items go to a backlog with recovery notes.
  • Community skills — install from GitHub with owner/repo@branch#subdir. OS + dependency validation.
  • Always-on — launchd / systemd service. Enables dreaming + heartbeat 24/7.
  • Webhooks — external systems (Cloudflare Workers, GitHub Actions, CI/CD, IoT) can POST events to the agent via HTTP. The agent processes them like any other message.
  • Channel scope — opt-in per-channel privacy layer. When you pair WhatsApp, you can choose: agent acts as owner (sees all chats), guest (sees nothing channel-derived), or auto (owner-only ceiling). Default is off — zero behavior change for users who don't opt in.
  • Execution gate — opt-in guardrail (companion to channel scope). When the current Claude Code turn was triggered by a non-owner message in a paired group chat, blocks destructive tools (Bash, Write, Edit, Task, and more) per a denylist/allowlist policy. Always-on protected paths fire even with the gate off — agent cannot self-modify hooks, agent-config, SSH/credential dirs, shell init, or persistence mechanisms. Default off.
  • Doctor — 9+ health checks (config, identity, memory, SQLite, QMD, bootstrap, HTTP, messaging, dreaming, scope). --fix auto-repairs safe issues.
  • Terse by design — the agent acts, doesn't narrate. Confirmations in 1-2 lines, no preambles, no recaps.
  • Node.js v18+
  • Windows: Claude Code must be run from inside WSL2 (not native PowerShell / cmd).

1. Create a folder for your agent.

Each agent lives in its own folder. Create one and open Claude Code there:

mkdir ~/my-agent && cd ~/my-agent
claude

2. Install the plugin.

Inside Claude Code, add Anthropic's official community marketplace:

/plugin marketplace add anthropics/claude-plugins-community

Then install the plugin:

/plugin install clawcode@claude-community

When prompted for scope, select "Install for you, in this repo only (local scope)" — this keeps the agent isolated to this folder.

Then reload plugins so the skills become available:

/reload-plugins

Bleeding-edge alternative. The community marketplace syncs nightly from Anthropic's review pipeline, so brand-new fixes can take up to ~24h to land. If you want the absolute latest commit, install from this repo's marketplace instead — same plugin, different identifier. Run them one at a time:

/plugin marketplace add crisandrews/ClawCode
/plugin install agent@clawcode

3. Create your agent:

/agent:create

This starts the bootstrap ritual — a casual conversation where the agent discovers its name, personality, and emoji. You can also import an existing agent instead:

/agent:import

4. Reload to apply the personality:

/mcp

The agent now wakes up with its identity on every session.

ClawCode injects personality and behavior at four points in the session lifecycle:

Hook When What happens
SessionStart Session opens Reads SOUL.md + IDENTITY.md + USER.md and injects them as context. Checks if heartbeat + dreaming crons exist — creates them if missing.
PreCompact Context getting full Reminds agent to save important facts to memory/YYYY-MM-DD.md before compression erases them.
Stop Session closing Reminds agent to write a session summary (what was discussed, decisions, open items).
SessionEnd Session closed Logs a session.end event for the dreaming system.

This means:

  • Every session starts with personality — the agent never says "I'm Claude." It knows its name, vibe, and your info.
  • Memory survives compaction — PreCompact flushes facts before they're lost.
  • Sessions are summarized — the next session knows what happened in the last one.
  • Dreaming tracks sessions — knows when you were active, when you paused.

The agent also detects your language from each message and responds in kind. Switch from Spanish to English mid-conversation — the agent switches too. Status cards, error messages, and commands all adapt.

Full details: docs/hooks.md

The agent writes to memory/YYYY-MM-DD.md during sessions and searches it automatically at the start of every turn — no need to say "search memory." Bilingual (Spanish ↔ English, 40+ synonym pairs), date-aware ("hoy" resolves to today's date), and safety-critical (warns about allergies before suggesting food). Trivial messages (greetings, "ok", slash commands) skip the search — no wasted context.

Two backends: builtin (SQLite + FTS5, works out of the box) and QMD (local embeddings for semantic search — install with bun install -g qmd).

Full details: docs/memory.md · docs/memory-context.md · docs/qmd.md

Nightly cron (3 AM) runs 3-phase memory consolidation:

  • Light — ingests recall signals from the day, deduplicates candidates
  • REM — extracts recurring themes, identifies multi-day patterns, writes reflections to DREAMS.md
  • Deep — ranks candidates with 6 weighted signals (relevance 0.30, frequency 0.24, query diversity 0.15, recency 0.15, consolidation 0.10, conceptual richness 0.06) and promotes winners to memory/MEMORY.md

Run manually: dream(action='run') or preview with dream(action='dry-run').

Full details: docs/dreaming.md

TTS via sag, ElevenLabs, OpenAI, or macOS say. STT via local Whisper or OpenAI Whisper API. The agent auto-selects the best available backend. Enable with agent_config(action='set', key='voice.enabled', value='true').

Full details: docs/voice.md

Browser-based chat UI with real-time SSE delivery. Enable the HTTP bridge, open http://localhost:18790. Dark/light mode, conversation logging in JSONL + Markdown (same format as WhatsApp plugin).

agent_config(action='set', key='http.enabled', value='true')
/mcp

Every browser tab gets its own sessionId (UUID v4, persisted in localStorage) that partitions per-session chat history and live agent replies — two browsers sharing the same http.token cannot read each other's conversations. sessionId is a privacy partition; http.token remains the auth boundary.

Full details: docs/webchat.md · docs/http-bridge.md

Reach your agent from WhatsApp, Telegram, Discord, iMessage, or Slack. Each messaging plugin is an independent MCP server — no conflicts with ClawCode.

/agent:messaging

Slash commands work from any channel — /status, /help, /whoami, /new, /compact all respond whether the user is in the CLI terminal or chatting via WhatsApp. Formatting adapts automatically (*bold* for WhatsApp, **bold** for Telegram, standard markdown for CLI).

Full details: docs/channels.md

When the agent indexes messaging-channel logs into its memory (WhatsApp via claude-whatsapp), it can apply per-channel scope filtering so the agent only sees what the operator is allowed to see — mirroring the upstream plugin's own access governance.

Default is off. Users who don't opt in see no behavior change.

To opt in:

/agent:scope wizard

The wizard walks through: which channel, mode (shadow = log only, enforce = filter), and identity (owner = sees all, guest = sees nothing channel-derived, auto = owner-only ceiling). owner mode requires an out-of-band trust file you create via Bash — the agent cannot grant itself owner privileges.

Important caveats:

  • MCP scope is not a filesystem sandbox. Native Read, Grep, or direct SQLite over channel log files always bypass the scope filter by design. Hard isolation lives at the OS/filesystem layer.
  • The filter covers MCP tools (memory_search, memory_get, memory_context, dream, voice_transcribe, chat_inbox_read).
  • A separate per-chat indexer reads upstream messages.db read-only and stores chat-id columns locally so per-chat allowlists work.
  • Trust files are per-workspace. As of 1.7.0 the trust file lives under ~/.claude/agent/scope-trust/<workspace-fingerprint>/<channel>-<suffix>, keyed by a fingerprint of the workspace path. Granting trust in workspace A does NOT unlock workspace B — open each workspace and run the wizard to grant trust there. Upgrading from 1.5/1.6: legacy global files are ignored; doctor surfaces them with a cleanup command.

Execution gate (independent opt-in, layered on top of read scope) — same wizard adds a separate question that activates a PreToolUse gate. When the current turn was triggered by a non-owner message in a paired channel, destructive tools (Bash, Write, Edit, Task, etc.) are blocked per a denylist (recommended) or allowlist policy. Shadow mode logs would-block decisions for review; enforce mode blocks them outright. Always-on protected paths refuse MCP writes to plugin internals, agent-config, scope-trust dir, SSH/credential dirs, shell init files, and persistence mechanisms — even with the gate off, so the agent cannot self-modify the gate. A separate per-workspace <channel>-exec trust file (created via Bash) unlocks the gate for a trusted machine without disabling read scope.

Full details: docs/channel-scope-compat.md · PRIVACY.md

Have an existing OpenClaw agent? /agent:import brings it into Claude Code with a step-by-step wizard (clickable options, one question at a time):

  1. Bootstrap files — copies SOUL.md, IDENTITY.md, USER.md, AGENTS.md, TOOLS.md, HEARTBEAT.md
  2. Memory — imports MEMORY.md + recent daily logs (credentials are never copied)
  3. Memory backend — asks: QMD (semantic search) or builtin (SQLite + FTS5)?
  4. Skills — classifies each skill as GREEN (portable), YELLOW (needs adaptation), or RED (incompatible). You choose: all, specific ones, or skip.
  5. Crons — same 3-tier classification for scheduled tasks. Prompts are adapted for Claude Code tools.
  6. Messaging — offers WhatsApp, Telegram, Discord, iMessage setup.

Files are copied clean — no annotations, no comments. Adaptation details go to IMPORT_BACKLOG.md so the user can revisit skipped items later. The import event is logged to memory so the agent remembers what was imported.

External systems can send events to the agent via POST /v1/webhook (requires HTTP bridge enabled). The agent queues them and processes on the next turn.

Use cases:

  • Email catch-all — Cloudflare Email Worker forwards every incoming email to the agent in real-time
  • Gmail push — Gmail notifies the agent via Pub/Sub when new emails arrive
  • CI/CD — GitHub Actions sends build results → agent summarizes and notifies via WhatsApp
  • Scheduled tasks — Cloudflare Workers trigger agent actions on a cron schedule
  • Monitoring — uptime checker sends alert → agent investigates and reports
  • IoT — sensor data arrives → agent logs to memory and acts on thresholds
curl -X POST http://localhost:18790/v1/webhook \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-token" \
  -d '{"event": "deploy", "status": "success", "repo": "my-app"}'

Security: when the bridge is exposed to the network (host: "0.0.0.0"), a token is required — the bridge refuses to start without one.

Queue holds up to 1000 events. Drain with GET /v1/webhooks or the chat_inbox_read MCP tool.

Full details: docs/http-bridge.md

/agent:doctor runs 11 health checks: config validity, identity files, memory directory, SQLite integrity, QMD availability, bootstrap state, HTTP bridge, messaging plugins, dreaming, cron registry, jq availability. Returns a ✅/⚠️/❌ card. Use --fix to auto-repair safe issues (create missing memory/, reindex SQLite, remove stale BOOTSTRAP.md).

Full details: docs/doctor.md

Reminders (heartbeat, dreaming, imports, and ad-hoc "remind me in 2h") survive session closes. ClawCode maintains a registry at memory/crons.json and reconciles it against the live harness on every SessionStart: anything missing gets recreated, anything live-but-unknown gets adopted. PostToolUse captures ad-hoc CronCreate/CronDelete automatically — you don't need a special command for "remind me".

Manage reminders through /agent:crons (aliases /agent:reminders, list reminders, recordatorios):

/agent:crons list                       # ✅⚠️⏸ status table
/agent:crons add "0 9 * * *" "email"    # add a reminder
/agent:crons delete 3                   # remove with AskUserQuestion confirm
/agent:crons pause heartbeat-default    # pause without deleting
/agent:crons reconcile                  # force sync
/agent:crons import                     # bring OpenClaw crons into the registry

Full details: docs/crons.md

Skill Description
/agent:create Create a new agent with bootstrap ritual
/agent:import [id] Import an existing agent (personality + memory + skills + crons)
/agent:doctor [--fix] Diagnose agent health. --fix applies safe auto-repairs
/agent:settings View/modify agent config (guided)
/agent:scope Channel-scope opt-in: wizard, status, enable, disable, audit, test
/agent:skill install|list|remove Install community skills from GitHub
/agent:channels Messaging channel status and launch command
/agent:service install|status|uninstall|logs Always-on background service
/agent:voice status|setup TTS / STT backends
/agent:messaging Set up WhatsApp, Telegram, Discord, iMessage, Slack
/agent:crons / /agent:reminders Manage reminders: list, add, delete, pause, reconcile, import
/agent:heartbeat Memory consolidation and periodic checks
/agent:update Check for new Claude Code / ClawCode releases and print safe update commands
/agent:status Agent status dashboard
/agent:usage Resource usage
/agent:new Save session and prepare for /clear
/agent:compact Save context before compression
/whoami Sender info and agent identity
/help List all available commands (dynamic)

Install skills from GitHub:

/agent:skill install alice/pomodoro
/agent:skill install alice/skills@main#weather
/agent:skill list
/agent:skill remove pomodoro

Full details: docs/skill-manager.md

Run the agent as a background service (launchd on macOS, systemd on Linux):

/agent:service install
/agent:service status
/agent:service logs

The service defaults are tuned for 24/7 daemon use: PTY wrap so lifecycle hooks survive graceful shutdown, crash-loop guard, persistent logs under ~/.clawcode/logs/, a resume-on-restart wrapper so the agent rehydrates its last conversation after a restart, and a self-heal sidecar that recovers from stuck deferred-tool loops automatically. Full details in docs/service.md.

Optional companion: docs/watchdog.md — opt-in external health probe + auto-restart for always-on services.

Run /agent:update to check whether Claude Code or ClawCode has a newer release available. The skill compares installed versions against npm and the upstream git tags, prints the safe update commands for each, and never applies them itself. The heartbeat cron does the same check once per UTC day with per-version dedupe, so a new release pings you once and then stays quiet.

All settings in agent-config.json. Edit directly or use agent_config:

agent_config(action='get')
agent_config(action='set', key='memory.backend', value='qmd')

Non-critical settings apply live. Critical settings need /mcp — the agent tells you which.

Full details: docs/config-reload.md

Update to the latest version. Use the command set that matches how you installed. Run each line one at a time — Claude Code's slash commands don't batch.

If you installed from the community marketplace (clawcode@claude-community):

/plugin marketplace update anthropics/claude-plugins-community
/plugin update clawcode@claude-community
/reload-plugins

If you installed from this repo's marketplace (agent@clawcode):

/plugin marketplace update crisandrews/ClawCode
/plugin update agent@clawcode
/reload-plugins

If /plugin update says "already at latest version" but you know there's a new one, use the manual method: type /plugin, find your installed plugin in the list, press Enter, and select Update.

Your personality, memory, skills, and config are preserved — only the plugin code updates. No data loss.

Uninstall:

/plugin uninstall clawcode@claude-community   # if installed from community marketplace
/plugin uninstall agent@clawcode              # if installed from this repo's marketplace

Your agent files (SOUL.md, IDENTITY.md, memory/, skills/) stay in the folder — they're yours. Only the plugin code is removed.

Clear cache (if reinstall fails or behaves unexpectedly). The cache path depends on which marketplace you installed from. Close Claude, then in terminal:

rm -rf ~/.claude/plugins/cache/claude-community/clawcode   # community marketplace install
rm -rf ~/.claude/plugins/cache/clawcode                    # own marketplace install

Reopen Claude and install again.

Each agent is its own folder with its own personality, memory, and config:

~/agent-work/      ← Agent #1
~/agent-personal/  ← Agent #2

Install the plugin in each folder with local scope. Switch: cd ~/other-agent && claude.

Every agent has these files in its root. They're injected as context at session start via the SessionStart hook.

File What it defines
SOUL.md Core truths, boundaries, philosophy — the agent's deepest identity
IDENTITY.md Name, emoji, creature type, vibe, birth date
USER.md Your info: name, timezone, language, preferences
AGENTS.md Operational rules, safety boundaries, local skill triggers
TOOLS.md Platform-specific formatting (WhatsApp uses *bold*, Telegram uses **bold**)
HEARTBEAT.md What to check every 30 min (review daily logs, consolidate memory)
BOOTSTRAP.md First-run ritual (deleted after onboarding)

The agent never says "I'm Claude" — it uses its name from IDENTITY.md. Even when asked directly "are you Claude?", it answers: "I'm [name] — built on Claude, but with my own memory, personality, and name."

~/my-agent/
├── SOUL.md, IDENTITY.md, USER.md     # Agent personality
├── AGENTS.md, TOOLS.md, HEARTBEAT.md # Behavioral rules
├── agent-config.json                 # Settings
├── memory/
│   ├── MEMORY.md                     # Long-term curated memory
│   ├── YYYY-MM-DD.md                 # Daily logs (append-only)
│   ├── .memory.sqlite                # Search index (auto-generated)
│   └── .dreams/                      # Dream tracking data
├── .webchat/logs/conversations/      # WebChat logs (JSONL + MD)
├── skills/                           # Installed + imported skills
└── IMPORT_BACKLOG.md                 # Skipped import items (if any)

Conversation logs are stored in two formats per channel:

  • JSONL — one JSON object per line, ideal for programmatic access and memory indexing
  • Markdown — human-readable chat transcript

Run /agent:doctor first — it checks everything in one shot. Add --fix to auto-repair safe issues.

  • "Failed to reconnect to plugin:agent:clawcode" (or :clawcode:clawcode on community installs) — Dependencies didn't install. Check Node.js v18+ (node --version). Then try manually depending on where you installed from: close Claude, run cd ~/.claude/plugins/cache/clawcode/agent/*/ && npm install (own marketplace) or cd ~/.claude/plugins/cache/claude-community/clawcode/*/ && npm install (community), then reopen Claude.
  • Agent has no personality — Run /mcp to reload. The SessionStart hook injects identity from SOUL.md + IDENTITY.md.
  • Memory search returns nothing — Index builds on first search. For QMD: agent_config(action='set', key='memory.backend', value='qmd').
  • Agent doesn't remember things — The active memory reflex uses bilingual synonyms but not everything. Try different keywords.
  • Config change didn't take effect — Non-critical settings apply live. Critical ones need /mcp. The agent tells you which.
  • Messaging channels — Run /agent:channels status for installed/authenticated/active status.
  • Crons don't persist across restarts — Known limitation: durable: true is currently session-only in Claude Code. Crons are recreated automatically at each session start via the SessionStart hook (default heartbeat + dreaming). For 24/7, use /agent:service install.
  • /plugin update clawcode@agent stays silent for minutes — Not hung. Claude Code is downloading and installing the new version in the background; no progress indicator is shown during the fetch. Wait; a status line should appear when it's ready (can take a few minutes on the first update). Once it finishes, /plugins-reload is a good follow-up to make sure the running session picks up the new cache before the next turn.
  • Crons only run while Claude Code is open — for 24/7, use /agent:service install.
  • WebChat + WhatsApp logs are indexable via memory.extraPaths in config.
  • Each agent folder is fully self-contained — portable, backupable, deletable.

Per-feature documentation in docs/.

Build within Claude Code's limits. Use its plugin system, its hooks, its MCP servers. Don't patch Claude Code's internals; don't disable its features from the outside. If a feature needs restraint (the in-process auto-updater during daemon mode, for example), reach for the environment variable Claude Code itself documents, not a workaround. Respect the terms of service. The platform is where the agent lives, not something to work around.

Most of v1.4.0 and v1.4.1 came from @JD2005L, running ClawCode as a 24/7 systemd service and sending back a dozen PRs of fixes, hardening, and features from the front lines: the WORKSPACE resolution fix, the service crash-loop PTY wrap, the resume-on-restart wrapper, the hardening defaults, the /agent:update skill, cross-user import discovery, the reconcile fast-path, and the self-heal sidecar. Thank you.

ClawCode is an independent, open-source project. Claude is a trademark of Anthropic, PBC. ClawCode is not affiliated with or endorsed by Anthropic.

About

Persistent agents for Claude Code as a plugin, not a harness. Memory, personality, messaging across WhatsApp, Telegram, and Discord, plus a service mode for 24/7 runs. Imports from OpenClaw.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages