Skip to content

Instantly share code, notes, and snippets.

View Rustam-Z's full-sized avatar
πŸš€

@Rustam-Z Rustam-Z

πŸš€
View GitHub Profile
import os
import sys
print(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@Rustam-Z
Rustam-Z / aws-index.html
Created February 21, 2022 06:24
Simple HTML file to run in the AWS EC2 instance to check the server
<html>
<body bgcolor=black>
<center>
<h2><font color=yellow>Hello from Mars!</font></h2>
<font color=red>Rustam-Z</font>
</center>
</body>
</html>
@Rustam-Z
Rustam-Z / import.py
Created February 25, 2022 16:56
Import Python modules using strings
import importlib
# Contrived example of generating a module named as a string
full_module_name = "tables." + "tasks"
# The file gets executed upon import, as expected.
mymodule = importlib.import_module(full_module_name)
# Then you can use the module like normal
var = mymodule.COLUMNS
import pathlib
print(pathlib.Path(__file__).parent.absolute())
@Rustam-Z
Rustam-Z / .gitignore
Created May 15, 2022 07:12
Gitignore template
venv/*
.*
*.pyc
__pycache__*/
@Rustam-Z
Rustam-Z / MyLogger.py
Created August 1, 2022 13:07 — forked from huklee/MyLogger.py
python Logger using example with Singleton Pattern
# -*- coding: utf-8 -*-
import logging
import os
import datetime
import time
class SingletonType(type):
_instances = {}
@Rustam-Z
Rustam-Z / 00-intro.md
Created February 9, 2026 13:13 — forked from nodir-t/00-intro.md
Claudir Architecture Deep Dive β€” Table of Contents

Claudir Architecture Deep Dive

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.

Table of Contents

  1. The Three-Tier System β€” Owner/Supervisor, CTO bot, public chatbots. Trust hierarchy, bot-to-bot messaging, config-driven personalities, self-healing wrapper.

  2. The Harness and Engine β€” Three-process model, message flow pipeline, spam filtering, debouncer, control loop, inject mechanism, dropped text detection.

@Rustam-Z
Rustam-Z / 01-the-three-tier-system.md
Created February 9, 2026 13:13 — forked from nodir-t/01-the-three-tier-system.md
Claudir Architecture β€” Part 1: The Three-Tier System

Part 1: The Three-Tier System

Three-Tier Architecture

The Three Tiers

Each tier has a distinct identity, trust level, and permission set. The bot tiers share the same Rust binary (claudir) but run with different configuration files that control their behavior.

Tier 0: Owner & Supervisor

@Rustam-Z
Rustam-Z / 02-the-harness-and-engine.md
Created February 9, 2026 13:13 — forked from nodir-t/02-the-harness-and-engine.md
Claudir Architecture β€” Part 2: The Harness and Engine

Part 2: The Harness and Engine

Three-Process Model

Message Flow Pipeline

Each Bot = Three Processes

Every bot instance consists of three OS processes. The harness is the core β€” it handles Telegram I/O, hosts the MCP tool server, and manages the CC subprocess. CC is the brain β€” it processes messages, makes tool calls back to the harness via HTTP, and returns control actions. The wrapper just ensures the harness stays alive.

@Rustam-Z
Rustam-Z / 03-mcp-and-the-tool-system.md
Created February 9, 2026 13:13 — forked from nodir-t/03-mcp-and-the-tool-system.md
Claudir Architecture β€” Part 3: MCP and the Tool System

Part 3: MCP and the Tool System

MCP Tool Architecture

Why MCP?

The original design had Claude Code return a JSON array of tool calls via StructuredOutput. This worked, but was limiting β€” Claude had to batch all tool calls into a single response, couldn't chain results, and complex JSON parsing was error-prone.

MCP solves all of these. Claude Code makes HTTP calls to a local server during its turn, gets results back, and can chain tool calls naturally. Within a single turn, the bot can send multiple messages, check the database, generate an image, and react to a message β€” all as separate MCP calls interleaved with reasoning. The harness runs the MCP server, so tool execution is still controlled by Rust code.