Skip to content
Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TinyClaw 🦞

Minimal multi-channel AI assistant with WhatsApp integration and queue-based architecture.

🎯 What is TinyClaw?

TinyClaw is a lightweight wrapper around Claude Code that:

  • βœ… Connects WhatsApp (via QR code)
  • βœ… Processes messages sequentially (no race conditions)
  • βœ… Maintains conversation context
  • βœ… Runs 24/7 in tmux
  • βœ… Ready for multi-channel (Telegram, etc.)

Key innovation: File-based queue system prevents race conditions and enables multi-channel support.

πŸ“ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  WhatsApp       │──┐
β”‚  Client         β”‚  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                     β”œβ”€β”€β†’ Queue (incoming/)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚        ↓
β”‚  Telegram       │───   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  (future)       β”‚  β”‚   β”‚   Queue      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚   β”‚  Processor   β”‚
                     β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Other Channels β”€β”€β”€β”€β”€β”€β”˜        ↓
                         claude --dangerously-skip-permissions -c -p
                              ↓
                         Queue (outgoing/)
                              ↓
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ Channels send   β”‚
                    β”‚ responses       β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tmux Layout

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  WhatsApp    β”‚    Queue     β”‚
β”‚  Client      β”‚  Processor   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Heartbeat   β”‚    Logs      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • macOS or Linux
  • Claude Code installed
  • Node.js v14+
  • tmux

Installation

cd /Users/jliao/workspace/tinyclaw

# Install dependencies
npm install

# Make scripts executable
chmod +x *.sh *.js

# Start TinyClaw
./tinyclaw.sh start

First Run

A QR code will appear in your terminal:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
        WhatsApp QR Code
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

[QR CODE HERE]

πŸ“± Scan with WhatsApp:
   Settings β†’ Linked Devices β†’ Link a Device

Scan it with your phone. Done! πŸŽ‰

Test It

Send a WhatsApp message to yourself from a different WhatsApp account:

"Hello Claude!"

You'll get a response! πŸ€–

πŸ“‹ Commands

# Start TinyClaw
./tinyclaw.sh start

# Check status
./tinyclaw.sh status

# Send manual message
./tinyclaw.sh send "What's the weather?"

# Reset conversation
./tinyclaw.sh reset

# View logs
./tinyclaw.sh logs whatsapp
./tinyclaw.sh logs queue

# Attach to tmux
./tinyclaw.sh attach

# Stop
./tinyclaw.sh stop

πŸ”§ Components

1. whatsapp-client.js

  • Connects to WhatsApp via QR code
  • Writes incoming messages to queue
  • Reads responses from queue
  • Sends replies back

2. queue-processor.js

  • Polls incoming queue
  • Processes ONE message at a time
  • Calls claude -c -p
  • Writes responses to outgoing queue

3. heartbeat-cron.sh

  • Runs every 5 minutes
  • Sends heartbeat via queue
  • Keeps conversation active

4. tinyclaw.sh

  • Main orchestrator
  • Manages tmux session
  • CLI interface

πŸ’¬ Message Flow

WhatsApp message arrives
       ↓
whatsapp-client.js writes to:
  .tinyclaw/queue/incoming/whatsapp_<id>.json
       ↓
queue-processor.js picks it up
       ↓
Runs: claude -c -p "message"
       ↓
Writes to:
  .tinyclaw/queue/outgoing/whatsapp_<id>.json
       ↓
whatsapp-client.js sends response
       ↓
User receives reply

πŸ“ Directory Structure

tinyclaw/
β”œβ”€β”€ .claude/              # Claude Code config
β”‚   β”œβ”€β”€ settings.json     # Hooks config
β”‚   └── hooks/            # Hook scripts
β”œβ”€β”€ .tinyclaw/            # TinyClaw data
β”‚   β”œβ”€β”€ queue/
β”‚   β”‚   β”œβ”€β”€ incoming/     # New messages
β”‚   β”‚   β”œβ”€β”€ processing/   # Being processed
β”‚   β”‚   └── outgoing/     # Responses
β”‚   β”œβ”€β”€ logs/
β”‚   β”œβ”€β”€ whatsapp-session/
β”‚   └── heartbeat.md
β”œβ”€β”€ tinyclaw.sh           # Main script
β”œβ”€β”€ whatsapp-client.js    # WhatsApp I/O
β”œβ”€β”€ queue-processor.js    # Message processing
└── heartbeat-cron.sh     # Health checks

πŸ”„ Reset Conversation

Via CLI

./tinyclaw.sh reset

Via WhatsApp

Send: !reset or /reset

Next message starts fresh (no conversation history).

βš™οΈ Configuration

Heartbeat Interval

Edit heartbeat-cron.sh:

INTERVAL=300  # seconds (5 minutes)

Heartbeat Prompt

Edit .tinyclaw/heartbeat.md:

Check for:

1. Pending tasks
2. Errors
3. Unread messages

Take action if needed.

πŸ“Š Monitoring

View Logs

# WhatsApp activity
tail -f .tinyclaw/logs/whatsapp.log

# Queue processing
tail -f .tinyclaw/logs/queue.log

# Heartbeat checks
tail -f .tinyclaw/logs/heartbeat.log

# All logs
./tinyclaw.sh logs daemon

Watch Queue

# Incoming messages
watch -n 1 'ls -lh .tinyclaw/queue/incoming/'

# Outgoing responses
watch -n 1 'ls -lh .tinyclaw/queue/outgoing/'

🎨 Features

βœ… No Race Conditions

Messages processed sequentially, one at a time:

Message 1 β†’ Process β†’ Done
Message 2 β†’ Wait β†’ Process β†’ Done
Message 3 β†’ Wait β†’ Process β†’ Done

βœ… Multi-Channel Ready

Add Telegram by creating telegram-client.js:

// Write to queue
fs.writeFileSync(
  '.tinyclaw/queue/incoming/telegram_<id>.json',
  JSON.stringify({ channel: 'telegram', message, ... })
);

// Read responses
// Same format as WhatsApp

Queue processor handles it automatically!

βœ… Clean Responses

Uses claude -c -p:

  • -c = continue conversation
  • -p = print mode (clean output)
  • No tmux capture needed

βœ… Persistent Sessions

WhatsApp session persists across restarts:

# First time: Scan QR code
./tinyclaw.sh start

# Subsequent starts: Auto-connects
./tinyclaw.sh restart

πŸ” Security

  • WhatsApp session stored locally in .tinyclaw/whatsapp-session/
  • Queue files are local (no network exposure)
  • Each channel handles its own authentication
  • Claude runs with your user permissions

πŸ› Troubleshooting

WhatsApp not connecting

# Check logs
./tinyclaw.sh logs whatsapp

# Re-authenticate
rm -rf .tinyclaw/whatsapp-session/
./tinyclaw.sh restart

Messages not processing

# Check queue processor
./tinyclaw.sh status

# Check queue
ls -la .tinyclaw/queue/incoming/

# View queue logs
./tinyclaw.sh logs queue

QR code not showing

# Use helper script
./show-qr.sh

# Or attach to tmux
tmux attach -t tinyclaw

πŸš€ Production Deployment

Using systemd

sudo systemctl enable tinyclaw
sudo systemctl start tinyclaw

Using PM2

pm2 start tinyclaw.sh --name tinyclaw
pm2 save

Using supervisor

[program:tinyclaw]
command=/path/to/tinyclaw/tinyclaw.sh start
autostart=true
autorestart=true

🎯 Use Cases

Personal AI Assistant

You: "Remind me to call mom"
Claude: "I'll remind you!"
[5 minutes later via heartbeat]
Claude: "Don't forget to call mom!"

Code Helper

You: "Review my code"
Claude: [reads files, provides feedback]
You: "Fix the bug"
Claude: [fixes and commits]

Multi-Device

  • WhatsApp on phone
  • Telegram on desktop
  • CLI for scripts All share the same Claude conversation!

πŸ™ Credits

πŸ“„ License

MIT


TinyClaw - Small but mighty! 🦞✨

About

Tiny openclaw

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages