System Architecture
Tiny Claw is built from scratch as a native framework with a philosophy of keeping the core tiny and making everything else pluggable. This architectural approach ensures minimal footprint, maximum flexibility, and zero dependency on external AI frameworks.Core Design Principles
Tiny Core
The core stays minimal. All non-essential features live as plugins.
Plugin Everything
Channels, providers, and tools are all plugins. Easy to extend.
Native, Not Wrapped
Every component is built from scratch with zero external AI framework dependencies.
Bun-Native
Built on Bun for maximum performance and minimal footprint.
Architecture Diagram

plugins/.
Layer Breakdown
User Layer
Users interact with Tiny Claw through various channels:- Web UI — Discord-like interface with SSE streaming
- Discord — Native Discord bot integration
- Friends — Private chat invites for trusted users
- CLI — Command-line interface (planned)
Channel Plugins (Pluggable)
Channel plugins connect external messaging platforms to the agent loop:getPairingTools()— called during boot to merge pairing toolsstart(context)— called after agentContext is built- The plugin drives messages into the agent via
context.enqueue stop()— called during graceful shutdown
Tiny Core (packages/core/)
The core contains:Router
Smart query classification using 8-dimension scoring to route queries to appropriate providers
Tool Plugins (Pluggable)
Additional capabilities can be added via tool plugins:- Web browsing and scraping
- Image generation and analysis
- Calendar and scheduling
- Email and notifications
- Cloud service integrations
Model Provider Plugins (Pluggable)
Provider plugins register additional LLM providers:- OpenAI (GPT-4, GPT-4o)
- Anthropic (Claude)
- Local Ollama
- Google Gemini
LLM Layer
Providers abstract the underlying LLM APIs:- Multi-provider support with automatic failover
- Query tier routing (simple → cheap models, complex → powerful models)
- Provider health checks and fallback chains
Package Structure
Data Flow
Channel Plugin
Channel plugin receives the message and enqueues it via
context.enqueue(userId, message)Agent Loop
Core agent loop processes the message:
- Loads conversation history from SQLite
- Retrieves relevant memories (episodic + semantic search)
- Builds system prompt with heartware personality context
- Classifies query complexity via Router
- Selects appropriate provider based on tier
Tool Execution
If LLM requests tool calls:
- Shield evaluates each tool call for threats
- Tools are executed (memory, delegation, heartware, etc.)
- Results are fed back to LLM
Key Interfaces
AgentContext
The central context object passed to tools and agents:packages/types/src/index.ts
Tool Interface
packages/types/src/index.ts
Message Format
packages/types/src/index.ts
Why This Architecture?
Tiny Core = Low Overhead
Tiny Core = Low Overhead
By keeping only essential features in core, Tiny Claw remains lightweight and fast. The entire core is under 50KB compressed.
Plugins = Flexibility
Plugins = Flexibility
Users only load what they need. Don’t need Discord? Don’t load the plugin. Want to add GitHub integration? Write a tool plugin.
Native = No Lock-In
Native = No Lock-In
Unlike frameworks built on top of other AI frameworks, Tiny Claw owns its entire stack. No dependency on proprietary systems.
Bun = Performance
Bun = Performance
Bun is 3x faster than Node.js for I/O operations and provides a single binary runtime with built-in TypeScript support.
Comparison with Other Frameworks
| Tiny Claw | Other AI Agent Frameworks | |
|---|---|---|
| Architecture | Native framework, built from scratch | Built on existing frameworks (Pi, Claude Code, Codex) |
| Core size | Tiny by design, everything else is a plugin | Large monolith that grows over time |
| Runtime | Bun-native, single binary | Node.js 22+, pnpm, multiple processes |
| Routing | Adapts to whichever provider plugins you install | Hardcoded to a single provider |
| Security | Built-in SHIELD.md anti-malware enforcement | No native threat model |
| UI | Discord-like web experience out of the box | Terminal-only or separate UI dependency |
Next: Plugin System
Learn how to build and extend Tiny Claw with plugins