Claudir is a ~33,000-line Rust Telegram bot system that uses Claude AI (via Anthropic's Claude Code CLI) to power intelligent chat interactions. What makes it architecturally interesting is not just that it wraps an LLM — it's how it structures trust, isolation, and operational resilience through a deliberate three-tier hierarchy.
-
The Three-Tier System — Owner/Supervisor, CTO bot, public chatbots. Trust hierarchy, bot-to-bot messaging, config-driven personalities, self-healing wrapper.
-
The Harness and Engine — Three-process model, message flow pipeline, spam filtering, debouncer, control loop, inject mechanism, dropped text detection.
-
MCP and the Tool System — ~40 tools via Model Context Protocol, heartbeat problem, memory system security, rate limiting, SSRF protection.
-
The Security Model — 11 defense layers, spam classification, tool restrictions, kill switch, real social engineering incidents.
-
Claude Code Integration — Subprocess management, worker thread architecture, stdin/stdout streaming, crash recovery, shared state across restarts.
-
Focus Mode — Single-chat attention, cursor system, debouncing, stop-rejection, muting vs focus.
-
Database Schema — ~20 SQLite tables: messaging, spam, reminders, focus, billing (with WAL pattern), embeddings, operations.